7.7.2. Generic Time Series Regression

This example serves as a “Hello World” introduction to time series regression using the TinyML ModelMaker toolchain. It demonstrates how to use any generic time series regression task with our toolchain.

7.7.2.1. Overview

  • Task: Time series regression (continuous value prediction)

  • Dataset: Synthetic data (y = 1.2 sin(x) + 3.2 cos(x))

  • Model: REGR_1k (~1,000 parameters)

  • Target: F28P55 (NPU device)

7.7.2.2. Running the Example

cd tinyml-modelzoo
./run_tinyml_modelzoo.sh examples/generic_timseries_regression/config.yaml

7.7.2.3. Understanding the Dataset

The dataset consists of synthetically generated data:

Column

Description

x

Randomly generated in range [0, 3]

y

Target: y = 1.2 sin(x) + 3.2 cos(x)

Dataset split:

  • Training: 7 files

  • Validation: 2 files

  • Test: 1 file

Each file contains 5000 datapoints.

7.7.2.4. Dataset Format

For regression tasks, ModelMaker expects the dataset in this structure:

{dataset_name}.zip/
|
|-- files/
|     |-- {file1}.csv
|     |-- {file2}.csv
|     |-- {fileN}.csv
|
|-- annotations/
      |-- file_list.txt
      |-- instances_train_list.txt
      |-- instances_val_list.txt
      |-- instances_test_list.txt

Note

Unlike classification tasks, regression always requires annotation files to specify train/validation/test splits.

7.7.2.5. Configuration

common section:

common:
  task_type: generic_timeseries_regression
  target_device: F28P55

dataset section:

dataset:
  dataset_name: generic_timeseries_regression
  input_data_path: https://software-dl.ti.com/C2000/esd/mcu_ai/01_03_00/datasets/generic_timeseries_regression.zip

data_processing_feature_extraction section:

data_processing_feature_extraction:
  data_proc_transforms:
    - SimpleWindow
  frame_size: 10
  stride_size: 1
  variables: 1

training section:

training:
  optimizer: adam
  lr_scheduler: cosineannealinglr
  model_name: REGR_1k
  batch_size: 128
  training_epochs: 100
  lambda_reg: 0.01
  num_gpus: 1
  quantization: 0

7.7.2.6. Evaluation Metrics

RMSE (Root Mean Square Error)

Measures the mean of the square root of the sum of squares of errors.

  • Range: 0 to infinity

  • Ideal value: 0 (lower is better)

R2 Score (Coefficient of Determination)

Indicates how well predictions match actual values.

  • Range: (-infinity, 1]

  • Ideal value: 1 (higher is better)

7.7.2.7. Expected Results

Metric

Value

RMSE

0.13

R2 Score

0.99

7.7.2.8. Output Location

Results are saved to:

../tinyml-modelmaker/data/projects/{dataset_name}/run/{date-time}/{model_name}/

Key files:

  • training/base/best_model.pt - Trained model

  • training/base/post_training_analysis/ - Prediction plots

  • compilation/artifacts/mod.a - Compiled for device

7.7.2.9. Next Steps

After successfully running this generic example:

  1. Try Torque Measurement Regression - Real-world motor torque prediction

  2. Explore Regression Dataset Format - Use your own regression data

  3. Read Understanding Config - Learn all config options