text_plain_output_1.png
from sklearn.linear_model import LinearRegression

from sklearn.model_selection import train_test_split

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

car = pd.read_csv('/kaggle/input/car-15/cardata.csv')

car.columns

car.isnull().sum()

car.replace({'Fuel_Type': {'Petrol': 0, 'Diesel': 1, 'CNG': 2}}, inplace=True)
car.replace({'Seller_Type': {'Dealer': 0, 'Individual': 1}}, inplace=True)
car.replace({'Transmission': {'Manual': 0, 'Automatic': 1}}, inplace=True)

corr = car.corr()

X = car.drop(['Car_Name', 'Selling_Price'], axis=1)
Y = car['Selling_Price']
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=42)

lrmodel = LinearRegression()
lrmodel.fit(X_train, Y_train)

training_data_prediction = lrmodel.predict(X_train)

Y_pred = lrmodel.predict(X_test)

sns.regplot(x=Y_test, y=Y_pred, data=car, scatter_kws={'color': 'green'}, line_kws={'color': 'blue'})