Introduction to StatsForecast: Boost your Time Series Forecasting

Cover Image for Introduction to StatsForecast: Boost your Time Series Forecasting

In the world of data-driven decision-making, time series forecasting plays an essential role in predicting future trends and driving business success. To empower organizations with even greater predictive capabilities, MindsDB is thrilled to announce its recent integration with Nixtla's StatsForecast, a machine learning engine tailored for accurate and efficient time series forecasting.

In this blog post, we introduce the StatsForecast engine and present usage examples.

Streamline Forecasting with StatsForecast

The advantages brought to time series forecasting by the StatsForecast engine integration with MindsDB include fast and accurate implementations of models, probabilistic forecasting and confidence intervals, support for exogenous variables and static covariates, anomaly detection, and more.

To explore the implementation details and features of StatsForecast in-depth, please refer to this link. Please note that this integration does not cover all available features of StatsForecast; we’re working on enabling more features soon.

Example: Forecasting Future Expenses

Let’s create a model based on the StatsForecast engine to estimate monthly expenses of various categories.

CREATE MODEL quarterly_expenditure_forecaster
FROM mysql_demo_db
  (SELECT * FROM historical_expenditures)
PREDICT expenditure
ORDER BY month
GROUP BY category
HORIZON 3
USING
        ENGINE = 'statsforecast';
        HIERARCHY = [‘category’];

We use the CREATE MODEL statement to create and train the quarterly_expenditure_forecaster model.

As it is not a pre-trained model, we must provide a training dataset in the FROM clause so the model learns from patterns followed by historical data. We use the historical_expenditures table that stores monthly expenditures of different categories.

Next, we define the column to be predicted (here, it is the expenditure column). It is followed by the ORDER BY clause, ensuring chronological order of records, and the GROUP BY clause to split data into groups (here, based on expenditure categories).

Since the interval between data records is one month, by defining HORIZON 3, we ask the model to predict expenditures for the upcoming three months.

At last, we use the USING clause to define the engine as statsforecast. Optionally, we can define the HIERARCHY parameter to support hierarchical reconciliation that may improve prediction accuracy when the data has a hierarchical structure. This option is powered by another Nixtla library that focuses exclusively on this technique, Hierarchical Forecast.

To explore more examples, visit our documentation here.

What’s Next

If you are already familiar with MinsdDB, we encourage you to try its new integration with Nixtla’s StatsForecast ML engine, as it can enhance time series forecasting with its wide range of features.

And if you are new to MindsDB, go ahead and create a demo account to explore MindsDB Cloud. Join our Slack community to ask questions and share feedback.