image_output_1.png
from sklearn.linear_model import LinearRegression

import matplotlib.pyplot as plt

import pandas as pd

data = pd.read_csv('../input/salary/Salary_Data.csv')
data

df = pd.DataFrame(data)
df

regressor = LinearRegression()
regressor.fit(x_train, y_train)

y_pred = regressor.predict(x_test)
y_pred

a = x_test
b = y_test
c = x_test
d = y_pred

a = x_test
b = y_test
c = x_test
d = y_pred

compare = pd.DataFrame({'Actual': y_test.flatten(), 'Prediction': y_pred.flatten()})
compare

a = x_train
b = y_train
c = x_test
d = y_pred
plt.scatter(a, b)
plt.scatter(c, d)
plt.grid()
plt.show()