1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/pkg/emlearn
Marian Buschsieweke 59738ba32d
tests/pkg/emlearn: drop model.h from builddep
Now that model.h is in the repo, it no longer is a build dependency.
This allows compilation of the test without having emlearn installed,
which is useful e.g. for build testing.
2024-10-14 11:20:41 +02:00
..
tests tests: move pkg_ application to tests/pkg subdirectory 2023-05-06 07:55:01 +02:00
.gitignore tests/pkg/emlearn: add model.h to repo 2024-09-28 18:29:56 +02:00
digit tests: move pkg_ application to tests/pkg subdirectory 2023-05-06 07:55:01 +02:00
generate_digit.py tests: move pkg_ application to tests/pkg subdirectory 2023-05-06 07:55:01 +02:00
generate_model.py tests: move pkg_ application to tests/pkg subdirectory 2023-05-06 07:55:01 +02:00
main.c tests: move pkg_ application to tests/pkg subdirectory 2023-05-06 07:55:01 +02:00
Makefile tests/pkg/emlearn: drop model.h from builddep 2024-10-14 11:20:41 +02:00
Makefile.ci examples,tests: Bump Makefile.ci for MSP430 boards 2024-05-07 07:57:41 +02:00
model tests/pkg/emlearn: update generated model 2024-08-29 10:01:42 +02:00
model.h tests/pkg/emlearn: add model.h to repo 2024-09-28 18:29:56 +02:00
README.md tests: move pkg_ application to tests/pkg subdirectory 2023-05-06 07:55:01 +02:00
train_model.py tests: move pkg_ application to tests/pkg subdirectory 2023-05-06 07:55:01 +02:00

Emlearn package test application

This application shows how to use a machine learning model with emlearn on RIOT in order to predict a value from a hand written digit image. The model is a Scikit-Learn random forest estimator trained on the MNIST dataset.

Expected output

The default digit to predict is a hand-written '6', so the application output is the following:

Predicted digit: 6

Use the Python scripts

The application comes with 3 Python scripts:

  • generate_digit.py is used to generate a new digit file. This file is embedded in the firmware image and is used as input for the inference engine. Use the -i option to select a different digit. For example, the following command:
    $ ./generate_digit.py -i 1
    
    will generate a digit containing a '9'. The digit is displayed at the end of the script so one knows which digit is stored. Note that each time a new digit is generated, the firmware image must be rebuilt to include this new digit.
  • train_model.py is used to train a new Scikit-Learn Random Forest estimator. The trained model is stored in the model binary file.
    $ ./train_model.py
    
    will just train the model.
  • generate_model.py is used to generate the sonar.h header file from the model binary file. The script is called automatically by the build system when the model binary file is updated.