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

Errors when porting LinearSVC model #18

Closed
FakeNameSE opened this issue Aug 21, 2017 · 9 comments
Closed

Errors when porting LinearSVC model #18

FakeNameSE opened this issue Aug 21, 2017 · 9 comments
Labels

Comments

@FakeNameSE
Copy link

Sorry to bother you again, but when attempting to run:
python3 -m sklearn_porter -i model_notokenizer.pkl -l java I get:

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.5/dist-packages/sklearn_porter/__main__.py", line 71, in <module>
    main()
  File "/usr/local/lib/python3.5/dist-packages/sklearn_porter/__main__.py", line 49, in main
    porter = Porter(model, language=language)
  File "/usr/local/lib/python3.5/dist-packages/sklearn_porter/Porter.py", line 65, in __init__
    raise ValueError(error)
ValueError: The given model 'Pipeline(memory=None,
     steps=[('vect', TfidfVectorizer(analyzer='word', binary=False, decode_error='strict',
        dtype=<class 'numpy.int64'>, encoding='utf-8', input='content',
        lowercase=True, max_df=0.5, max_features=None, min_df=0.001,
        ngram_range=(1, 1), norm='l2', preprocessor=None, smooth_idf=True...ax_iter=1000,
     multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,
     verbose=0))])' isn't supported.

I'm running python 3.5.2, numpy 1.13.1, and sklearn 0.19.0.

@nok
Copy link
Owner

nok commented Aug 22, 2017

Hello @FakeNameSE,

no problem! I'm happy about each serious issue and hint. It seems that I have to add support for the new pipeline feature of scikit-learn 0.19. I will fix it.

Happy coding,
Darius

@nok nok added the bug label Aug 25, 2017
@nok
Copy link
Owner

nok commented Aug 26, 2017

Hello @FakeNameSE,

I pushed the fix b444da7 to pypi. Now you can reinstall the package with:

pip install --no-cache-dir --force-reinstall --ignore-installed sklearn-porter

Again thanks for your attention and help.

Happy coding,
Darius

@FakeNameSE
Copy link
Author

Unfortunately, I still seem to be getting the error.

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.5/dist-packages/sklearn_porter/__main__.py", line 71, in <module>
    main()
  File "/usr/local/lib/python3.5/dist-packages/sklearn_porter/__main__.py", line 49, in main
    porter = Porter(model, language=language)
  File "/usr/local/lib/python3.5/dist-packages/sklearn_porter/Porter.py", line 77, in __init__
    raise ValueError(error)
ValueError: The given model 'Pipeline(memory=None,
     steps=[('vect', TfidfVectorizer(analyzer='word', binary=False, decode_error='strict',
        dtype=<class 'numpy.int64'>, encoding='utf-8', input='content',
        lowercase=True, max_df=0.5, max_features=None, min_df=0.001,
        ngram_range=(1, 1), norm='l2', preprocessor=None, smooth_idf=True...ax_iter=1000,
     multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,
     verbose=0))])' isn't supported.

@nok
Copy link
Owner

nok commented Aug 29, 2017

How did you create the estimator and fit the model? Can you share your code?

In addition can you please execute the following snippet on the estimator before you dump the model as a pickle file:

algorithm_name = str(type(your_classifier).__name__)
print(algorithm_name)

@Phyks
Copy link

Phyks commented Sep 27, 2017

Hi,

I seem to be having the same issue.

> algorithm_name = str(type(classifier).__name__)
Pipeline

My code is available at https:/Phyks/OFFClassification/blob/master/notebook.ipynb. In particular,

classifier = Pipeline([
    ('vectorizer', CountVectorizer()),
    ('tfidf', TfidfTransformer()),
    ('clf', OneVsRestClassifier(LinearSVC()))
])

classifier.fit(X_train, Y_train_transformed)

Thanks!

@nok
Copy link
Owner

nok commented Sep 29, 2017

Thanks @Phyks, the fix (#b92edff) is pushed to the master (dev) branch:

pip uninstall -y sklearn-porter
pip install --no-cache-dir https:/nok/sklearn-porter/zipball/master

Happy coding,
Darius

@Phyks
Copy link

Phyks commented Oct 2, 2017

Indeed, it fixed it (partially). I am now getting

ValueError: Currently the given model 'OneVsRestClassifier(estimator=LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True,
     intercept_scaling=1, loss='squared_hinge', max_iter=1000,
     multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,
     verbose=0),
          n_jobs=1)' isn't supported.

which makes sense since it seems OneVsRestClassifier is not yet available. Are there any plans to support it? Would be awesome :)

@nok
Copy link
Owner

nok commented Oct 5, 2017

Thanks! Step by step ... the neverending story 😄 .

Yes, the support of the OneVsRestClassifier would be awesome! For that I created a new issue (#19). This one will be closed right after my posting.

Thank you all for your feedback and help,
Darius

@nok nok closed this as completed Oct 5, 2017
@Phyks
Copy link

Phyks commented Oct 5, 2017

Awesome! I'm following the other issue for updates on this then. Thanks a lot for this lib!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants