Closed markusheiden closed 2 years ago
Thanks for your feedback, but I can't reproduce your critical issues. Can you install the latest version of release/1.0.0 and test it again please?
pip install https://github.com/nok/sklearn-porter/zipball/release/1.0.0
Here is a basic example:
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn_porter import Estimator
# 1. Load data and train a dummy classifier:
X, y = load_iris(return_X_y=True)
clf = RandomForestClassifier()
clf.fit(X, y)
# 2. Port or transpile an estimator:
est = Estimator(clf, language='java', template='exported')
# output = est.port()
# print(output)
# 3. Validate and compare the predictions:
score = est.test(X)
print(score) # the score should be 1.0
https://github.com/nok/sklearn-porter/tree/release/1.0.0#basics
There are several compile errors when transpiling random forrests to java:
int[] classes = new int[[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]];
should beint[] classes = new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
.for (int i = 1; i < [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]; i++)
should befor (int i = 1; i < classes.length; i++)
.int n_classes = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]; int[] classes = new int[n_classes];
should beint[] classes = new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; int n_classes = classes.length;
Maybe there are other errors too, because the transpiled random forrest does not produce the same result as python.