image_output_1.png
from sklearn.linear_model import LinearRegression

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df = pd.read_csv('/kaggle/input/years-of-experience-and-salary-dataset/Salary_Data.csv')

x = df[['YearsExperience']]
x

y = df.iloc[:, 1].values
y

from sklearn.linear_model import LinearRegression
model = LinearRegression()

model.fit(x, y)

y_pred = model.predict(x)
y_pred

model.coef_

model.intercept_