Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tensorflow
- import pandas as pd
- from sklearn import linear_model
- import matplotlib.pyplot as plt
- import numpy as np
- from sklearn.model_selection import cross_val_predict
- from numpy import genfromtxt
- data = genfromtxt('data.csv',delimiter=',')
- data = np.ndarray(shape=(21,4),buffer=data)
- data = np.delete(data,(0),axis=0)
- data = np.delete(data,(0),axis=1) # not necessary
- data = np.delete(data,(0),axis=1) # not necessary
- x_data = data[:,[0]] # sleep
- y_data = data[:,[1]]# grades
- lr = linear_model.LinearRegression()
- predicted = cross_val_predict(lr, x_data, y_data, cv=10)
- fig1, ax1 = plt.subplots()
- fig2, ax2 = plt.subplots()
- ax1.plot(x_data, predicted,'.')
- ax1.set_xlabel('Time of Sleep')
- ax1.set_ylabel('Exam Grades')
- ax2.scatter(y_data, predicted, edgecolors=(0, 0, 0))
- ax2.plot([y_data.min(), y_data.max()], [y_data.min(), y_data.max()], 'k--', lw=1)
- ax2.set_xlabel('Measured')
- ax2.set_ylabel('Predicted')
- plt.show()
Add Comment
Please, Sign In to add comment