Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance on Seasonal Intermittent Demand Data #194

Open
Arsa-Nik opened this issue Nov 28, 2024 · 0 comments
Open

Performance on Seasonal Intermittent Demand Data #194

Arsa-Nik opened this issue Nov 28, 2024 · 0 comments

Comments

@Arsa-Nik
Copy link

Arsa-Nik commented Nov 28, 2024

I am using TimesFM on monthly demand data (specifically seasonal intermittent), and I wonder whether my current parameter setup is correct and if you have further insights on how to improve its performance—I'm in the process of fine-tuning it next.
P.S. I'm using v1.2.1, and it seems _median_index is not initialized in this version so I manually initialized it below.

data_1 = {
    'unique_id': ['ID_1'] * 52,  
    'ds': pd.date_range(start='2018-12-01', periods=52, freq='MS').tolist(),
    'values': [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 4.0, 46.0, 395.0,
               0.0, 0.0, 5.0, 2.0, 2.0, 0.0, 0.0, 3.0, 7.0, 23.0, 84.0,
               494.0, 177.0, 387.0, 8.0, 2.0, 5.0, 1.0, 0.0, 5.0, 10.0,
               33.0, 86.0, 2213.0, 1331.0, 141.0, 19.0, 5.0, 1.0, 5.0,
               7.0, 6.0, 7.0, 17.0, 202.0, 3240.0, 2178.0, 8.0, 2.0, 1.0]
}
train_data = pd.DataFrame(data_1)
tfm = timesfm.TimesFm(
      hparams=timesfm.TimesFmHparams(
          backend="gpu",
          per_core_batch_size=32,
          horizon_len=18,
      ),
      checkpoint=timesfm.TimesFmCheckpoint(
          huggingface_repo_id="google/timesfm-1.0-200m"),
  )
tfm._median_index = -1 
forecast = tfm.forecast_on_df(
        inputs=train_data,
        freq='MS',
        num_jobs=-1, 
    )
    
plt.figure(figsize=(14, 8))
plt.plot(train_data['ds'], train_data['values'], label='Actuals', marker='o', linestyle='-', color='blue')
plt.plot(forecast['ds'], forecast['timesfm'], label='Forecast', marker='o', linestyle='--', color='orange')
plt.fill_between(forecast['ds'], forecast['timesfm-q-0.1'], forecast['timesfm-q-0.9'], color='orange', alpha=0.2, label='90% Confidence Interval')
plt.title('Actuals and Forecasts with Prediction Intervals', fontsize=16)
plt.xlabel('Date', fontsize=14)
plt.ylabel('Values', fontsize=14)
plt.legend(fontsize=12)
plt.grid(True)
plt.tight_layout()
plt.show()

Screenshot 2024-11-28 at 11 50 50 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant