简体   繁体   中英

Python prediction value output into excel

I create the following codes and get the forecast chart but don't know how to export the predicted value into excel.

import statsmodels as sm
sm.tsa.holtwinters.ExponentialSmoothing

model_expo1= sm.tsa.holtwinters.ExponentialSmoothing(monthly_series,trend='add',
                                                     seasonal='add',seasonal_periods=12)

results_1= model_expo1.fit()

results_1.summary()

fit1= model_expo1.fit().predict(0,len(monthly_series))

mae1= abs(monthly_series- fit1).mean()

forecast1=model_expo1.fit().predict(0,len(monthly_series)+12)
monthly_series.plot(label='actual')
forecast1.plot(label='forecast')

Thank you

# Create a DataFrame containing the forecast values.
forecast_df = pd.DataFrame({"forecast": forecast1})

# Write the DataFrame to an Excel file.
forecast_df.to_excel("forecast_values.xlsx")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM