Kaggle competition: House Prices - Advanced Regression Techniques
<SOS> metric: rmsle Kaggle data source: house-prices-advanced-regression-techniques<load_from_csv>
!pip install h2o
train_df = pd.read_csv(".. /input/titanic/train.csv")
 test_df = pd.read_csv(".. /input/titanic/test.csv" )<count_missing_values>
%matplotlib inline
train_df.isna().sum()<count_missing_values>
h2o.init()
test_df.isna().sum()<concatenate>
train = h2o.import_file('/kaggle/input/house-prices-advanced-regression-techniques/train.csv')
 test = h2o.import_file('/kaggle/input/house-prices-advanced-regression-techniques/test.csv')
 train.head()
train_set = train_df.drop(columns=["Survived"])
 test_set = test_df.copy(deep = True)
 frame = [train_set,test_set]
final_set = pd.concat(frame,axis=0 )<categorify>
train = train[train['GrLivArea'] < 4500]
train['SalePrice'] = train['SalePrice'].log1p()
def fill_nan_categorical(categorical_features,data):
for i in categorical_features:
data[i] = data[i].fillna(data[i].mode() [0])
 return data<categorify>
x = [col for col in train.columns if col not in ['Id','SalePrice']]
y = 'SalePrice'
test_id = test['Id']
categorical_features = final_set.select_dtypes(exclude=["number","bool_"] ).columns.tolist()
final_set = fill_nan_categorical(categorical_features,final_set )<categorify>
aml = H2OAutoML(max_models = 30, max_runtime_secs=300, seed = 1, stopping_metric = 'RMSLE')
 aml.train(x = x, y = y, training_frame = train )
def fill_nan_continuous(continuous_features,data):
for i in categorical_features:
data[i] = data[i].fillna(data[i].mean() [0])
 return data<data_type_conversions>
lb = aml.leaderboard; lb
continuous_features = final_set.select_dtypes(include=["number","object_"] ).columns.tolist()
final_set = fill_nan_categorical(continuous_features,final_set )<categorify>
aml.leader
def one_hot_encoder(final_set):
df = final_set.copy(deep= True)
 dummies = pd.get_dummies(df,prefix="column_",drop_first=True)
 return dummies<categorify>
preds = aml.leader.predict(test )
final_set = final_set.drop(columns = ["Name"])
 ohe_set = one_hot_encoder(final_set )<prepare_x_and_y>
result = preds.expm1()
sub = test_id.cbind(result)
 sub.columns = ['Id','SalePrice']
sub = sub.as_data_frame()
sub.to_csv('submission.csv', index = False )