XGBoost: How to obtain scale_pos_weight for multi classes?

I know there is a similar Qn at Unbalanced multiclass data with XGBoost.

  1. But I don't understand the reply provided by @Esmailian. What is the actual formula to obtain 1, 0.333 and 0.167?
For example, if we have three imbalanced classes with ratios

class A = 10%
class B = 30%
class C = 60%

Their weights would be (dividing the smallest class by others)

class A = 1.000
class B = 0.333
class C = 0.167
  1. Will I obtain the same values with
from sklearn.utils import class_weight
classes_weights = class_weight.compute_sample_weight(
    class_weight='balanced',
    y=train_df['class']
)

Topic weighted-data machine-learning

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.