title: Residual plot for residual vs predicted value in Python
body: <p>I have run a KNN model. Now i want to plot the residual vs predicted value plot. Every example from different websites shows that i have to first run a linear regression model. But i couldn't understand how to do this. Can anyone help? Thanks in advance.
  Here is my model-</p>
  <pre><code>train, validate, test = np.split(df.sample(frac=1), [int(.6*len(df)), int(.8*len(df))])
  x_train = train.iloc[:,[2,5]].values
  y_train = train.iloc[:,4].values
  x_validate = validate.iloc[:,[2,5]].values
  y_validate = validate.iloc[:,4].values
  x_test = test.iloc[:,[2,5]].values
  y_test = test.iloc[:,4].values
  clf=neighbors.KNeighborsRegressor(n_neighbors = 6)
  clf.fit(x_train, y_train)
  y_pred = clf.predict(x_validate)
  </code></pre>