title: Plotting cross validation error for different degrees of polynomials
body: <p>I am new to python and want to plot a CV error for each fold and for each degree of polynomial. The below code calculate error values for different degree polynomials and for each fold. Kindly guide me in this regard.</p>
  
  <pre><code>from sklearn.cross_validation import KFold
  kf = KFold(len(dF), n_folds=5)
  e_test = []
  orders = [2,3]
  dims = [6,10]
  for i, order in enumerate(orders): 
      dF = getDataByDegree(d,order)
      error = []
      wTemp = np.empty(dims[i])
      wTemp.fill(0.001)
      for train_index, test_index in kf:
          x_train, x_test = dF[train_index], data['l'][train_index]
          y_train, y_test = dF[test_index], data['l'][test_index]
          w, x_error = gradientDes(wTemp,x_train,x_test)
          y_error = errorfun(w,y_train,y_test)
          error.insert(i,y_error[0])
      e_test.insert(i,error) 
  
  fig, ax = plt.subplots()
  for i in range(1,len(orders):
        ax.plot(orders,values[i],lw=2, label='Test Error - Fold %s' % str(int(i)+1))
  plt.show()   
  </code></pre>