EXTREMEXPLOIT

Sklearn Linear Regression

Mar 24th, 2020
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import sklearn
  4. import matplotlib.pyplot as plt
  5. from matplotlib import style
  6. from mpl_toolkits.mplot3d import Axes3D
  7. from sklearn import linear_model, preprocessing
  8.  
  9. style.use('dark_background')
  10.  
  11. DATA = pd.read_csv('CarPrice.csv', sep=',')
  12. X = np.array(DATA[['wheelbase', 'horsepower', 'curbweight', 'enginesize']])
  13. Y = np.array(DATA['price'])
  14.  
  15. X_Train, X_Test, Y_Train, Y_Test = sklearn.model_selection.train_test_split(X, Y, test_size=0.1)
  16. LinearModel = linear_model.LinearRegression()
  17. LinearModel.fit(X_Train, Y_Train)
  18. Accuracity = LinearModel.score(X_Test, Y_Test)
  19. print(Accuracity)
  20.  
  21. R = LinearModel.predict([[88.6, 111, 2548, 130]])
  22. print(R)
Add Comment
Please, Sign In to add comment