Skip to content

salernosimone/tinyml4all-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python library for the book TinyML Quickstart. Contains code and examples.

Installation

pip install tinyml4all

Usage

For a complete list of the examples, refer to the book. Here's one that classifies a tabular dataset and exports a C++ header file for Arduino:

from tinyml4all.tabular.classification import Table, Chain
from tinyml4all.tabular.features import Scale
from tinyml4all.tabular.classification.models import RandomForest


table = Table.read_csv("sample_data/fruits.csv").set_targets(column="fruit")

# print a description of the parameters you can set
# on the given classifier
print(help(RandomForest))

# train classifier and make predictions
rf = RandomForest(n_estimators=20)
table2 = rf(table)

# table.full() prints the data + true labels + predicted labels
print(table2.full())
print(table2.classification_report())

# create a chain of preprocessing and classification
chain = Chain(Scale(), RandomForest(n_estimators=20))
table2 = chain(table)
print(table2.classification_report())

# export for Arduino
chain.convert_to("c++", class_name="FruitChain", save_to="sample_data/FruitChain.h")

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published