© 1999-2048 dssz.net 粤ICP备11031372号
[其它] 算法应用,单变量线性回归&梯度下降:已知如下数据集,绘制出数据集的散点图并给出能够和所有散点拟合出最好的一条直线
说明:import numpy as np import matplotlib.pyplot as plt # 算法应用,单变量线性回归&梯度下降:已知如下数据集,绘制出数据集的散点图并给出能够和所有散点拟合出最好的一条直线 # 预测函数 def getHypo(X, theta): return np.dot(X, theta) # 代价函数 def getCost(h, y): m = len(h) return (1.0 / 2*m) * np.sum(np.square<weixin_38645862> 上传 | 大小:50kb