課程
/后端開發(fā)
/Python
/Python實(shí)現(xiàn)線性回歸
我看了一點(diǎn),但是不是很明白
2018-04-08
源自:Python實(shí)現(xiàn)線性回歸 1-1
正在回答
import numpy as np?
from numpy.linalg import inv
from numpy import dot
from numpy import mat
import pandas as pd?
dataset = pd.read_csv('data.csv')
print(dataset)
temp = dataset.iloc[:,2:5] #iloc :對(duì)數(shù)組進(jìn)行切片
# X = mat([1,2,3]).reshape(3,1)
# Y = 2*X
# # theta = (X'X)^-1X'Y
# #theta = dot(dot(inv(dot(X.T,X)), X.T),T)
# #theta = theta - alpha*(theta*X-Y)*X
# theta = 1.
# alpha = 0.1
# for i in range(100):
# theta = theta + np.sum(alpha *(Y - dot(X,theta))*X.reshape(1,3))/3.#加權(quán)平均
# print(theta
舉報(bào)
掌握python進(jìn)行線性回歸分析的原理及編程實(shí)踐
2 回答學(xué)習(xí)目標(biāo)怎么制定
1 回答我的啊大師傅撒旦
2 回答sei ta 和X 都是1行n列的矩陣 怎么相乘啊
2 回答1 最小二乘和梯度下降的公式怎么得來的?
2 回答theta*x 為什么是點(diǎn)乘?直接乘不行嗎
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-04-08
import numpy as np?
from numpy.linalg import inv
from numpy import dot
from numpy import mat
import pandas as pd?
dataset = pd.read_csv('data.csv')
print(dataset)
temp = dataset.iloc[:,2:5] #iloc :對(duì)數(shù)組進(jìn)行切片
# X = mat([1,2,3]).reshape(3,1)
# Y = 2*X
# # theta = (X'X)^-1X'Y
# #theta = dot(dot(inv(dot(X.T,X)), X.T),T)
# #theta = theta - alpha*(theta*X-Y)*X
# theta = 1.
# alpha = 0.1
# for i in range(100):
# theta = theta + np.sum(alpha *(Y - dot(X,theta))*X.reshape(1,3))/3.#加權(quán)平均
# print(theta