Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import scikit-learn
  2. from sklearn import datasets
  3. from sklearn.model_selection import cross_val_predict
  4. from sklearn import linear_model
  5. import matplotlib.pyplot as plt
  6.  
  7. lr = linear_model.LinearRegression()
  8. boston = datasets.load_boston()
  9. y = boston.target
  10.  
  11. # cross_val_predict returns an array of the same size as `y` where each entry
  12. # is a prediction obtained by cross validation:
  13. predicted = cross_val_predict(lr, boston.data, y, cv=10)
  14.  
  15. fig, ax = plt.subplots()
  16. ax.scatter(y, predicted, edgecolors=(0, 0, 0))
  17. ax.plot([y.min(), y.max()], [y.min(), y.max()], 'k--', lw=4)
  18. ax.set_xlabel('Measured')
  19. ax.set_ylabel('Predicted')
  20. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement