Class_weight for SVM classifier in Python
<p>I have a set of parameters to choose the best ones for svm.SVC classifier using GridSearchCV:</p>

<pre><code>X=dataset.ix[:, dataset.columns != 'class']
Y=dataset['class']
X_train, X_test, Y_train, Y_test = cross_validation.train_test_split(X, Y, test_size=0.5)

clf=svm.SVC()
params=
        {'kernel':['linear', 'rbf', 'poly', 'sigmoid'],
         'C':[1, 5, 10],
         'degree':[2,3],
         'gamma':[0.025, 1.0, 1.25, 1.5, 1.75, 2.0],
         'coef0':[2, 5, 9],
         'class_weight': [{1:10}, 'balanced']}

searcher = GridSearchCV(clf, params, cv=9, n_jobs=-1, scoring=f1)
searcher.fit(X_train, Y_train)
</code></pre>

<p>And i get the error: <code>ValueError: class_weight must be dict, 'auto', or None, got: 'balanced'</code>
Why do I have it, if in instructions of svm parameters there is <code>'balanced'</code>, not <code>'auto'</code> ?</p>

<p><code>'balanced'</code> should be working as you can see in line 51 or 74 <a href="http://sklearn%20utils%20github" rel="nofollow">https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/class_weight.py</a></p>

<p>Execute <code>sklearn.__version__</code> to check what version you are running.</p>

python machine-learning scikit-learn svm