Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: invalid literal for int() with base 10: 'post1' on Example from Readme #73

Closed
MarcusSchilling opened this issue May 4, 2020 · 2 comments

Comments

@MarcusSchilling
Copy link

MarcusSchilling commented May 4, 2020

Hello,

I tried to run Porter to transform my RandomForestClassifier to JavaScript. I ran into an unexpected "error invalid literal for int() with base 10: 'post1'". Then I thought, let's try the demo from the README of sklearn-porter. The result remained the same. Can anyone tell me if this is a mistake by sklearn-porter or where my real problem might lie?

Error Message

ValueError Traceback (most recent call last)
in
10
11 # Export:
---> 12 porter = Porter(clf, language='java')
13 output = porter.export(embed_data=True)
14 print(output)

/opt/conda/lib/python3.7/site-packages/sklearn_porter/Porter.py in init(self, estimator, language, method, **kwargs)
59 from sklearn import version as sklearn_ver
60 sklearn_ver = str(sklearn_ver).split('.')
---> 61 sklearn_ver = [int(v) for v in sklearn_ver]
62 major, minor = sklearn_ver[0], sklearn_ver[1]
63 patch = sklearn_ver[2] if len(sklearn_ver) >= 3 else 0

/opt/conda/lib/python3.7/site-packages/sklearn_porter/Porter.py in (.0)
59 from sklearn import version as sklearn_ver
60 sklearn_ver = str(sklearn_ver).split('.')
---> 61 sklearn_ver = [int(v) for v in sklearn_ver]
62 major, minor = sklearn_ver[0], sklearn_ver[1]
63 patch = sklearn_ver[2] if len(sklearn_ver) >= 3 else 0

ValueError: invalid literal for int() with base 10: 'post1'

Demo Code

from sklearn.datasets import load_iris
from sklearn.tree import tree
from sklearn_porter import Porter

Load data and train the classifier:

samples = load_iris()
X, y = samples.data, samples.target
clf = tree.DecisionTreeClassifier()
clf.fit(X, y)

Export:

porter = Porter(clf, language='java')
output = porter.export(embed_data=True)
print(output)

@lucasavila00
Copy link

It's a bug in sklearn_porter.
Use another version of scikit_learn for now, 0.22.2.post1 is not compatible.
Use 0.22.2 or 0.22. They all work fine.

@nok
Copy link
Owner

nok commented May 16, 2022

See duplicate #67.

@nok nok closed this as completed May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants