1
$\begingroup$

I tried creating a SVM Classifier, as:

# Create a SVM Classifier
model = SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,
            decision_function_shape=None, degree=3, gamma='auto', kernel='linear',
            max_iter=-1, probability=True, random_state=None, shrinking=True,
            tol=0.001, verbose=False
            )

(Using Python 2.7)

But getting this error--

TypeError: init() got an unexpected keyword argument 'decision_function_shape'

Any thoughts on that? How to sort it out?

Update >>

My sklearn version is 0.16.1. I tried to install the update but it's kept on saying- No matching distribution found for the upgrade.

$\endgroup$

1 Answer 1

1
$\begingroup$

Your snippet is almost exactly the same as scikit-learn's example (except for kernel='rbf' and probability=False) and works fine under version 0.18, provided the needed imports are present.

Update: the version of scikit learn used is 0.16.1, and in that version, SVC did not have as many arguments as in 0.18, as per the docs. You should therefore use something like this:

model = SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3,
            gamma=0.0, kernel='linear', max_iter=-1, probability=True,
            random_state=None, shrinking=True, tol=0.001, verbose=False)

For upgrading scikit-learn to 0.18, (assuming you use pip) do this:

pip install scikit-learn==0.18 --force-reinstall
$\endgroup$
3
  • $\begingroup$ It's because that's the basic structure of the classifier but the parameters can be changed as per the requirement. I used probability=False because if I'll enable it then it will slow down the method and then whole functioning, plus kernel='rbf' because I wanted to use this type of kernel for my algorithm. Now coming to the error, I tried using multiple parameters still the error is same. Any thoughts on that, why am getting this? That will be very useful. Cheers! :) $\endgroup$
    – Abhishek
    Commented Oct 27, 2016 at 11:16
  • $\begingroup$ As I said, you snippet works just fine with python 2.7 and sklearn 0.18, I tested it myself before answering. This means that the error is not in those lines, but elsewhere, e.g. lack of imports, wrong version of sklearn. Please, provide more information on your test in order for the problem to be identifiable. $\endgroup$
    – noe
    Commented Oct 27, 2016 at 12:43
  • $\begingroup$ Okay great, kindly check the update in the post. $\endgroup$
    – Abhishek
    Commented Oct 27, 2016 at 12:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.