I'm trying to use class weights in a Scikit learn SVM classifier using RandomizedSearchCV
.
clf= svm.SVC(probability=True, random_state=0)
parameters = {'clf__C': scipy.stats.expon(scale=100), 'clf__gamma': scipy.stats.expon(scale=.1),
'clf__kernel': ['rbf'], 'clf__class_weight':['balanced', None]}
search=RandomizedSearchCV(estimator=clf, param_distributions=parameters, scoring='f1_micro',
cv=5, n_iter=100, random_state=0)
search.fit(features,labels)
I have 4 classes. Now for the class_weight I would like to have random values between 0 and 1 for each of the four classes. It could be done with
'class_weight':[{0: w} for w in [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]]
But this is only for one class and the values are discrete and not just sampled between 0 and 1.
How can I solve this?
Last but not least, does it matter if I'm using values between 0 and 1 or between 1 and 10 (i.e. are the weights rescaled)?
And should the weights of all 4 classes sum up always to the same value (e.g. 1)?