{"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":"import gc\nimport tensorflow as tf\nimport numpy as np\nimport pandas as pd","metadata":{"execution":{"iopub.status.busy":"2023-02-11T02:20:10.477708Z","iopub.execute_input":"2023-02-11T02:20:10.478666Z","iopub.status.idle":"2023-02-11T02:20:17.132918Z","shell.execute_reply.started":"2023-02-11T02:20:10.478549Z","shell.execute_reply":"2023-02-11T02:20:17.131627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test_1 = pd.read_feather('../input/amex-imputed-and-1hot-encoded/X_test_1.ftr').set_index('customer_ID')\nX_test_2 = pd.read_feather('../input/amex-imputed-and-1hot-encoded/X_test_2.ftr').set_index('customer_ID')","metadata":{"execution":{"iopub.status.busy":"2023-02-11T02:20:17.135359Z","iopub.execute_input":"2023-02-11T02:20:17.136026Z","iopub.status.idle":"2023-02-11T02:21:05.981462Z","shell.execute_reply.started":"2023-02-11T02:20:17.135987Z","shell.execute_reply":"2023-02-11T02:21:05.979692Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = tf.keras.models.load_model('/kaggle/input/test-dtc-model/shallow_nn.h5')","metadata":{"execution":{"iopub.status.busy":"2023-02-11T02:21:05.983536Z","iopub.execute_input":"2023-02-11T02:21:05.983931Z","iopub.status.idle":"2023-02-11T02:21:10.167672Z","shell.execute_reply.started":"2023-02-11T02:21:05.983893Z","shell.execute_reply":"2023-02-11T02:21:10.166364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds1 = pd.DataFrame(model.predict(dict(X_test_1), batch_size=5000, verbose=1), index=X_test_1.index, columns=['prediction'])\npreds2 = pd.DataFrame(model.predict(dict(X_test_2), batch_size=5000, verbose=1), index=X_test_2.index, columns=['prediction'])","metadata":{"execution":{"iopub.status.busy":"2023-02-11T02:21:10.169866Z","iopub.execute_input":"2023-02-11T02:21:10.170327Z","iopub.status.idle":"2023-02-11T02:22:49.658277Z","shell.execute_reply.started":"2023-02-11T02:21:10.170282Z","shell.execute_reply":"2023-02-11T02:22:49.656876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del X_test_1, X_test_2\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2023-02-11T02:22:49.660870Z","iopub.execute_input":"2023-02-11T02:22:49.661325Z","iopub.status.idle":"2023-02-11T02:22:49.937889Z","shell.execute_reply.started":"2023-02-11T02:22:49.661283Z","shell.execute_reply":"2023-02-11T02:22:49.936299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.concat([preds1, preds2])\n\n# predictions only need to be for each customer\nsubmission = submission.groupby('customer_ID').agg(['last'])\nsubmission.columns = submission.columns.droplevel(1)\n\n# index needs to be removed from submission csv\nsubmission = submission.reset_index()\nsubmission.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2023-02-11T02:22:49.939449Z","iopub.execute_input":"2023-02-11T02:22:49.939815Z","iopub.status.idle":"2023-02-11T02:22:56.269924Z","shell.execute_reply.started":"2023-02-11T02:22:49.939782Z","shell.execute_reply":"2023-02-11T02:22:56.268830Z"},"trusted":true},"execution_count":null,"outputs":[]}]}