text_plain_output_1.png image_output_1.png
from sklearn import linear_model

import numpy as np # linear algebra

import numpy as np # linear algebra

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

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

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

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

train.sample

train.shape

train.isnull().count()

train = train.dropna()

train.shape

slr = linear_model.LinearRegression()

x_train = np.array(train.iloc[:, :-1].values)
y_train = np.array(train.iloc[:, :1].values)
x_test = np.array(test.iloc[:, :-1].values)
y_test = np.array(test.iloc[:, :1].values)

slr.fit(x_train, y_train)

slr.coef_

slr.intercept_

y_pred = slr.predict(x_test)

y_pred