[scikit-learn] question about class_weights in LogisticRegression

Stuart Reynolds stuart at stuartreynolds.net
Tue Aug 1 12:19:54 EDT 2017

I hope not. And not accoring to the docs...

class_weight : dict or 'balanced', optional
Weights associated with classes in the form ``{class_label: weight}``.
If not given, all classes are supposed to have weight one.
The "balanced" mode uses the values of y to automatically adjust
weights inversely proportional to class frequencies in the input data
as ``n_samples / (n_classes * np.bincount(y))``.
Note that these weights will be multiplied with sample_weight (passed
through the fit method) if sample_weight is specified.

On Tue, Aug 1, 2017 at 9:03 AM, Johnson, Jeremiah
<Jeremiah.Johnson at unh.edu> wrote:
> Hello all,
> I’m looking for confirmation on an implementation detail that is somewhere
> in liblinear, but I haven’t found documentation for yet. When the
> class_weights=‘balanced’ parameter is set in LogisticRegression, then the
> regularisation parameter for an observation from class I is class_weight[I]
> * C, where C is the usual regularization parameter – is this correct?
> Thanks,
> Jeremiah
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn

More information about the scikit-learn mailing list