text_plain_output_1.png
from  sklearn.model_selection import train_test_split

from sklearn.metrics import mean_absolute_error

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)
home_sale_price = data.SalePrice
column_interest = ['BsmtFinSF1', 'SalePrice']
two_column_data = data[column_interest]

y = data.SalePrice
Cost_predictors = ['LotArea', 'YearBuilt', '1stFlrSF', '2ndFlrSF', 'FullBath', 'BedroomAbvGr', 'TotRmsAbvGrd']
X = data[Cost_predictors]
from sklearn.tree import DecisionTreeRegressor
price_model = DecisionTreeRegressor()
price_model.fit(X, y)

from sklearn.metrics import mean_absolute_error
predicted_home_price = price_model.predict(X)
mean_absolute_error(y, predicted_home_price)

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