我想在散点图上画一个线性回归图。在
def chart1(df, yr, listcols):
temp = df[(df['YEAR']==yr)]
fig, axes = plt.subplots(nrows=2, ncols=2, figsize = (12,12))
for e in [['WD','pk_h',0,0],['WD','of_h',0,1],['SAT','of_h',1,0],['SUN','of_h',1,1]]:
temp.ix[(temp['daytype']==e[0])&(temp['hourtype']==e[1]),listcols].plot(kind='scatter', title=str(yr)+' '+e[0]+' '+e[1], x=listcols[0], y=listcols[1], ax=axes[e[2],e[3]])
fig.tight_layout()
return temp
chartd = chart1(o2, 2017,['PROD', 'option_exercise'])
我不知道如何在我的循环中使它成为可能。在
它应该是这样工作的:
在for循环中运行回归并将结果存储到“res”中。使用存储的系数手动计算预测的y(“yhat”)。然后绘制x与y和x与yhat的图表:
相关问题 更多 >
编程相关推荐