{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"print(os.listdir(\"../input/andrews-features-only\"))\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0be78c0dd2e3a95f6f87bffafba9f138f70dd893"},"cell_type":"code","source":"import h2o\nfrom h2o.automl import H2OAutoML\n\nh2o.init(max_mem_size='16G')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"82931a909e601f27dd14c6b8fa3706d378cd10a2"},"cell_type":"code","source":"train = h2o.import_file(\"../input/andrews-features-only/X_tr.csv\")\ntest = h2o.import_file(\"../input/andrews-features-only/X_test.csv\")\ny_train = h2o.import_file(\"../input/andrews-features-only/y_tr.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e9ad4c8900cef210b9f1d569f9d0f703dc03d8ec"},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4e64dc8eae125d7901f85fe448b1a66d9826c7d9"},"cell_type":"code","source":"train['time_to_failure'] = y_train['time_to_failure']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"61dbd6943bada1efc1b796f14bd3bebe4af9b82a"},"cell_type":"code","source":"train.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"85b81e540dc7dcf9318176ec414b3accf2271175"},"cell_type":"code","source":"test.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"76ded483948203283f906f3fbbb0989cb1f02eb7"},"cell_type":"code","source":"x = test.columns\ny = 'time_to_failure'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e52a9b27ef9c8d034a7f1c24e5ea35ff353a0d23"},"cell_type":"code","source":"# Run AutoML for 20 base models (limited to 1 hour max runtime by default)\naml = H2OAutoML(max_models=50000, seed=55, max_runtime_secs=31000,nfolds=0,sort_metric=\"MAE\",stopping_metric=\"MAE\")\naml.train(x=x, y=y, training_frame=train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f2ac0c86a2feaf02b60f6a598bafc8b107f416cc"},"cell_type":"code","source":"# View the AutoML Leaderboard\nlb = aml.leaderboard\nlb.head(rows=lb.nrows)  # Print all rows instead of default (10 rows)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e0291089fc2252d5b629da28ceaee61636f816b2"},"cell_type":"code","source":"# The leader model is stored here\naml.leader","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4e17f770534985ca65496f056a4ba12b2add0c52"},"cell_type":"code","source":"# If you need to generate predictions on a test set, you can make\n# predictions directly on the `\"H2OAutoML\"` object, or on the leader\n# model object directly\n\npreds = aml.predict(test)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"54e5d315397bf1ab5681a228555f7d9e6ad686da"},"cell_type":"code","source":"sample_submission = pd.read_csv('../input/LANL-Earthquake-Prediction/sample_submission.csv')\nsample_submission['time_to_failure'] = preds.as_data_frame().values.flatten()\nsample_submission.to_csv('h2o_submission_1.csv', index=False)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"70795e7c27bc02c23dc457ac6407f8686af81fce"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}