0

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 ?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
pierre_comalada
  • 300
  • 3
  • 11

2 Answers2

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.

Community
  • 1
  • 1
lorenzori
  • 737
  • 7
  • 23
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