eloquentarduino / micromlgen

Generate C code for microcontrollers from Python's sklearn classifiers
MIT License
188 stars 35 forks source link

One Class SVM just gives the wrong output #15

Open Michel96w opened 2 years ago

Michel96w commented 2 years ago

Hello, I train the One Class SVC in Python and port it to C++ as follows: import micromlgen from micromlgen import port classmap = { -1: 'Fault', 1: 'No fault' } c_code_OCSVM= port(one_class_svm) modelfile= open('OCSVM.h', 'w') modelfile.write(c_code_OCSVM) modelfile.close()

I import the OCSVM as follows to the Arduino IDE, (Board: ESP32)

include "OCSVM.h"

Eloquent::ML::Port::OneClassSVM clf; void setup() { Serial.begin(115200); delay(2000);

float data [2] ={0.45,1.0}; Serial.println(clf.predict(data)); }

The Problem is, that "clf.predict(data)" gives another outout as "prediction = one_class_svm.predict(r)" in python.
Is soemthing missing in my Code?

Shirsaa commented 7 months ago

hi, i am also using micromlgen to convert my RF regression into C++ code. but the generated code gives different and wrong results as compared to the python code i had written. it is giving a single output for every input given to it which in fact is wrong.

Can someone tell me what went wrong?