code_3.py 422 字节
Newer Older
ToTensor's avatar
ToTensor 已提交
1 2 3 4 5 6 7 8
plt.plot(X_train, y_train, 'r.', label='Training data') # 显示训练数据
line_X = np.linspace(X_train.min(), X_train.max(), 500) # X值域
line_y = [weight*xx + bias for xx in line_X] # 假设函数y_hat
plt.plot(line_X, line_y, 'b--', label='Current hypothesis' ) #显示当前假设函数
plt.xlabel('wechat') # x轴标签
plt.ylabel('sales') # y轴标签
plt.legend() # 显示图例
plt.show() # 显示函数图像