title: raise ValueError("bad input shape {0}".format(shape)) ValueError: bad input shape (10, 90)
body: <p>I am new to this so any help is appriciated, this code was given to me by my prof when I asked for an example, I had hoped for a working model...</p>
  
  <pre><code>from numpy import loadtxt
  import numpy as np
  from sklearn import svm
  from sklearn.metrics import accuracy_score, f1_score
  from sklearn.feature_selection import SelectPercentile, f_classif
  </code></pre>
  
  <p>Read data</p>
  
  <pre><code>data = loadtxt('running.txt')
  label = loadtxt('walking.txt')
  X = data
  y = label
  </code></pre>
  
  <p>Define walking status as 0, running status as 1</p>
  
  <pre><code>print('Class labels:', np.unique(y))
  </code></pre>
  
  <p>Random pick 50% data as test data and leave the rest as train data</p>
  
  <pre><code>from sklearn.cross_validation import train_test_split
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5)
  </code></pre>
  
  <p>Use sklearn to select 50% features</p>
  
  <pre><code>selector = SelectPercentile(f_classif, 50)
  selector.fit(X_train, y_train)
  X_train_transformed = selector.transform(X_train)
  X_test_transformed = selector.transform(X_test)
  </code></pre>
  
  <p>Apply support vector machine algorithm</p>
  
  <pre><code>clf = svm.SVC(kernel="rbf", C=1)
  clf.fit(X_train_transformed, y_train)
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>SVC(C=1, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape=None, degree=3, gamma='auto', kernel='rbf',max_iter=-1,probability=False, random_state=None, shrinking=True,tol=0.001, verbose=False)
  </code></pre>
  
  <p>&nbsp;</p>
  
  <pre><code>pred=clf.predict(X_test_transformed)
  print("Accuracy is %.4f and the f1-score is %.4f " %
  (accuracy_score(pred, y_test), f1_score(y_test, pred)))
  </code></pre>
  
  <blockquote>
    <p>Traceback (most recent call last): File "", line 1, in  File "C:\Users\praym\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile execfile(filename, namespace) File "C:\Users\praym\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
        exec(compile(f.read(), filename, 'exec'), namespace)
      File "C:/Users/praym/OneDrive/School/Information Structres/Assignment4.py", line 18, in 
        selector.fit(X_train, y_train)
      File "C:\Users\praym\Anaconda3\lib\site-packages\sklearn\feature_selection\univariate_selection.py", line 322, in fit
        X, y = check_X_y(X, y, ['csr', 'csc'])
      File "C:\Users\praym\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 515, in check_X_y
        y = column_or_1d(y, warn=True)
      File "C:\Users\praym\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 551, in column_or_1d
        raise ValueError("bad input shape {0}".format(shape))
    ValueError: bad input shape (10, 90)</p>
  </blockquote>