[scikit-learn] question about class_weights in LogisticRegression

Johnson, Jeremiah Jeremiah.Johnson at unh.edu
Tue Aug 1 12:30:22 EDT 2017


Right, I know how the class_weight calculation is performed. But then
those class weights are utilized during the model fit process in some way
in liblinear, and that¹s what I am interested in. libSVM does
class_weight[I] * C (https://www.csie.ntu.edu.tw/~cjlin/libsvm/); is the
implementation in liblinear the same?

Best,
Jeremiah



On 8/1/17, 12:19 PM, "scikit-learn on behalf of Stuart Reynolds"
<scikit-learn-bounces+jeremiah.johnson=unh.edu at python.org on behalf of
stuart at stuartreynolds.net> wrote:

>I hope not. And not accoring to the docs...
>https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_scikit-2Dl
>earn_scikit-2Dlearn_blob_ab93d65_sklearn_linear-5Fmodel_logistic.py-23L947
>&d=DwIGaQ&c=c6MrceVCY5m5A_KAUkrdoA&r=hQNTLb4Jonm4n54VBW80WEzIAaqvTOcTEjhIk
>rRJWXo&m=2XR2z3VWvEaERt4miGabDte3xkz_FwzMKMwnvEOWj8o&s=4uJZS3EaQgysmQlzjt-
>yuLkSlcXTd5G50LkEFMcbZLQ&e=
>
>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://urldefense.proofpoint.com/v2/url?u=https-3A__mail.python.org_mail
>>man_listinfo_scikit-2Dlearn&d=DwIGaQ&c=c6MrceVCY5m5A_KAUkrdoA&r=hQNTLb4Jo
>>nm4n54VBW80WEzIAaqvTOcTEjhIkrRJWXo&m=2XR2z3VWvEaERt4miGabDte3xkz_FwzMKMwn
>>vEOWj8o&s=MgZoI9VOHFh3omGKHTASFx3NAVjj6AY3j_75mnOUg04&e=
>>
>_______________________________________________
>scikit-learn mailing list
>scikit-learn at python.org
>https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.python.org_mailm
>an_listinfo_scikit-2Dlearn&d=DwIGaQ&c=c6MrceVCY5m5A_KAUkrdoA&r=hQNTLb4Jonm
>4n54VBW80WEzIAaqvTOcTEjhIkrRJWXo&m=2XR2z3VWvEaERt4miGabDte3xkz_FwzMKMwnvEO
>Wj8o&s=MgZoI9VOHFh3omGKHTASFx3NAVjj6AY3j_75mnOUg04&e= 



More information about the scikit-learn mailing list