text_html_output_1.png
from sklearn.metrics import mean_absolute_error

from sklearn.model_selection import train_test_split

from sklearn.tree import DecisionTreeRegressor

import pandas as pd

import pandas as pd
main_file_path = '../input/train.csv'
data = pd.read_csv(main_file_path)

y = data.SalePrice

predicators = ['YearBuilt', 'YrSold', 'TotalBsmtSF']

X = data[predicators]

from sklearn.tree import DecisionTreeRegressor
housing_model = DecisionTreeRegressor()
housing_model.fit(X, y)

from sklearn.metrics import mean_absolute_error
predicted_Home_prices = housing_model.predict(X)
mean_absolute_error(y, predicted_Home_prices)

from sklearn.model_selection import train_test_split
train_X, val_X, train_y, val_y = train_test_split(X, y, random_state=0)
housing_model = DecisionTreeRegressor()
housing_model.fit(train_X, train_y)
val_predictions = housing_model.predict(val_X)
print(mean_absolute_error(val_y, val_predictions))