最后一次输出执行有错
哪位大神帮我看一下那个地方出错了
***********************************************
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]
temp['X0']=1 #截距
X=temp.iloc[:,[3,0,1,2]] #读取temp的第3,0,1,2列
#print(X)
#iloc[m,n] m-行 n-列
Y=dataset.iloc[:,1].values.reshape(150,1)
#print(Y)
theta = dot(dot(inv(dot(X.T,X)),X.T),Y)
print(theta)
theta=np.array([1.,1.,1.,1.]).reshape(4,1)
alpha=0.1 #学习速率
X0=X.iloc[:,0].values.reshape(150,1)
X1=X.iloc[:,1].values.reshape(150,1)
X2=X.iloc[:,2].values.reshape(150,1)
X3=X.iloc[:,3].values.reshape(150,1)
for i in range(10000):
temp[0]=theta[0] + alpha*np.sum((Y-dot(X,theta))*X0)/150.0
temp[1]=theta[1] + alpha*np.sum((Y-dot(X,theta))*X0)/150.0
temp[2]=theta[2] + alpha*np.sum((Y-dot(X,theta))*X0)/150.0
temp[3]=theta[3] + alpha*np.sum((Y-dot(X,theta))*X0)/150.0
theta=temp
print(theta)
***************************************************************