I'm working on a project to create sign language recognition gloves that detect gestures and play corresponding audio outputs. from online tutorials, I have coded a basic decision tree classifier model in python and used my own collected dataset to make predictions, here is that code:
import pandas as pd
data=pd.read_csv('mydata.csv')
X = data.drop(columns=['Word'])
X = X.values
y = data['Word']
from sklearn.tree import DecisionTreeClassifier
model = DecisionTreeClassifier()
model.fit(X,y)
predictions = model.predict([[-3.18,-8.92,-2.27,227,303,254,297,169]]) ##Sensor values from collected dataset
predictions
This code works well and makes predictions accurately. And on the other hand, I followed another tutorial to interface Arduino with Python using PySerial and bring in the live values of the serial monitor into the Python
import time
import serial
arduinoData=serial.Serial('com6',115200)
time.sleep(1)
while True:
while(arduinoData.inWaiting()==0):
pass
dataPacket=arduinoData.readline()
dataPacket=str(dataPacket,'utf-8')
dataPacket=dataPacket.strip('\r\n')
splitPacket=dataPacket.split(",")
X=float(splitPacket[0])
Y=float(splitPacket[1])
Z=float(splitPacket[2])
T=float(splitPacket[3])
I=float(splitPacket[4])
M=float(splitPacket[5])
R=float(splitPacket[6])
P=float(splitPacket[7])
print(X,Y,Z,T,I,M,R,P)
-0.72,-1.33,10.72,234,238,199,332,176
How do I make live predictions from the ML model code mentioned earlier using (X,Y,Z,T,I,M,R,P) values that are received from Python? So when I perform a gesture and if the sensor values match the prediction criteria, then it should print the 'predictions' variable.