7.7.1. Generic Time Series Classification
This example serves as a “Hello World” introduction to time series classification using the TinyML ModelMaker toolchain. It demonstrates how to use any generic time series classification task with our toolchain.
7.7.1.1. Overview
Task: Time series classification (3 classes)
Dataset: Synthetic waveforms (sine, square, sawtooth)
Model: CLS_1k_NPU (~1,000 parameters)
Target: F28P55 (NPU device)
Training time: ~2-5 minutes on CPU
7.7.1.2. Running the Example
cd tinyml-modelzoo
./run_tinyml_modelzoo.sh examples/generic_timeseries_classification/config.yaml
cd tinyml-modelzoo
run_tinyml_modelzoo.bat examples\generic_timeseries_classification\config.yaml
7.7.1.3. Understanding the Dataset
The dataset contains three classes of synthetic waveforms:
Sine wave - Smooth sinusoidal pattern
Square wave - Alternating high/low values
Sawtooth wave - Linear ramp pattern
Each waveform is a 1D time series with 1024 samples.
7.7.1.4. Dataset Format
For classification tasks, ModelMaker expects the dataset in this structure:
{dataset_name}.zip/
|
|-- classes/
|-- class_1/
| |-- file1.csv
| |-- file2.csv
|
|-- class_2/
| |-- file1.csv
| |-- file2.csv
|
|-- class_N/
|-- ...
Note
For classification tasks, the folder names under classes/ become the
class labels. No separate annotation files are required.
7.7.1.5. Configuration
common section:
common:
task_type: generic_timeseries_classification
target_device: F28P55
dataset section:
dataset:
dataset_name: generic_timeseries_classification
data_processing_feature_extraction section:
data_processing_feature_extraction:
feature_extraction_name: Generic_1024Input_FFTBIN_64Feature_8Frame
variables: 1
training section:
training:
model_name: CLS_1k_NPU
batch_size: 256
training_epochs: 20
num_gpus: 0
testing: {}
compilation: {}
7.7.1.6. Feature Extraction
The Generic_1024Input_FFTBIN_64Feature_8Frame preset:
Applies 1024-point FFT to convert to frequency domain
Bins the FFT output into 64 frequency features
Concatenates 8 frames for temporal context
Total input to model: 64 x 8 = 512 features
7.7.1.7. Evaluation Metrics
Accuracy
Percentage of correctly classified samples.
Range: 0% to 100%
Ideal value: 100% (higher is better)
F1-Score
Harmonic mean of precision and recall.
Range: 0 to 1
Ideal value: 1 (higher is better)
7.7.1.8. Expected Results
Float32 Model:
Accuracy: 98-100%
F1-Score: ~1.0
Quantized Model:
Accuracy: 95-100%
7.7.1.9. Output Location
Results are saved to:
../tinyml-modelmaker/data/projects/generic_timeseries_classification/run/<timestamp>/CLS_1k_NPU/
Key files:
training/base/best_model.pt- Trained modeltraining/quantization/best_model.onnx- Quantized ONNXcompilation/artifacts/mod.a- Compiled for device
7.7.1.10. Variations to Try
Different Feature Extraction
Try raw time domain instead of FFT:
data_processing_feature_extraction:
feature_extraction_name: Generic_512Input_RAW_512Feature_1Frame
Different Model Size
Try a smaller or larger model:
training:
model_name: CLS_100_NPU # Smaller
# or
model_name: CLS_4k_NPU # Larger
Different Target Device
Compile for a different device:
common:
target_device: MSPM0G3507
7.7.1.11. Next Steps
After successfully running this generic example:
Try Arc Fault Detection - Real-world arc fault detection
Explore Classification Dataset Format - Use your own classification data
Read Understanding Config - Learn all config options