Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import the necessary libraries
- import numpy
- import matplotlib.pyplot as plot
- import pandas
- from sklearn.model_selection import train_test_split
- from sklearn.linear_model import LinearRegression
- # Import the dataset
- dataset = pandas.read_csv('dian.csv')
- x = dataset.iloc[:, 0].values.reshape(-1, 1)
- y = dataset.iloc[:, 1].values.reshape(-1, 1)
- linearRegressor = LinearRegression()
- linearRegressor.fit(x, y)
- # Visualising the training set results
- plot.scatter(x, y, color = 'blue')
- plot.plot(x, linearRegressor.predict(x), color = 'red')
- plot.title('Training set')
- plot.xlabel('Payroll')
- plot.ylabel('Sales')
- plot.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement