# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

df=pd.read_csv('Salary_Data.csv')

df.head(10)

X = dataset.iloc[:, :-1].values
Y = dataset.iloc[:, 1].values

#Splitting the data sets into traning set and test set
from sklearn.model_selection import train_test_split
X_train , X_test , Y_train ,Y_test = train_test_split(X,Y,test_size=0.25,random_state=0)

from sklearn.linear_model import LinearRegression

lr = LinearRegression()

lr.fit(X_train,Y_train)

y_pred = lr.predict(X_test)

y_pred

Y_test

plt.scatter(X_train,Y_train)
plt.plot(X_train,lr.predict(X_train),color='red')
plt.title('Experience VS Salary ')
plt.xlabel('Years of Experience')
plt.ylabel('Salary')


plt.scatter(X_test,Y_test)
plt.plot(X_train,lr.predict(X_train),color='maroon')
plt.title('Experience VS Salary TEST SET ')
plt.xlabel('Years of Experience')
plt.ylabel('Salary')




StarcoderdataJupyterScriptsDedupFiltered