Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
klehar
Helper V
Helper V

Issue with reproducing same outputs for my predictions

Hi,

 

I'm trying to run a python script that will essentially perform time series forecasting on my input data.

What I want is the next 12 predicted values.

I did this in jupyter and power bi both but I'm getting different values for same dates

I'm not sure what random seed needs to be set here.

 

Code:

import numpy as np
import matplotlib.pyplot as plt
import pypyodbc  as pyodbc
import pandas as pd 
from statsmodels.tsa.arima_model import ARMA,ARMAResults,ARIMA,ARIMAResults
from statsmodels.graphics.tsaplots import plot_acf,plot_pacf # for determining (p,q) orders
from statsmodels.tsa.holtwinters import ExponentialSmoothing

SERVER_NAME = 'm.its.corp.net'
DATABASE_NAME = 'GDB'


cnxn = pyodbc.connect(Driver='{SQL Server}', Server=SERVER_NAME , database=DATABASE_NAME,
                      trusted_connection='Yes')

cursor = cnxn.cursor()



sql_query = """
select * from mytable
"""


# With Headers
df = pd.read_sql(sql_query, cnxn,index_col='date',parse_dates=True)
#index col is required to make sure stasmodel on this dataset we need to set index frequency
df.index.freq = 'MS'

method_TESmul12 = ExponentialSmoothing(df['tcv'],trend='mul',seasonal='mul',seasonal_periods=12).fit()
range = pd.date_range('01-02-2022',periods=12,freq='MS')
predictions = method_TESmul12.forecast(12).astype(int)
predictions_range = pd.DataFrame({'Date':range, 'TCV':predictions})
predictions_range

 

What is wrong?
Dataset has 110 records. 2 records pasted below:

 

datetcv
1/1/20132011131
2/1/20132053142
1 REPLY 1
Anonymous
Not applicable

Hi @klehar ,

 

Could you share a sample file with us? And you can show us a screenshot with the result you want. This will make it easier for us to understand your requirements.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors