sklearn.utils.class_weight.compute_class_weight(class_weight, classes, y)
[source]
Estimate class weights for unbalanced datasets.
Parameters: |
class_weight : dict, ‘balanced’ or None If ‘balanced’, class weights will be given by classes : ndarray Array of the classes occurring in the data, as given by y : array-like, shape (n_samples,) Array of original class labels per sample; |
---|---|
Returns: |
class_weight_vect : ndarray, shape (n_classes,) Array with class_weight_vect[i] the weight for i-th class |
The “balanced” heuristic is inspired by Logistic Regression in Rare Events Data, King, Zen, 2001.
© 2007–2017 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.utils.class_weight.compute_class_weight.html