fig, ax = plt.subplots(figsize=(12,8))
ax.plot(x, f, 'r', label='Prediction')
ax.scatter(data.Population, data.Profit, label='Traning Data')
ax.legend(loc=2)
ax.set_xlabel('Population')
ax.set_ylabel('Profit')
ax.set_title('Predicted Profit vs. Population Size')
plt.show()
这篇博客展示了如何使用Python的matplotlib库创建一个图表,该图表描绘了预测的利润与人口规模之间的关系。通过红色曲线表示预测值,用散点图表示训练数据。图表清晰地标注了x轴为'Population'(人口),y轴为'Profit'(利润),并设有标题'PredictedProfitvs.PopulationSize',有助于理解数据分布和模型预测效果。
2688

被折叠的 条评论
为什么被折叠?



