AI Table
or a predictor
. By querying the model, we’ll produce
categorical forecasts for a multivariate time series.
Make sure you have access to a working MindsDB installation, either locally or
at MindsDB Cloud.
If you want to learn how to set up your account at MindsDB Cloud, follow
this guide. Another way is to set up
MindsDB locally using
Docker or
Python.
Let’s get started.
example_db.demo_data.eeg_eye
table).
ARFF
format that should be converted to the CSV
format before uploading it via MindsDB SQL Editor.
Follow this guide to find out how to upload a file to MindsDB.
Now you can run queries directly on the file as if it were a table. Let’s preview the data that we’ll use to train our predictor.
files.eeg_eye
file
as a table. Make sure you replace it with example_db.demo_data.eeg_eye
if
you connect the data as a database.0
indicates open eye and 1
indicates closed eye. We want to know ahead
of time when the eye state will change, so we predict the eyeDetection
column.
Below is the sample data stored in the files.eeg_eye
table.
Column | Description | Data Type | Usage |
---|---|---|---|
AF3 ,F7 ,F3 ,FC5 ,T7 ,P7 ,O1 ,O2 ,P8 ,T8 ,FC6 ,F4 ,F8 ,AF4 | The EEG measurement data. | float | Feature |
eyeDetectin | The state of the patient’s eye where 0 indicates open eye and 1 indicates closed eye. | binary | Label |
CREATE MODEL
statement and specify the
input columns used to train FROM
(features) and what we want to
PREDICT
(labels).
The eyeDetection
column is our target variable. The interesting thing about
this example is that we aim to forecast labels that are not strictly
numerical. Even though this example is simple (because the variable is a binary
category), this can easily be generalized to more than two categories.
We order the measurements by the Timestamps
column that shows readings
frequency of approximately 8 milliseconds.
(50 * 8) = 400 [ms]
) to predict the following 80 ms
((10 * 8) = 80 [ms]
).
complete
, we can start making
predictions!
SELECT
statement lets you make predictions for the
label based on the chosen features for a given time period. Usually, you want to
know what happens right after the latest training data point that was fed. We
have a special keyword for that, the LATEST
keyword.
Let’s run a query to get predictions for the next HORIZON
timesteps into
the future, which in this case is roughly 80 milliseconds.
JOIN
any set of WINDOW
rows worth of
measurements with this predictor, and forecasts will be emitted to help us
expect a change in the state of the patient’s eye based on the EEG readings.
eye is open
to 0
and eye is closed
to 1
would be enough to replicate the above behavior.
We could also explore other options. With some data transformations on the data
layer, we could get a countdown to the next change in state, effectively
predicting a date if we cast this back into the timestamp domain.