Preparing data for model training is mostly out of the scope of the AI SDK. Prepared example datasets are available for the end-to-end tutorials. You can try out these tutorials without requiring data acquisition. Each end-to-end tutorial includes a notebook to guide you through downloading a sample dataset.
Processing time series data
The State Identifier end-to-end tutorial provides basic building blocks for building ML models that process time series of aligned signals. Aligned signals mean that the input of the processing pipeline consists of rows, containing a value for each signal. For example, a row consisting of 3 signals and a time stamp would look like this:
| Time stamp | var1 | var2 | var |
|---|---|---|---|
| 09:50:23 | 1.2 | 202 | 25 |
The building blocks help you create a time series pipeline that processes a stream of such rows according to the following pattern:
The roles of the piping elements are as follows:
"Windowing" accumulates a given number of input rows in a processing window.
The "feature extractor" calculates several characteristics for each window. A feature is a mathematical value calculated from the values in the window.
The "classifier" is the actual machine learning model that predicts a class for each window based on the extracted characteristics.
Most pipelines contain other processing elements, such as imputers to fill missing values, or scalers that map an input to a predefined range.
To train the classifier in such a pipeline, the input data must undergo the preprocessing steps during the training process.
Therefore, this processing pipeline must be defined as a part of data preparation before training. This is where the building blocks in the State Identifier end-to-end tutorial play a crucial role.
These building blocks are based on the widely used machine learning Python package scikit-learn. Scikit-learn provides a framework for defining pipelines that allows you to combine data transformers with classifiers or other kinds of estimators. The building blocks
can be found in the src/pipeline.py file in the State Identifier end-to-end tutorial. The commonly used libraries are:
WindowTransformer, which transforms a series of input rows into a series of row-based windowsFeatureTransformer, which transforms a window of rows into the feature values according to user-defined functions
In addition to these transformers, there is a transformer called FillMissingValues, which performs input data correction for simple cases. For more advanced cases, you should use a more sophisticated imputer to correct your input.
For more details and concrete examples, refer to the training notebooks in the State Identifier end-to-end tutorial.
Mapping predicted classes of data windows to data points
As described in the previous chapter, time series data is typically classified on a window-by-window basis. This means that the class of a single data row is not defined on its own. Nevertheless, there are cases where it is convenient to map the classes defined window by window to the data points themselves. For example, if you want to visualize the data points according to their classification by color-coding the data points with the class.
The State Identifier end-to-end tutorial provides the utility function back_propagate_labels in the file src/pipeline.py to perform this mapping. For more details and concrete examples, please refer to the training notebooks in the State Identifier end-to-end tutorial.