{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-07-01T20:56:13.544592Z","iopub.execute_input":"2021-07-01T20:56:13.545003Z","iopub.status.idle":"2021-07-01T20:56:13.573286Z","shell.execute_reply.started":"2021-07-01T20:56:13.544921Z","shell.execute_reply":"2021-07-01T20:56:13.571832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"../input/mitsuru-features-only-train-and-test/train_df_noindex.csv\")\ntest = pd.read_csv(\"../input/mitsuru-features-only-train-and-test/test_df_noindex.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:56:34.304741Z","iopub.execute_input":"2021-07-01T20:56:34.305092Z","iopub.status.idle":"2021-07-01T20:56:48.165410Z","shell.execute_reply.started":"2021-07-01T20:56:34.305064Z","shell.execute_reply":"2021-07-01T20:56:48.164511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:56:48.166865Z","iopub.execute_input":"2021-07-01T20:56:48.167187Z","iopub.status.idle":"2021-07-01T20:56:48.201959Z","shell.execute_reply.started":"2021-07-01T20:56:48.167153Z","shell.execute_reply":"2021-07-01T20:56:48.201283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:57:13.287068Z","iopub.execute_input":"2021-07-01T20:57:13.287397Z","iopub.status.idle":"2021-07-01T20:57:13.292705Z","shell.execute_reply.started":"2021-07-01T20:57:13.287366Z","shell.execute_reply":"2021-07-01T20:57:13.291653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"execution":{"iopub.status.busy":"2021-07-01T21:01:47.483796Z","iopub.execute_input":"2021-07-01T21:01:47.484748Z","iopub.status.idle":"2021-07-01T21:01:47.652516Z","shell.execute_reply.started":"2021-07-01T21:01:47.484685Z","shell.execute_reply":"2021-07-01T21:01:47.651720Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install deep_autoviml --upgrade","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:57:19.057175Z","iopub.execute_input":"2021-07-01T20:57:19.057489Z","iopub.status.idle":"2021-07-01T20:58:31.230507Z","shell.execute_reply.started":"2021-07-01T20:57:19.057461Z","shell.execute_reply":"2021-07-01T20:58:31.229429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from deep_autoviml import deep_autoviml as deepauto","metadata":{"execution":{"iopub.status.busy":"2021-07-01T20:58:49.154413Z","iopub.execute_input":"2021-07-01T20:58:49.154762Z","iopub.status.idle":"2021-07-01T20:58:53.238044Z","shell.execute_reply.started":"2021-07-01T20:58:49.154728Z","shell.execute_reply":"2021-07-01T20:58:53.237093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"######   D E F A U L T S    S E T T I N G S   F O R   D E E P    A U T O  V I M L ###\nkeras_model_type =  \"fast\" ## always try \"fast\" first, then \"fast2\", \"auto\", etc.\n### always set early_stopping to True first and then change it to False\n#### You always need 15 max_trials to get something decent #####\n#### always set tuner to \"storm\" and then \"optuna\". \n### NLP char limit kicks off NLP processing. Feature Cross later.\nproject_name = \"Elo\"\nmodel_options = {'nlp_char_limit':50, 'cat_feat_cross_flag':False,\n                 'max_trials': 10, \"tuner\": \"storm\"}\nkeras_options = {\"patience\":10, 'class_weight': True, 'early_stopping': True, \n                 'lr_scheduler': '', \"optimizer\": 'RMS'}","metadata":{"execution":{"iopub.status.busy":"2021-07-01T21:02:35.280974Z","iopub.execute_input":"2021-07-01T21:02:35.281291Z","iopub.status.idle":"2021-07-01T21:02:35.286568Z","shell.execute_reply.started":"2021-07-01T21:02:35.281261Z","shell.execute_reply":"2021-07-01T21:02:35.285576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target = \"target\"","metadata":{"execution":{"iopub.status.busy":"2021-07-01T21:02:46.700201Z","iopub.execute_input":"2021-07-01T21:02:46.700653Z","iopub.status.idle":"2021-07-01T21:02:46.704956Z","shell.execute_reply.started":"2021-07-01T21:02:46.700586Z","shell.execute_reply":"2021-07-01T21:02:46.703847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model, cat_vocab_dict = deepauto.fit(train, target, keras_model_type=keras_model_type,\n                                     project_name=project_name, keras_options=keras_options,  \n                                     model_options=model_options, save_model_flag=False, use_my_model='',\n                                     model_use_case='', verbose=1)","metadata":{"execution":{"iopub.status.busy":"2021-07-01T21:03:21.918038Z","iopub.execute_input":"2021-07-01T21:03:21.918365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = deepauto.predict(model, project_name, test_dataset=test,\n                                 keras_model_type=keras_model_type, \n                                 cat_vocab_dict=cat_vocab_dict)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_preds = predictions[-1]","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission = pd.read_csv('/kaggle/input/elo-merchant-category-recommendation/sample_submission.csv')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission['target'] = preds.as_data_frame().values.flatten()\nsample_submission.to_csv('submission_1.csv', index=False)","metadata":{},"execution_count":null,"outputs":[]}]}