text_plain_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 # data processing, CSV file I/O (e.g. pd.read_csv)

import numpy as np
import pandas as pd
from sklearn.tree import DecisionTreeRegressor
from sklearn.metrics import mean_absolute_error
from sklearn.model_selection import train_test_split
from sklearn.impute import SimpleImputer
df = pd.read_csv('../input/melbourne-housing-snapshot/melb_data.csv')
def trainModelAndAssessMAE(df):
    df = df.select_dtypes(exclude=['object'])
    df, df_test = train_test_split(df, random_state=0)
    mdl = DecisionTreeRegressor(random_state=0)
    data = df
    answers = df[['Price']]
    mdl = mdl.fit(data, answers)
    predictions = mdl.predict(df_test.select_dtypes(exclude=['object']))
    return mean_absolute_error(predictions, df_test[['Price']])

trainModelAndAssessMAE(df.dropna(axis=0))