nok / sklearn-porter

Transpile trained scikit-learn estimators to C, Java, JavaScript and others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't use port or save functions

GMSL1706 opened this issue · comments

Here are my versions :
The scikit-learn 0.21.3
Python 3.7.13

And here is my code. I used the same example as in the notebook.

# 1. Load data and train a dummy classifier:
X, y = load_iris(return_X_y=True)
clf = tree.DecisionTreeClassifier()
clf.fit(X, y)

I tried this code:

# 2. Port or transpile an estimator:
est = Estimator(clf, language='java', template='combined')
output = est.port()
print(output)

This is my error:

---------------------------------------------------------------------------
TemplateNotFound                          Traceback (most recent call last)
[<ipython-input-38-6d9e6b3013b2>](https://localhost:8080/#) in <module>()
      1 # 2. Port or transpile an estimator:
      2 est = Estimator(clf, language='java', template='combined')
----> 3 output = est.port()
      4 print(output)

5 frames
[/usr/local/lib/python3.7/dist-packages/jinja2/loaders.py](https://localhost:8080/#) in get_source(self, environment, template)
    305             source = self.mapping[template]
    306             return source, None, lambda: source == self.mapping.get(template)
--> 307         raise TemplateNotFound(template)
    308 
    309     def list_templates(self):

TemplateNotFound: combined.class

Can someone help me ?

Hello @GMSL1706 ,

which version of sklearn-porter did you install?

The notebook uses the latest state on the main branch which isn't released yet. So, can you please upgrade the package?

pip install https://github.com/nok/sklearn-porter/zipball/main

Kind regards,
Darius

Hi Darius,

I used this code pip install https://github.com/nok/sklearn-porter/zipball/main to install sklearn-porter but it looks like it was not installed correctly. See below (I used google colab):

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
yellowbrick 1.4 requires scikit-learn>=1.0.0, but you have scikit-learn 0.21.3 which is incompatible.
imbalanced-learn 0.8.1 requires scikit-learn>=0.24, but you have scikit-learn 0.21.3 which is incompatible.
Successfully installed loguru-0.6.0 scikit-learn-0.21.3 sklearn-porter-1.0.0

Help!

Seems that I have the same issue with version 1.0.0 and sklearn version 0.21.0. Did you find any solution ?