title: Polynomial regression in Python using sklearn, numpy and matplotlib
body: <p>I'm trying to make a small program that will plot a graph with best fit line and that will predict the COST value based on inputted SIZE value.</p>
  
  <p>I always get this error, and I do not know what it means:</p>
  
  <pre><code>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().
  No handles with labels found to put in legend.
  </code></pre>
  
  <p>This is the graph that I get (red), and I think that curve should look like green curve that i have draw.</p>
  
  <p><a href="https://i.stack.imgur.com/3HgZl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3HgZl.png" alt="enter image description here"></a></p>
  
  <p>And finally, program makes prediction only when I exit the graph.
  What am I doing wrong? 
  This is the code:</p>
  
  <pre><code>import numpy as np
  from sklearn.svm import SVR
  import matplotlib.pyplot as plt
  
  size=[[1],[2],[3],[4],[5],[7],[9],[10],[11],[13]]
  cost=[[10],[22],[35],[48],[60],[80],[92],[111],[118],[133]]
  
  def predict(size,cost,x):
  
      dates=np.reshape(size,(len(size),1))
  
      svr_poly=SVR(kernel="poly",C=1e3, degree=2)
      svr_poly.fit(size,cost)
  
      plt.scatter(size,cost, color="blue")
      plt.plot(cost, svr_poly.predict(cost), color="red")
  
      plt.xlabel("Size")
      plt.ylabel("Cost")
      plt.title("prediction")
      plt.legend()
  
      plt.show()
  
  predictedcost=predict(size,cost,7)
  
  print(predictedcost)
  </code></pre>