eloquentarduino / micromlgen

Generate C code for microcontrollers from Python's sklearn classifiers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

suggestion for two bugfixes: adding two needed std libs and fixing gauss function in GNB.

DvanHartevelt opened this issue · comments

Hello, I'm sorry if this isn't the way to do this, I am a bit new to Github.

I found a few bugs, and I fixed them in my own copy of microMLgen. I am still debugging a few others.
it's usefull to include and in the _skeleton.jinja, because e.g. the GNB uses math functions.

second of all, the gauss function is implemented wrong.
image

This worked, but the gauss is now a negative value, and needs to be added to the priors in votes.jinja

Hopefully I've been of some help. Thank you for this library, it helped a lot so far.

I'm in the process of working on a better implementation of the whole library. I don't actually get what's wrong on the gauss function since it's just a matter of sign and it will work if it is used consistently.

Nevertheless, I welcome your contributions.

The sign can go either way. The two other changes are more important tho. The square needs to be taken of the difference between the datapoint and the mean, not (just) the absolute value. And half of the log of varience needs to be aded/subtracted, because in this context varience is the square of standard deviation.

also, adding "#inlcude " and "#include " is needed, because the two of them are needed.

Oh, also the template for SVM is a bit off. The implementation for variable arguments isn't valid. you need to give the number of variable arguments as an argument. When I get home I can show how I fixed it :P

Also, thank you for the answers

fricc. the two standard libraries somehow wont display. they are cmath and cstdint.

Oh, also the template for SVM is a bit off. The implementation for variable arguments isn't valid. you need to give the number of variable arguments as an argument. When I get home I can show how I fixed it :P

I know of this, and I've fixed it in the new version I'm working on.
The includes and this "error" don't actually prevent the code to work correctly (I tested all of them), it probably isn't 100% portable.

The square needs to be taken of the difference between the datapoint and the mean, not (just) the absolute value. And half of the log of varience needs to be aded/subtracted, because in this context varience is the square of standard deviation.

This needs to be fixed if that's the case.