[scikit-learn] sample_weight vs class_weight

Sole Galli solegalli at protonmail.com
Fri Dec 4 05:40:44 EST 2020

Actually, I found the answer. Both seem to be optimising the loss function for the various algorithms, below I include some links.

If, we pass class_weight and sample_weight, then the final cost / weight is a combination of both.

I have a follow up question: in which scenario would we use both? why do some estimators allow to pass weights both as a dict in the init or as sample weights in fit? what's the logic? I found it a bit confusing at the beginning.

Thank you!



Soledad Galli

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, December 3, 2020 11:55 AM, Sole Galli via scikit-learn <scikit-learn at python.org> wrote:

> Hello team,
> What is the difference in the implementation of class_weight and sample_weight in those algorithms that support both? like random forest or logistic regression?
> Are both modifying the loss function? in a similar way?
> Thank you!
> Sole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20201204/50e98e28/attachment-0001.html>

More information about the scikit-learn mailing list