nok / sklearn-porter

Transpile trained scikit-learn estimators to C, Java, JavaScript and others.
BSD 3-Clause "New" or "Revised" License
1.28k stars 170 forks source link

Divergence Between Original Model and Ported Model #57

Closed JinLi711 closed 5 years ago

JinLi711 commented 5 years ago

I've noticed that the integrity score of the JavaScript ported model for extraTrees is around .86 (after sampling a few thousand random inputs). What would be some possible reasons for the cause of such a large this divergence? The extraTrees have 3 estimators with depth 2.

nok commented 5 years ago

Hello @JinLi711,

the algorithm of the prediction and the floating-point precision have an effect.

The accuracy of the prediction will be improved with the next release. The good news is that it's already implemented and commited. But I'm sorry to say that the next release requires more time than I expected. Nevertheless you can copy and paste the relevant parts from the templates directly: RandomForestClassifier/templates/js/exported.class.jinja2

Don't be confused about the name. The prediction of a RandomForestClassifier and an ExtraTreesClassifier are equal.

Regards, Darius