title: How to create an SVM with multiple features for classification?
body: <p>I am writing a piece of code to identify different 2D shapes using opencv. I get 4 sets of data from each image of a 2D shape and these are stored in the multidimensional array featureVectors.</p>
  
  <p>I am trying to write an svm/svc that takes into account all 4 features obtained from the image. I have been able to make it work with just 2 features but when i try all 4 my graph comes out looking like this. </p>
  
  <p><a href="https://i.stack.imgur.com/I5thI.png" rel="nofollow noreferrer">My Graph which is incorrect</a></p>
  
  <p>My values for featureVectors are:</p>
  
  <pre><code>[[  4.00000000e+00   1.74371349e-03   6.49705560e-01   9.07957236e+01]
   [  4.00000000e+00   4.60937436e-02   1.97642179e-01   9.02041472e+01]
   [  1.00000000e+00   1.18553450e-03   3.03491372e-01   6.03489082e+01]
   [  1.00000000e+00   1.54552898e-02   8.38091425e-01   1.09021207e+02]
   [  3.00000000e+00   1.69961646e-02   4.13691915e+01   1.36838300e+02]]
  </code></pre>
  
  <p>And my Labels are:</p>
  
  <pre><code>[[2]
   [2]
   [0]
   [0]
   [1]]
  </code></pre>
  
  <p>Here is my code for the SVM:</p>
  
  <pre><code>#Saving featureVectors to a csv file
  values1 = featureVectors
  header1 = ["Number of Sides", "Standard Deviation of Number of     Sides/Perimeter",
             "Standard Deviation of the Angles", "Largest Angle"]
  my_df = pd.DataFrame(featureVectors)
  my_df.to_csv('featureVectors.csv', index=True, header=header1)
  
  #Saving labels to a csv file
  values2 = labels
  header2 = ["Label"]
  my_df = pd.DataFrame(labels)
  my_df.to_csv('labels.csv', index=True, header=header2)
  
  #Writing the SVM
  def Build_Data_Set(features = header1, features1 = header2):
  
      data_df = pd.DataFrame.from_csv("featureVectors.csv")
      #data_df = data_df[:250]
      X = np.array(data_df[features].values)
  
      data_df2 = pd.DataFrame.from_csv("labels.csv")
      y = np.array(data_df2[features1].values)
      #print(X)
      #print(y)
  
      return X,y
  
  def Analysis():
      X,y = Build_Data_Set()
  
      clf = svm.SVC(kernel = 'linear', C = 1.0)
      clf.fit(X, y)
  
      w = clf.coef_[0]
      a = -w[0] / w[1]
      xx = np.linspace(0,5)
      yy = np.linspace(0,185)
  
      h0 = plt.plot(xx,yy, "k-", label="non weighted")
  
      plt.scatter(X[:, 0],X[:, 1],c=y)
      plt.ylabel("Maximum Angle (Degrees)")
      plt.xlabel("Number Of Sides")
      plt.title('Shapes')
      plt.legend()
  
  
      plt.show()
  
  Analysis()
  </code></pre>
  
  <p>I have only used 5 data sets(shapes) so far because I knew it wasn't working correctly.</p>