-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
SVC predict_proba fails with new-style kernel strings (expected str, got newstr) #10374
Copy link
Copy link
Closed
Labels
BugEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolvehelp wanted
Description
Description
If an SVC is initialized with a new-style kernel string (future.types.newstr.newstr), calls to SVC.predict_proba() will fail with the error
TypeError: Argument 'kernel' has incorrect type (expected str, got newstr)
Calls to fit, predict, and score work correctly.
The culprit is the inner call to svm.libsvm.predict_proba().
Steps/Code to Reproduce
In a new virtual environment, using python 2.7:
pip install future scikit-learn numpy scipy
Run:
from builtins import str
from sklearn.svm import SVC
from sklearn.datasets import load_iris
X, y = load_iris(True)
svm = SVC(kernel=str('sigmoid'), probability=True) # it doesn't matter which kernel is chosen
svm.fit(X, y)
svm.predict_proba(X)Expected Results
No error is thrown, and the call returns a proba array.
Actual Results
Traceback (most recent call last):
File "error.py", line 8, in <module>
svm.predict_proba(X)
File "/home/bcyphers/scratch/venv/local/lib/python2.7/site-packages/sklearn/svm/base.py", line 600, ina
return pred_proba(X)
File "/home/bcyphers/scratch/venv/local/lib/python2.7/site-packages/sklearn/svm/base.py", line 648, ina
cache_size=self.cache_size, coef0=self.coef0, gamma=self._gamma)
TypeError: Argument 'kernel' has incorrect type (expected str, got newstr)
Versions
Linux-4.4.0-104-generic-x86_64-with-Ubuntu-16.04-xenial
('Python', '2.7.12 (default, Nov 20 2017, 18:23:56) \n[GCC 5.4.0 20160609]')
('NumPy', '1.13.3')
('SciPy', '1.0.0')
('Scikit-Learn', '0.19.1')
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolvehelp wanted