I would like to know how scikit-learn put more emphasis on a class when we use the parameter class_weight
. Is it an oversampling of the minority sampling ?
Asked
Active
Viewed 435 times
0

desertnaut
- 57,590
- 26
- 140
- 166

pierre_comalada
- 300
- 3
- 11
2 Answers
0
Neither. I think that it instead affects the loss:
- higher loss for the class with higher weight.
- lower loss for the class with a lower weight.
The matter is discussed more in depth in this thread.
-
This is generally true. However, I think the question is how it is actually done? – AndreyF Jan 25 '17 at 12:18
-
Yes the question is more how it penalize the majority class. – pierre_comalada Jan 25 '17 at 12:29
0
I'm not sure if there is a single method of treating class_weight
for all the algorithms.
The way Decision Trees (and Forests) deals with this is by modifying the weights of each sample according to its class.
You can consider weighting samples as a more general case of oversampling all the minority class samples (using weights you can "oversample" fractions of samples).

AndreyF
- 1,798
- 1
- 14
- 25