Advertisement
Guest User

dian

a guest
Nov 18th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. # Import the necessary libraries
  2. import numpy
  3. import matplotlib.pyplot as plot
  4. import pandas
  5. from sklearn.model_selection import train_test_split
  6. from sklearn.linear_model import LinearRegression
  7.  
  8. # Import the dataset
  9. dataset = pandas.read_csv('dian.csv')
  10. x = dataset.iloc[:, 0].values.reshape(-1, 1)
  11. y = dataset.iloc[:, 1].values.reshape(-1, 1)
  12.  
  13. linearRegressor = LinearRegression()
  14. linearRegressor.fit(x, y)
  15.  
  16. # Visualising the training set results
  17. plot.scatter(x, y, color = 'blue')
  18. plot.plot(x, linearRegressor.predict(x), color = 'red')
  19. plot.title('Training set')
  20. plot.xlabel('Payroll')
  21. plot.ylabel('Sales')
  22. plot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement