{"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","collapsed":true,"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":false},"cell_type":"markdown","source":"### cf. https://www.kaggle.com/bluexleoxgreen/simple-feature-lightgbm-baseline"},{"metadata":{"trusted":true,"_uuid":"c0605fdfd52510e755172da5f1b8c451c5fa5cf5"},"cell_type":"code","source":"import h2o\nfrom h2o.automl import H2OAutoML\n\nh2o.init(max_mem_size='15G')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6fee248af0e9f763f016a733dd511ac61b83f8ae"},"cell_type":"code","source":"%%time\ntrain = h2o.import_file(\"../input/vsb-train-test-1/train_new.csv\")\ntest = h2o.import_file(\"../input/vsb-train-test-1/test_new.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"30df7fb472b8985a74739fd13e3fe0599ff6ef79"},"cell_type":"code","source":"train = train.drop(['id_measurement','phase'])\ntest = test.drop(['id_measurement','phase'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0517d483f6c1e9a0f57a77e0010cc7cd78cc8b0a"},"cell_type":"code","source":"train.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7f35715e3c36c1c40a8784ce41eea319976916c3"},"cell_type":"code","source":"x = train.columns\ny = \"target\"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c19d660ea367c5d430160fa142f4616bb5782f60"},"cell_type":"code","source":"# For binary classification, response should be a factor\ntrain[y] = train[y].asfactor()\nx.remove(y)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"19f06934b815e50b925a8787c5bcf1ec26a50a0d"},"cell_type":"code","source":"%%time\n# Run AutoML for 50 base models (limited to 1 hour max runtime by default)\naml = H2OAutoML(max_models=50, seed=42, max_runtime_secs=7200)\naml.train(x=x, y=y, training_frame=train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"264adea191fd793f05590e720fd62a34b959cf9e"},"cell_type":"code","source":"lb = aml.leaderboard\nlb.head(rows=lb.nrows) ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a58e7afb987ed0982235223058817a84d8687430"},"cell_type":"code","source":"aml.leader # Best model","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"89263b6bd933ab7c7e5c9680af87d9f1109fbb0c"},"cell_type":"code","source":"preds = aml.predict(test)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e81b62e8708dbde594f0a95ffe6ecf586b8eb97c"},"cell_type":"code","source":"predictions = preds[0].as_data_frame().values.flatten()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"72171d190b185c8a5d5a8b1214b3c2aa1f309093"},"cell_type":"code","source":"x_filename = pd.read_csv('../input/vsb-train-test-1/test_new.csv')['signal_id']\nsub_df = pd.DataFrame({\"signal_id\":x_filename})\nsub_df[\"target\"] = pd.Series(predictions).round()\nsub_df['signal_id'] = sub_df['signal_id'].astype(np.int64)\nsub_df['target'] = sub_df['target'].astype(np.int64)\nsub_df.to_csv(\"submission.csv\", index=False)\nsub_df","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}