Guest User

Untitled

a guest
Dec 11th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import tensorflow
  2. import pandas as pd
  3. from sklearn import linear_model
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. from sklearn.model_selection import cross_val_predict
  7. from numpy import genfromtxt
  8.  
  9. data = genfromtxt('data.csv',delimiter=',')
  10. data = np.ndarray(shape=(21,4),buffer=data)
  11. data = np.delete(data,(0),axis=0)
  12. data = np.delete(data,(0),axis=1) # not necessary
  13. data = np.delete(data,(0),axis=1) # not necessary
  14.  
  15. x_data = data[:,[0]] # sleep
  16. y_data = data[:,[1]]# grades
  17.  
  18. lr = linear_model.LinearRegression()
  19.  
  20. predicted = cross_val_predict(lr, x_data, y_data, cv=10)
  21.  
  22. fig1, ax1 = plt.subplots()
  23. fig2, ax2 = plt.subplots()
  24. ax1.plot(x_data, predicted,'.')
  25. ax1.set_xlabel('Time of Sleep')
  26. ax1.set_ylabel('Exam Grades')
  27. ax2.scatter(y_data, predicted, edgecolors=(0, 0, 0))
  28. ax2.plot([y_data.min(), y_data.max()], [y_data.min(), y_data.max()], 'k--', lw=1)
  29. ax2.set_xlabel('Measured')
  30. ax2.set_ylabel('Predicted')
  31.  
  32. plt.show()
Add Comment
Please, Sign In to add comment