How to Get all the Output

Siew

Suppose I would like to predict a time series data in a given random rows. let say Index = (2000, 4000, 12000) , it means i would like to predict the output at row 2000, 4000 and 12000 Below is my code:

index = df['Index']
y=[]
for index in index:
    ind_1 = index - 1;
    ind = data.iloc[:ind_1]
    fit = SimpleExpSmoothing(ind).fit(smoothing_level=0.65,optimized=False)
    y = fit.forecast(1)
    y.append(y)

print(y)

But it only shows me the last prediction which is at row 12000.

Is it possible to know how I can get the other outputs as well at row 2000 and 4000?

Thanks.

Faquarl

Rename your y list something else, it is getting overwritten - you change it here

y   = fit.forecast(1);

so at the end you are printing the last output of above. You must have not pasted all of your code, as you would be crashing if you were appending to anything that is not a list here

y.append(y)

The full fix is below

index = df['Index']

y = []
for index in index:
    ind_1 = index - 1;
    ind = data.iloc[:ind_1]
    fit = SimpleExpSmoothing(ind).fit(smoothing_level=0.65,optimized=False)
    x = fit.forecast(1)
    y.append(x)

print(y)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related