Before we can use the JS SDK, we must install it by running the following command:
Another way is to clone the JS SDK repository and install all dependencies manually.
Once installation of the package succeeds, the next step is to connect MindsDB. You can connect either your local installation or your MindsDB Cloud account, as below.
Please visit our documentation for details.
Let’s go over an example of creating and training a time series model, and then, using it to make batch predictions.
First, we need to define the training options, including training data, columns used to order and group data, the window clause defining how many rows to look back at, and the horizon clause defining how many data records to forecast.
We use the trainModel function to create and train a model. Its first argument is the model name. The second argument stores a column to be predicted. And in the third argument, we pass all training options defined above.
It may take some time to train the model. Here is how to check the model status until it finishes the training phase.
You can also describe a model. It is equivalent to using the DESCRIBE statement.
Now that the model is ready, we can make predictions. In the case of time series models, we make batch predictions by joining the data table with the model, where the data table serves as input data for the model.
We use the batchQuery function to query for batch predictions.
Visit our documentation to learn more about all functions available in the JS SDK.