Screen Link:
My Code:
import numpy as np
lr = LinearRegression()
lr.fit(train[['Gr Liv Area']], train['SalePrice'])
from sklearn.metrics import mean_squared_error
train_predictions = lr.predict(train[['Gr Liv Area']])
test_predictions = lr.predict(test[['Gr Liv Area']])
train_mse = mean_squared_error(train_predictions, train['SalePrice'])
test_mse = mean_squared_error(test_predictions, test['SalePrice'])
train_rmse = np.sqrt(train_mse)
test_rmse = np.sqrt(test_mse)
print(train_rmse)
print(test_rmse)
What I expected to happen:
I don’t really understand the logic of the code from train_predictions = lr.predict(train[[‘Gr Liv Area’]])
on down.
Could someone explain what is going on at each line? Thanks
What actually happened:
Replace this line with the output/error