"""
Thanks to https://www.kaggle.com/rohanrao/automl-tutorial-tps-may-2021
for wonderful notebook. I have copied few commands from the same nb.
"""


## import packages
import pandas as pd

import h2o
from h2o.automl import H2OAutoML


#load and split dataset into training and test folds
## prepare data
h2o.init()

h2o_train = h2o.import_file('../input/santander-customer-transaction-prediction-dataset/train.csv')
h2o_test = h2o.import_file('../input/santander-customer-transaction-prediction-dataset/test.csv')

h2o_train['target'] = h2o_train['target'].asfactor()


h2o_train.head()
h2o_train.describe()
len(h2o_train.columns)
## run model
features = [x for x in h2o_train.columns if x not in ['ID_code', 'target']]

model = H2OAutoML()
model
model.train(x=features, y='target', training_frame=h2o_train)
## check leaderboard
model.leaderboard


## generate predictions
preds_h2oaml = model.leader.predict(h2o_test)


preds_h2oaml = preds_h2oaml.drop([1,2])
preds_h2oaml.as_data_frame()