title: Sci-kit Learn PLS SVD and cross validation
body: <p>The <code>sklearn.cross_decomposition.PLSSVD</code> class in Sci-kit learn appears to be failing when the response variable has a shape of <code>(N,)</code> instead of <code>(N,1)</code>, where <code>N</code> is the number of samples in the dataset.</p>
  
  <p>However, <code>sklearn.cross_validation.cross_val_score</code> fails when the response variable has a shape of <code>(N,1)</code> instead of <code>(N,)</code>. How can I use them together?</p>
  
  <p>A snippet of code:</p>
  
  <pre><code>from sklearn.pipeline import Pipeline
  from sklearn.cross_decomposition import PLSSVD
  from sklearn.preprocessing import StandardScaler
  from sklearn.linear_model import LogisticRegression
  
  # x -&gt; (N, 60) numpy array
  # y -&gt; (N, ) numpy array
  
  # These are the classifier 'pieces' I'm using
  plssvd = PLSSVD(n_components=5, scale=False)
  logistic = LogisticRegression(penalty='l2', C=0.5)
  scaler = StandardScaler(with_mean=True, with_std=True)
  
  # Here's the pipeline that's failing
  plsclf = Pipeline([('scaler', scaler),
                     ('plssvd', plssvd), 
                     ('logistic', logistic)])
  
  # Just to show how I'm using the pipeline for a working classifier
  logclf = Pipeline([('scaler', scaler),
                     ('logistic', logistic)])
  
  ##################################################################
  
  # This works fine
  log_scores = cross_validation.cross_val_score(logclf, x, y, scoring='accuracy',
                                                verbose=True, cv=5, n_jobs=4)
  
  # This fails!
  pls_scores = cross_validation.cross_val_score(plsclf, x, y, scoring='accuracy',
                                                verbose=True, cv=5, n_jobs=4)
  </code></pre>
  
  <p>Specifically, it fails in the <code>_center_scale_xy</code> function of <code>cross_decomposition/pls_.pyc</code> with <code>'IndexError: tuple index out of range'</code> at line 103: <code>y_std = np.ones(Y.shape[1])</code>, because the shape tuple has only one element.</p>
  
  <p>If I set <code>scale=True</code> in the <code>PLSSVD</code> constructor, it fails in the same function at line 99: <code>y_std[y_std == 0.0] = 1.0</code>, because it is attempting to do a boolean index on a float (<code>y_std</code> is a float, since it only has one dimension).</p>
  
  <p>Seems, like an easy fix, just make sure the <code>y</code> variable has two dimensions, <code>(N,1)</code>. <strong>However:</strong></p>
  
  <p>If I create an array with dimensions <code>(N,1)</code> out of the output variable <code>y</code>, it still fails. In order to change the arrays, I add this before running <code>cross_val_score</code>:</p>
  
  <pre><code>y = np.transpose(np.array([y]))
  </code></pre>
  
  <p>Then, it fails in <code>sklearn/cross_validation.py</code> at line 398:</p>
  
  <pre><code>File "my_secret_script.py", line 293, in model_create
      scores = cross_validation.cross_val_score(plsclf, x, y, scoring='accuracy', verbose=True, cv=5, n_jobs=4)
  File "/Users/my.secret.name/anaconda/lib/python2.7/site-packages/sklearn/cross_validation.py", line 1129, in cross_val_score
      cv = _check_cv(cv, X, y, classifier=is_classifier(estimator))
  File "/Users/my.secret.name/anaconda/lib/python2.7/site-packages/sklearn/cross_validation.py", line 1216, in _check_cv
      cv = StratifiedKFold(y, cv, indices=needs_indices)
  File "/Users/my.secret.name/anaconda/lib/python2.7/site-packages/sklearn/cross_validation.py", line 398, in __init__
      label_test_folds = test_folds[y == label]
  ValueError: boolean index array should have 1 dimension
  </code></pre>
  
  <p>I'm running this on OSX, NumPy version <code>1.8.0</code>, Sci-kit Learn version <code>0.15-git</code>.</p>
  
  <p>Any way to use <code>PLSSVD</code> together with <code>cross_val_score</code>?</p>