By forecast And predict Trouble for a period of time , Opinions vary on the Internet .
Do data processing this time , A rough conclusion is drawn from the comparison , The use of parameters is not discussed in detail ( Please refer to the help document ):
edition :statsmodels 0.13.1
forecast Parameters steps, Indicates how many time points are predicted (fit After sample data ).
eg:
x=[1,2,3,4,5,6]
…
model.fit(x,y)
model.forecast(5), stay fit After the data sequence ( Out of sample ),forecast5 A little bit (x by 7,8,9,10,11)y Value .
predict Parameters (start,end) ,start Starting time ,end End point .
start 、 There is no limit to the end (in sample And out of sample All possible ),end Greater than start.
The values in the sample are fitted values , Outside the sample is the prediction .
If you only give one int value , Default view :
Greater than fit The last time point of the sample , Predict the value at this time .
Less than fit The last time point of the sample ,predict Current value to fit The last time point of the sample .
eg:
x=[1,2,3,4,5,6]
…
model.fit(x,y)
model.predict(2) #predict x be equal to 2,3,4,5,6 Of y
model.predict(7) #forecast x be equal to 7 Of y
get_prediction Basically the same predict
But the returned values are different . To view the forecast results, you need to use
.predicted_mean attribute
eg:
x=[1,2,3,4,5,6]
…
model.fit(x,y)
result=model.get_prediction(2)
result.predicted_mean # Return forecast results