蟒蛇世界相当新鲜。 我试图将我的SARIMAX模型的输出保存/打印到word文档,看来,我无法保存或打印word doc中的图/图。 一些文本行确实打印在单词doc中,但不打印在图中。 你能告诉我哪里出错了吗?
AIC = []
ar = [0,1,2,3,4]
for ar in ar:
ma = [0,1,2,3,4]
for ma in ma:
SDIFF = ['True','False']
for sd in SDIFF:
try:
model = sm.tsa.statespace.SARIMAX(data, order=(ar,0,ma), seasonal_order=(ar,0,ma,1), simple_differencing=sd)
result = model.fit()
except:
with open('file.doc', 'a') as f:
print('Time Run:', str(datetime.now()), file = f)
print('ar=',ar, 'ma=',ma, 'sd=',sd, file = f)
#Result.append(result)
print(result.summary(), file = f)
AIC.append(result.aic)
data_fcpred = result.predict(start = 16, end = 18, dynamic= True)
print(plt.plot(data_fcpred , color = 'red'), file = f)
print(plt.plot(data), file = f)
print(result.plot_diagnostics(), file = f)
print(plt.show(), file = f)
print('AIC', result.aic, file = f)
print(data[15:], file = f)
print(data_fcpred, file = f)
plt.clf()
print("#############################################", file = f)
print("#######################################", file = f)
continue
我可以执行plt.savefig,但是根据我在savefig方法中指定的名称,它会保存到不同的文件中。
我真正需要的是在同一个单词doc中绘制数字。