image_output_1.png
from sklearn.linear_model import LinearRegression

import pandas as pd

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

df = pd.DataFrame(data)
df

x = df.YearsExperience.values.reshape(-1, 1)
y = df.Salary.values.reshape(-1, 1)

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

y_pred = regressor.predict(x_test)
y_pred

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

df2 = pd.DataFrame({'YearsExperience': [1.5, 2.5, 3.5, 4.5, 5], 'Salary': [1, 4, 8, 9, 10]})

df3 = df.append(df2)
df3