Nixtla's TimeGPT Integration with MindsDB
TimeGPT by Nixtla is a generative pre-trained model specifically designed for predicting time series data. TimeGPT takes time series data as input and produces forecasted outputs. TimeGPT can be effectively employed in various applications, including demand forecasting, anomaly detection, financial prediction, and more.
You can learn more about its features here.
How to bring TimeGPT Models to MindsDB
Before creating a model, you will need to create an ML engine for TimeGPT using the CREATE ML_ENGINE
statement and providing the TimeGPT API key:
Once the ML engine is created, we use the CREATE MODEL
statement to create the TimeGPT model in MindsDB.
To ensure that the model is created based on the TimeGPT engine, include the USING
clause at the end, which defines the engine
and lists all parameters used with time-series models, including OREDER BY
, GROUP BY
, HORIZON
.
What’s different about the TimeGPT engine is that it does not expose the WINDOW
parameter in its API, so as a user you need to send a payload with at least N rows, where N depends on the model and the frequency of the series. This is automatically handled by MindsDB in the TimeGPT handler code.
Example
Nixtla’s TimeGPT model can be used to obtain real-time forecasts of the trading data from Binance.
Follow this link to watch a video on integrating TimeGPT model with Binance data.
First, connect to Binance from MindsDB executing this command:
Please note that before using the TimeGPT engine, you should create it from the MindsDB editor, or other clients through which you interact with MindsDB, with the below command:
You can check the available engines with this command:
If you see the TimeGPT engine on the list, you are ready to follow the tutorials.
Now let’s create a TimeGPT model and train it with data from Binance.
Use the CREATE MODEL
statement to create, train, and deploy a model. The FROM
clause defines the training data used to train the model - here, the latest Binance data is used. The PREDICT
clause specifies the column to be predicted - here, the open price of the BTC/USDT trading pair is to be forecasted.
As it is a time-series model, you should order the data by a date column - here, it is the open time when the open price takes effect. Finally, the HORIZON
clause defines how many rows into the future the model will forecast - here, it forecasts the next 10 rows (the next 10 minutes, as the interval between Binance data rows is one minute).
Please note that the TimeGPT engine is sensitive to inconsistent intervals between data rows. Please check your data for missing, duplicated or irregular timestamps to mitigate errors that may arise if the intervals between data rows are inconsistent.
In this example, the intervals between Binance data rows are consistently equal to one minute.
Before proceeding, make sure that the model status reads complete
.
To make forecasts, you must save the Binance data into a view:
This view is going to be joined with the model to get forecasts: