19
Is it possible to perform a GridSearchCV (to get the best SVM's C) and yet specify the sample_weight with scikit-learn?
Here's my code and the error I'm confronted to:
gs = GridSearchCV(
svm.SVC(C=1),
[{
'kernel': ['linear'],
'C': [.1, 1, 10],
'probability': [True],
'sample_weight': sw_train,
}]
)
gs.fit(Xtrain, ytrain)
>> ValueError: Invalid parameter sample_weight for estimator SVC
Edit: I solved the issue by getting the latest scikit-learn version and using the following:
gs.fit(Xtrain, ytrain, fit_params={'sample_weight': sw_train})