text_plain_output_1.png image_output_1.png
from sklearn.linear_model import LinearRegression

import matplotlib.pyplot as plt

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

test = pd.read_csv('/kaggle/input/random-linear-regression/test.csv')
train = pd.read_csv('/kaggle/input/random-linear-regression/train.csv')

train.dropna(inplace=True)

xtrain = train.x.values.reshape(-1, 1)
ytrain = train.y.values.reshape(-1, 1)

lm = LinearRegression()
lm.fit(xtrain, ytrain)

xtest = test.x.values.reshape(-1, 1)
ytest = test.y.values.reshape(-1, 1)

prediction = lm.predict(xtest)

plt.scatter(prediction, ytest)
plt.xlabel = 'predection'
plt.ylabel = 'y test'