title: How does sample_weight compare to class_weight in scikit-learn?
body: <p>I would like to use <a href="http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.GradientBoostingClassifier.html" rel="noreferrer">sklearn.ensemble.GradientBoostingClassifier</a> on an imbalanced classification problem. I intend to optimize for <a href="http://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html" rel="noreferrer">Area Under the Receiver Operating Characteristic Curve (ROC AUC)</a>. For this I would like to reweight my classes to make the small class more important to the classifier. </p>
  
  <p>This would normally be done (in <a href="http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html" rel="noreferrer">RandomForestClassifier</a> for example) by setting class_weight = “balanced” but there is no such parameter in the GradientBoostingClassifier.</p>
  
  <p>The documentation says:</p>
  
  <p><strong>The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y))</strong></p>
  
  <p>If y_train is my dataframe of my target with elements in {0,1}, then the documentation implies that this should reproduce the same as class_weight = “balanced” </p>
  
  <pre><code>sample_weight = y_train.shape[0]/(2*np.bincount(y_train))
  clf = ensemble.GradientBoostingClassifier(**params)
  clf.fit(X_train, y_train,sample_weight = sample_weight[y_train.values])
  </code></pre>
  
  <p>Is this correct or am I missing something?</p>