How can I use the machine learning library MicroML to perform simple inference on an ESP32?
Hello guys, how can I use the machine learning library MicroML to perform simple inference on an ESP32? My goal is to predict a simple numerical outcome based on a set of sensor readings, I was able to generate the c code prediction but unsure on what step to take next can anyone help me
from sklearn.linear_model import LinearRegressionimport numpy as npfrom micromlgen import port# Example dataX = np.array([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]])y = np.array([10, 20, 30, 40])# Train the modelmodel = LinearRegression().fit(X, y)# Generate C code for the modelc_code = port(model)print(c_code)
from sklearn.linear_model import LinearRegressionimport numpy as npfrom micromlgen import port# Example dataX = np.array([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]])y = np.array([10, 20, 30, 40])# Train the modelmodel = LinearRegression().fit(X, y)# Generate C code for the modelc_code = port(model)print(c_code)
@Middleware & OS @Helper
Solution
Hello @Enthernet Code , after Creating a c code of the model and include it into your ESP32 project as model.h. In your Arduino sketch, read from sensors, then call the function for prediction from the generated code, This project tutorial will guide you https://dev.to/tkeyo/tinyml-machine-learning-on-esp32-with-micropython-38a6