The class weights and sample weights are used in the same way, as a factor specific to each sample, in the loss function. In LogisticRegression, it is equivalent to incorporate this factor into a regularization parameter C specific to each sample.
Tom 2017-08-01 18:30 GMT+02:00 Johnson, Jeremiah <jeremiah.john...@unh.edu>: > 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....@python.org on behalf of > stu...@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=hQNTLb4Jonm4n54VBW80WEzIAaqvTO > cTEjhIk > >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.john...@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@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@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= > > _______________________________________________ > scikit-learn mailing list > scikit-learn@python.org > https://mail.python.org/mailman/listinfo/scikit-learn >
_______________________________________________ scikit-learn mailing list scikit-learn@python.org https://mail.python.org/mailman/listinfo/scikit-learn