text_plain_output_1.png
from sklearn.linear_model import LinearRegression

from sklearn.model_selection import train_test_split

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

import sklearn.metrics as m

import matplotlib.pyplot as plt
import seaborn as sns
house_df = pd.read_csv('../input/housesalesprediction/kc_house_data.csv')

house_df.isnull().sum()

house_df.drop(15870, inplace=True)

from sklearn.model_selection import train_test_split
y = house_df['price']
X = house_df[['bedrooms', 'bathrooms', 'sqft_living', 'sqft_lot', 'floors', 'waterfront', 'view', 'condition', 'grade', 'sqft_above', 'sqft_basement', 'yr_built', 'yr_renovated', 'zipcode', 'lat', 'long', 'sqft_living15', 'sqft_lot15']]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)

from sklearn.linear_model import LinearRegression
lr = LinearRegression(fit_intercept=True)

lr.fit(X_train, y_train)

pred = lr.predict(X_test)

import sklearn.metrics as m
n = X_test.shape[0]
p = X_test.shape[1] - 1
R2 = m.r2_score(y_test, pred)
adj_rsquared = 1 - (1 - R2) * ((n - 1) / (n - p - 1))
print('Adjusted R Squared: {}'.format(adj_rsquared))