text_plain_output_1.png
from sklearn.impute import SimpleImputer

from sklearn.linear_model import LinearRegression

from sklearn.pipeline import Pipeline

from sklearn.preprocessing import StandardScaler

from sklearn.tree import DecisionTreeRegressor

import matplotlib.pyplot as plt

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.tree import DecisionTreeRegressor
tree_reg = DecisionTreeRegressor()
tree_reg.fit(housing_prepared, housing_labels)