text_plain_output_1.png
from sklearn import linear_model

from sklearn.metrics import r2_score

import matplotlib.pyplot as plt

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

data = pd.read_csv('/kaggle/input/autompg-dataset/auto-mpg.csv', na_values='?', comment='\t', skipinitialspace=True)
data

data = data.replace(np.nan, 0)
data

cor = data.corr()

data = data.drop(['cylinders', 'displacement'], axis=1)
data

cor = data.corr()

x_train = data.iloc[:, 1:]
y_train = data.iloc[:, 0:1]
x_train

x_train.shape

model = linear_model.LinearRegression()
model.fit(x_train, y_train)
y_predict_val = model.predict(x_val)

training_rts = r2_score(y_predict_val, y_val)
training_rts