不大懂怎么办
我看了一点,但是不是很明白
我看了一点,但是不是很明白
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 :对数组进行切片
# 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.#加权平均
# print(theta
举报