我一直试图在一个变量中编写我自己的Pyhton程序进行线性回归,如Coursera所示。我写了以下代码 -
def ComputeCost(X,y,init_Theta):
calculated_cost = (1./2*m)*(np.dot(np.transpose((H_Theta(X,init_Theta)-y)),(H_Theta(X,init_Theta)-y)))
return calculated_cost
此函数以下列方式用于LinearRegression函数:
for i in range(iterations):
tempTheta = theta
calculated_cost = ComputeCost(X,y,tempTheta)
print(calculated_cost)
该程序给了我这个错误:
calculated_cost = (1./2*m)*(np.dot(np.transpose((H_Theta(X,init_Theta)-y)), (H_Theta(X,init_Theta)-y)))
RuntimeWarning: overflow encountered in multiply
请在这方面帮助我。