title: xgboost: Sample Weights for Imbalanced Data?
body: <p>I have a highly unbalanced dataset of 3 classes. To address this, I applied the sample_weight array in the XGBClassifier, but I'm not noticing any changes in the modelling results? All of the metrics in the classification report (confusion matrix) are the same. Is there an issue with the implementation? </p>
  
  <p><strong>The class ratios:</strong></p>
  
  <pre><code>military: 1171 
  government: 34852 
  other: 20869
  </code></pre>
  
  <p><strong>Example:</strong> </p>
  
  <pre><code>pipeline = Pipeline([
      ('bow', CountVectorizer(analyzer=process_text)), # convert strings to integer counts
      ('tfidf', TfidfTransformer()), # convert integer counts to weighted TF-IDF scores
      ('classifier', XGBClassifier(sample_weight=compute_sample_weight(class_weight='balanced', y=y_train))) # train on TF-IDF vectors w/ Naive Bayes classifier
  ])
  </code></pre>
  
  <p><strong>Sample of Dataset:</strong></p>
  
  <pre><code>data = pd.DataFrame({'entity_name': ['UNICEF', 'US Military', 'Ryan Miller'], 
                       'class': ['government', 'military', 'other']})
  </code></pre>
  
  <p><strong>Classification Report</strong></p>
  
  <p><a href="https://i.stack.imgur.com/7uwj5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7uwj5.png" alt="enter image description here"></a></p>