Simply put, I have an imbalanced data set and I have to train using partial_fit
because of the size. Some of the methods I use can't naturally handle multiclass problems, so I am wrapping them with a OneVsRestClassifier
. However, this causes problems adjusting the class_weights
.
Because I use partial_fit
the option of setting class_weight='balanced'
or 'auto'
is not possible.
Is there a simple solution where I can use OneVsRestClassifier
and still weight my classes?
Example code:
model = OneVsRestClassifier(SGDClassifier(loss='log', alpha=1e-4, penalty='elasticnet', class_weight=weights))
model.partial_fit(features, labels_i, classes=np.unique(labels_i))
where weights
is a dictionary containing the weights for each class.