title: What is sample weight in sklearn.model_selection.train_test_split
body: <p>In <a href="http://scikit-learn.org/stable/auto_examples/calibration/plot_calibration.html" rel="nofollow noreferrer">probability calibration of classifiers</a> from scikit-learn, there is a section of codes about <a href="http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html" rel="nofollow noreferrer">train_test_split</a> which I could not find explanation in documents.</p>
  
  <pre><code>centers = [(-5, -5), (0, 0), (5, 5)] X, y =
  make_blobs(n_samples=n_samples, n_features=2, cluster_std=1.0,
                    centers=centers, shuffle=False, random_state=42)
  
  y[:n_samples // 2] = 0 
  y[n_samples // 2:] = 1 
  sample_weight = np.random.RandomState(42).rand(y.shape[0])
  
  # split train, test for calibration 
  X_train, X_test, y_train, y_test, sw_train, sw_test = \
      train_test_split(X, y, sample_weight, test_size=0.9, random_state=42)
  </code></pre>
  
  <ol>
  <li><blockquote>
    <p>What does <code>sample_weight</code> in <code>train_test_split</code> do?</p>
  </blockquote></li>
  <li><blockquote>
    <p>How does the source code of <code>train_test_split</code> process <code>sample_weight</code>?</p>
  </blockquote></li>
  </ol>
  
  <p>Thanks a lot in advance.</p>