machine learning - Class_weight for SVM classifier in Python -
i have set of parameters choose best ones svm.svc classifier using gridsearchcv:
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)
and error: valueerror: class_weight must dict, 'auto', or none, got: 'balanced'
why have it, if in instructions of svm parameters there 'balanced'
, not 'auto'
?
'balanced'
should working can see in line 51 or 74 https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/utils/class_weight.py
execute sklearn.__version__
check version running.
Comments
Post a Comment