facebookresearch / Kats

Kats, a kit to analyze time series data, a lightweight, easy-to-use, generalizable, and extendable framework to perform time series analysis, from understanding the key statistics and characteristics, detecting change points and anomalies, to forecasting future trends.
MIT License
4.93k stars 537 forks source link

Plots in forecast tutorial doesn't match output. #233

Closed BinhHong closed 2 years ago

BinhHong commented 2 years ago

I run the code in Prophet Forecast in tutorial with the air_passengers dataset and m.plot() but the result doesn't match the output there. If I remember correctly, it used to.

MoKazemi9 commented 2 years ago

Hi @BinhHong ,Thanks for sharing the issue!, can you provide more context, the code and the plot to replicate the issue?

BinhHong commented 2 years ago

Hi @MoKazemi9 , the code here is exactly the same as in tutorial https://github.com/facebookresearch/Kats/blob/main/tutorials/kats_201_forecasting.ipynb.

The dataset is air_passengers.csv

air_passengers_df = pd.read_csv("air_passengers.csv")
air_passengers_df.columns = ["time", "value"]
air_passengers_ts = TimeSeriesData(air_passengers_df)

from kats.models.sarima import SARIMAModel, SARIMAParams
warnings.simplefilter(action='ignore')

# create SARIMA param class
params = SARIMAParams(
    p = 2, 
    d=1, 
    q=1, 
    trend = 'ct', 
    seasonal_order=(1,0,1,12)
    )

# initiate SARIMA model
m = SARIMAModel(data=air_passengers_ts, params=params)

# fit SARIMA model
m.fit()

# generate forecast values
fcst = m.predict(
    steps=30, 
    freq="MS"
    )

Then m.plot() produces Herunterladen (1) whereas in the tutorial Herunterladen

SakshiNYCU commented 2 years ago

@BinhHong I'm facing the same issue with the Ensemble model. A couple of weeks ago my graphs showed the actual and forecasted trends together but now as I try to replicate my results with the same code and data, they just show the forecasted trends.

I suggest you try the following:

# generate forecast values fcst = m.predict( steps=30, freq="MS" include_history = True )

I tried it for Ensemble, but it shows some error. However, in the case of SARIMA it works for me.

BinhHong commented 2 years ago

Hi @SakshiNYCU, thanks a lot for your suggestion. The result looks as I expected testKats

compared to the tutorial

Herunterladen

jeffhandl commented 2 years ago

263 should resolve this.