text_html_output_1.png
from sklearn.impute import SimpleImputer

from sklearn.linear_model import LinearRegression

from sklearn.metrics import mean_squared_error

from sklearn.pipeline import Pipeline

from sklearn.preprocessing import StandardScaler

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import numpy as np
import pandas as pd
df = pd.read_csv('../input/train.csv')

import matplotlib.pyplot as plt

housing = df.copy()

corr_matrix = housing.corr()

attributes = corr_matrix['SalePrice'].sort_values(ascending=False)
attributes

top10 = attributes[1:11]
attributes[:11]

housing = df.drop('SalePrice', axis=1)
housing_labels = df['SalePrice'].copy()

top10 = list(top10.index)
housing = housing[top10]

from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.impute import SimpleImputer
full_pipeline = Pipeline([('imputer', SimpleImputer(strategy='median')), ('std_scaler', StandardScaler())])
housing_prepared = full_pipeline.fit_transform(housing)
housing_prepared

from sklearn.linear_model import LinearRegression
lin_reg = LinearRegression()
lin_reg.fit(housing_prepared, housing_labels)

some_data = housing.iloc[:5]
some_labels = housing_labels.iloc[:5]
some_data_prepared = full_pipeline.transform(some_data)

from sklearn.metrics import mean_squared_error
housing_predictions = lin_reg.predict(housing_prepared)
lin_mse = mean_squared_error(housing_labels, housing_predictions)
lin_rmse = np.sqrt(lin_mse)
lin_rmse