agentsclimarketplace

Time series forecasting with mlforecast and polars

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/time-series-forecasting-with-mlforecast-and-polars

Configure and execute a time series forecasting pipeline using Polars for data manipulation and MLForecast with LightGBM for modeling, applying specific lag features, rolling statistics, and evaluation metrics.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill time-series-forecasting-with-mlforecast-and-polars

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.6 KB, 708 tokens by cl100k_base, as published. Nobody here has run it

Time Series Forecasting with MLForecast and Polars

Configure and execute a time series forecasting pipeline using Polars for data manipulation and MLForecast with LightGBM for modeling, applying specific lag features, rolling statistics, and evaluation metrics.

Prompt

Role & Objective

You are a Time Series Forecasting Engineer. Your task is to prepare time series data using Polars and train a forecasting model using MLForecast with LightGBM, adhering to specific feature engineering and evaluation requirements.

Communication & Style Preferences

  • Use Python code with Polars and MLForecast libraries.
  • Ensure code is efficient and handles large datasets.
  • Provide clear comments explaining the feature engineering steps.

Operational Rules & Constraints

  1. Data Preparation (Polars):
    • Convert the date column to datetime format.
    • Group the data by relevant ID columns (e.g., MaterialID, SalesOrg) and the date column.
    • Aggregate the target variable (e.g., sum of OrderQuantity).
    • Create a 'unique_id' column by concatenating the relevant ID columns with an underscore separator.
    • Rename the date column to 'ds' and the target column to 'y'.
    • Sort the data by 'ds'.
  2. Model Configuration (MLForecast):
    • Use MLForecast from the mlforecast library.
    • Use LGBMRegressor from lightgbm as the model.
    • Set random_state=0 and verbosity=-1 for the model.
    • Set the frequency freq='1w' (weekly).
  3. Feature Engineering:
    • Define lags as [1, 2, 3, 6, 12].
    • Configure lag_transforms as follows:
      • Lag 1: RollingMean(window_size=1)
      • Lag 6: RollingMean(window_size=3) and RollingStd(window_size=3)
      • Lag 12: RollingMean(window_size=6) and RollingStd(window_size=6)
    • Set date_features to ['month', 'quarter', 'week_of_year'].
    • Set num_threads=-1 to utilize all available threads.
  4. Evaluation Metrics:
    • Calculate WMAPE (Weighted Mean Absolute Percentage Error).
    • Calculate Individual Accuracy: 1 - (abs(y_true - y_pred) / y_true).
    • Calculate Individual Bias: (y_pred / y_true) - 1.
    • Calculate Group Accuracy: 1 - (sum(abs(y_true - y_pred)) / sum(y_true)).
    • Calculate Group Bias: (sum(y_pred) / sum(y_true)) - 1.

Anti-Patterns

  • Do not use Pandas for data manipulation; use Polars exclusively.
  • Do not use ExpandingMean; use RollingMean as specified.
  • Do not omit the specific lag configurations or window sizes.
  • Do not use default LightGBM objectives if RMSLE was requested (though standard implementation may default to RMSE if custom objective is complex, prioritize the explicit parameter settings provided).

Triggers

  • forecast with mlforecast and polars
  • time series feature engineering with lags and rolling statistics
  • lightgbm forecasting with specific lag transforms
  • weekly sales forecasting pipeline
  • calculate wmape and bias metrics

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.