title: How to use SVM regression in Iris dataset with pandas
body: <p>I am learning machine learning in python and using scikit learn package. I have already used R for this purpose and find its dataframe struture very easy. Scikit learn uses numpy array which i find little bit difficult. In python we have pandas which is similar to R dataframe. This code is taken from this <a href="http://baoilleach.blogspot.in/2012/10/learn-scikit-and-never-use-r-again.html" rel="nofollow">website</a>.</p>
  
  <p>R</p>
  
  <pre><code>library(e1071)
  library(MASS)
  data(iris)
  
  mysvm &lt;- svm(Species ~ ., iris)
  mysvm.pred &lt;- predict(mysvm, iris)
  table(mysvm.pred,iris$Species)
  # mysvm.pred   setosa versicolor virginica
  #   setosa     50      0          0
  #   versicolor  0     48          2
  #   virginica   0      2         48
  </code></pre>
  
  <p>Python</p>
  
  <pre><code>from sklearn import svm, datasets
  from sklearn.metrics import confusion_matrix
  iris = datasets.load_iris()
  
  mysvm = svm.SVC().fit(iris.data, iris.target)
  mysvm_pred = mysvm.predict(iris.data)
  print confusion_matrix(mysvm_pred, iris.target)
  # [[50  0  0]
  #  [ 0 48  2]
  #  [ 0  0 50]]
  </code></pre>
  
  <p>How can i use above python code with pandas dataframe and use SVM Regression</p>
  
  <p>EDITED</p>
  
  <p>This is what I have done</p>
  
  <pre><code>from sklearn import svm, datasets
  from sklearn.metrics import confusion_matrix
  import pandas as pd
  iris = datasets.load_iris()
  X=pd.DataFrame(iris.data,columns=iris.feature_names)
  y=pd.DataFrame(iris.target)
  X.head()
  y.head()
  mysvm = svm.SVC().fit(X,y )
  mysvm_pred = mysvm.predict(X)
  print confusion_matrix(mysvm_pred, y)
  </code></pre>
  
  <p>But its giving this error</p>
  
  <pre><code>&gt;&gt;&gt; mysvm = svm.SVC().fit(X,y )
  /usr/local/lib/python2.7/dist-packages/sklearn/svm/base.py:514: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
    y_ = column_or_1d(y, warn=True)
  &gt;&gt;&gt; mysvm_pred = mysvm.predict(X)
  &gt;&gt;&gt; print confusion_matrix(mysvm_pred, y)
  /usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py:2645: VisibleDeprecationWarning: `rank` is deprecated; use the `ndim` attribute or function instead. To find the rank of a matrix see `numpy.linalg.matrix_rank`.
    VisibleDeprecationWarning)
  [[50  0  0]
   [ 0 48  0]
   [ 0  2 50]]
  </code></pre>