{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":50160,"databundleVersionId":7921029,"sourceType":"competition"}],"dockerImageVersionId":30664,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:28.044136Z","iopub.execute_input":"2024-03-19T16:56:28.044582Z","iopub.status.idle":"2024-03-19T16:56:28.605615Z","shell.execute_reply.started":"2024-03-19T16:56:28.044547Z","shell.execute_reply":"2024-03-19T16:56:28.60425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_base = pd.read_csv('/kaggle/input/home-credit-credit-risk-model-stability/csv_files/train/train_base.csv')","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:28.607884Z","iopub.execute_input":"2024-03-19T16:56:28.608544Z","iopub.status.idle":"2024-03-19T16:56:30.323103Z","shell.execute_reply.started":"2024-03-19T16:56:28.608504Z","shell.execute_reply":"2024-03-19T16:56:30.321877Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_base.head()","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:30.324777Z","iopub.execute_input":"2024-03-19T16:56:30.325244Z","iopub.status.idle":"2024-03-19T16:56:30.350876Z","shell.execute_reply.started":"2024-03-19T16:56:30.325188Z","shell.execute_reply":"2024-03-19T16:56:30.349452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_base.info()","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:30.352887Z","iopub.execute_input":"2024-03-19T16:56:30.353771Z","iopub.status.idle":"2024-03-19T16:56:30.565466Z","shell.execute_reply.started":"2024-03-19T16:56:30.353719Z","shell.execute_reply":"2024-03-19T16:56:30.564092Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(df_train_base['target'].value_counts()[1]/df_train_base['target'].value_counts()[0])*100","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:30.569845Z","iopub.execute_input":"2024-03-19T16:56:30.570236Z","iopub.status.idle":"2024-03-19T16:56:30.612264Z","shell.execute_reply.started":"2024-03-19T16:56:30.570207Z","shell.execute_reply":"2024-03-19T16:56:30.610696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test_base = pd.read_csv('/kaggle/input/home-credit-credit-risk-model-stability/csv_files/test/test_base.csv')","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:30.614041Z","iopub.execute_input":"2024-03-19T16:56:30.614555Z","iopub.status.idle":"2024-03-19T16:56:30.630144Z","shell.execute_reply.started":"2024-03-19T16:56:30.614506Z","shell.execute_reply":"2024-03-19T16:56:30.628556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_test_base.shape)\nprint(df_test_base.info())\nprint(df_test_base.head())","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:30.632185Z","iopub.execute_input":"2024-03-19T16:56:30.632777Z","iopub.status.idle":"2024-03-19T16:56:30.648957Z","shell.execute_reply.started":"2024-03-19T16:56:30.632733Z","shell.execute_reply":"2024-03-19T16:56:30.647003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import other tables with 0 depth\ndf_train_static_0_0 = pd.read_csv('/kaggle/input/home-credit-credit-risk-model-stability/csv_files/train/train_static_0_0.csv')\ndf_train_static_0_1 = pd.read_csv('/kaggle/input/home-credit-credit-risk-model-stability/csv_files/train/train_static_0_1.csv')\ndf_train_static_cb_0 = pd.read_csv('/kaggle/input/home-credit-credit-risk-model-stability/csv_files/train/train_static_cb_0.csv')","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:56:30.651324Z","iopub.execute_input":"2024-03-19T16:56:30.65208Z","iopub.status.idle":"2024-03-19T16:57:41.951531Z","shell.execute_reply.started":"2024-03-19T16:56:30.652033Z","shell.execute_reply":"2024-03-19T16:57:41.950016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_train_static_0_0.shape)\nprint(df_train_static_0_0.info())","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:41.953794Z","iopub.execute_input":"2024-03-19T16:57:41.954284Z","iopub.status.idle":"2024-03-19T16:57:41.975351Z","shell.execute_reply.started":"2024-03-19T16:57:41.954241Z","shell.execute_reply":"2024-03-19T16:57:41.973718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_train_static_0_1.shape)\nprint(df_train_static_0_1.info())","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:41.979415Z","iopub.execute_input":"2024-03-19T16:57:41.979793Z","iopub.status.idle":"2024-03-19T16:57:42.003972Z","shell.execute_reply.started":"2024-03-19T16:57:41.979763Z","shell.execute_reply":"2024-03-19T16:57:42.002799Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_train_static_cb_0.shape)\nprint(df_train_static_cb_0.info())","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:42.005251Z","iopub.execute_input":"2024-03-19T16:57:42.00558Z","iopub.status.idle":"2024-03-19T16:57:43.92274Z","shell.execute_reply.started":"2024-03-19T16:57:42.005551Z","shell.execute_reply":"2024-03-19T16:57:43.921186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_base['case_id'].nunique()","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:43.924375Z","iopub.execute_input":"2024-03-19T16:57:43.926775Z","iopub.status.idle":"2024-03-19T16:57:43.989527Z","shell.execute_reply.started":"2024-03-19T16:57:43.926724Z","shell.execute_reply":"2024-03-19T16:57:43.988298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_static_0_1['case_id'].nunique() + df_train_static_0_0['case_id'].nunique()","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:43.99119Z","iopub.execute_input":"2024-03-19T16:57:43.99184Z","iopub.status.idle":"2024-03-19T16:57:44.049915Z","shell.execute_reply.started":"2024-03-19T16:57:43.991806Z","shell.execute_reply":"2024-03-19T16:57:44.048736Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_static_cb_0.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:44.05366Z","iopub.execute_input":"2024-03-19T16:57:44.054013Z","iopub.status.idle":"2024-03-19T16:57:44.061482Z","shell.execute_reply.started":"2024-03-19T16:57:44.053986Z","shell.execute_reply":"2024-03-19T16:57:44.060104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if set(df_train_static_0_1.columns)==set(df_train_static_0_0.columns):\n    print('Both have same columns')\nelse:\n    print('they have diff cols')","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:44.063247Z","iopub.execute_input":"2024-03-19T16:57:44.063951Z","iopub.status.idle":"2024-03-19T16:57:44.072896Z","shell.execute_reply.started":"2024-03-19T16:57:44.063916Z","shell.execute_reply":"2024-03-19T16:57:44.071625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"### Concat static tables\ndf_train_static = pd.concat([df_train_static_0_0,df_train_static_0_1], axis=0)","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:44.074624Z","iopub.execute_input":"2024-03-19T16:57:44.075607Z","iopub.status.idle":"2024-03-19T16:57:45.399981Z","shell.execute_reply.started":"2024-03-19T16:57:44.075565Z","shell.execute_reply":"2024-03-19T16:57:45.398813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_static.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:45.401591Z","iopub.execute_input":"2024-03-19T16:57:45.40207Z","iopub.status.idle":"2024-03-19T16:57:45.411039Z","shell.execute_reply.started":"2024-03-19T16:57:45.402027Z","shell.execute_reply":"2024-03-19T16:57:45.409827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Combine tables with depth 0 to each other\ndf_train = pd.merge(df_train_base,df_train_static,on='case_id', how='outer')","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:57:45.412473Z","iopub.execute_input":"2024-03-19T16:57:45.412818Z","iopub.status.idle":"2024-03-19T16:58:02.514892Z","shell.execute_reply.started":"2024-03-19T16:57:45.41279Z","shell.execute_reply":"2024-03-19T16:58:02.513512Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.head()","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:58:11.259938Z","iopub.execute_input":"2024-03-19T16:58:11.260388Z","iopub.status.idle":"2024-03-19T16:58:11.303447Z","shell.execute_reply.started":"2024-03-19T16:58:11.260351Z","shell.execute_reply":"2024-03-19T16:58:11.302109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if set(df_train_static_cb_0)==set(df_train):\n    print('They are same')\nelse:\n    print('They are not the same')\n","metadata":{"execution":{"iopub.status.busy":"2024-03-19T16:59:05.855183Z","iopub.execute_input":"2024-03-19T16:59:05.855639Z","iopub.status.idle":"2024-03-19T16:59:05.864426Z","shell.execute_reply.started":"2024-03-19T16:59:05.855588Z","shell.execute_reply":"2024-03-19T16:59:05.863089Z"},"trusted":true},"execution_count":null,"outputs":[]}]}