Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

XOR using Random Forest

The XOR problem stems from the famous Perceptrons (1969) book by Marvin Minsky and Seymour Papert. It can be trivially solved by a decision-tree or decision-tree ensemble. Thus it is a kind of "Hello World" example. Simple and an OK sanity check, but particularly useful.

Install requirements

Make sure to have Python 3.10+ installed.

Make sure to have the Unix port of MicroPython setup. On Windows you can use Windows Subsystem for Linux (WSL), or Docker.

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run training

This will train a RandomForest model using scikit-learn, and output xor_model.csv

python xor_train.py

Running on host

micropython -m mip install https://emlearn.github.io/emlearn-micropython/builds/latest/x64_6.3/emlearn_trees.mpy

micropython xor_run.py

Running on device (Viper IDE)

The fastest and easiest to to install on your device is to use Viper IDE. This will install the library and the example code: Run using ViperIDE

Running on device (manually)

!Make sure you have it running successfully on host first.

This command is for ESP32 (xtensawin). For other hardware, replace the string.

mpremote mip install https://emlearn.github.io/emlearn-micropython/builds/latest/xtensawin_6.3/emlearn_trees.mpy
mpremote cp xor_model.csv :
mpremote run xor_run.py