{"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 numpy as np\nimport pandas as pd\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport seaborn as sns ","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:19:47.326763Z","iopub.execute_input":"2022-05-27T10:19:47.327514Z","iopub.status.idle":"2022-05-27T10:19:48.609917Z","shell.execute_reply.started":"2022-05-27T10:19:47.327415Z","shell.execute_reply":"2022-05-27T10:19:48.608837Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# matplotlib setting\nmpl.rcParams['figure.dpi'] = 200\nmpl.rcParams['axes.spines.top'] = False\nmpl.rcParams['axes.spines.right'] = False\n\n# pandas setting\npd.set_option('display.max_rows', None)\npd.set_option('display.max_columns', None)","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:19:54.214052Z","iopub.execute_input":"2022-05-27T10:19:54.214617Z","iopub.status.idle":"2022-05-27T10:19:54.222615Z","shell.execute_reply.started":"2022-05-27T10:19:54.214571Z","shell.execute_reply":"2022-05-27T10:19:54.221327Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\ntrain = pd.read_feather('../input/amexfeather/train_data.ftr')\n#test = pd.read_feather('../input/amexfeather/test_data.ftr')\n#sample_submission = pd.read_csv('../input/amex-default-prediction/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:19:54.636288Z","iopub.execute_input":"2022-05-27T10:19:54.637117Z","iopub.status.idle":"2022-05-27T10:20:13.173618Z","shell.execute_reply.started":"2022-05-27T10:19:54.637078Z","shell.execute_reply":"2022-05-27T10:20:13.172452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.shape)\n#print(test.shape)\n\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:20:13.175112Z","iopub.execute_input":"2022-05-27T10:20:13.175453Z","iopub.status.idle":"2022-05-27T10:20:13.343790Z","shell.execute_reply.started":"2022-05-27T10:20:13.175421Z","shell.execute_reply":"2022-05-27T10:20:13.342744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = train.loc[:, 'P_2':'D_145'].describe()","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:25:07.032410Z","iopub.execute_input":"2022-05-27T10:25:07.032915Z","iopub.status.idle":"2022-05-27T10:27:59.668285Z","shell.execute_reply.started":"2022-05-27T10:25:07.032877Z","shell.execute_reply":"2022-05-27T10:27:59.665873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x= x.T","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:29:13.574591Z","iopub.execute_input":"2022-05-27T10:29:13.575234Z","iopub.status.idle":"2022-05-27T10:29:13.580960Z","shell.execute_reply.started":"2022-05-27T10:29:13.575199Z","shell.execute_reply":"2022-05-27T10:29:13.579934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mean = []\nstd = []\nfor col in train.columns: #included target column in the string , so we will only consider mean[:-1] for our consideration\n    if 'int' in str(train[col].dtypes) or 'float' in str(train[col].dtypes):\n        #used .astype('float64') to avoid memory overflow and getting 'inf' as mean\n        mean.append(np.nanmean(train[col].astype('float64'), axis = 0))\n        std.append(np.nanstd(train[col].astype('float64'), axis = 0))","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:30:14.708151Z","iopub.execute_input":"2022-05-27T10:30:14.708604Z","iopub.status.idle":"2022-05-27T10:30:40.701640Z","shell.execute_reply.started":"2022-05-27T10:30:14.708573Z","shell.execute_reply":"2022-05-27T10:30:40.700761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x['mean'] = mean[:-1]\nx['std'] = std[:-1]","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:31:15.220183Z","iopub.execute_input":"2022-05-27T10:31:15.220554Z","iopub.status.idle":"2022-05-27T10:31:15.226179Z","shell.execute_reply.started":"2022-05-27T10:31:15.220525Z","shell.execute_reply":"2022-05-27T10:31:15.225527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import gc\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:31:23.109436Z","iopub.execute_input":"2022-05-27T10:31:23.110459Z","iopub.status.idle":"2022-05-27T10:31:23.460823Z","shell.execute_reply.started":"2022-05-27T10:31:23.110421Z","shell.execute_reply":"2022-05-27T10:31:23.459728Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x.style.bar(subset=['mean'], color='#205ff2')\\\n                            .background_gradient(subset=['std'], cmap='Reds')\\\n                            .background_gradient(subset=['50%'], cmap='coolwarm')","metadata":{"execution":{"iopub.status.busy":"2022-05-27T10:31:40.988300Z","iopub.execute_input":"2022-05-27T10:31:40.988708Z","iopub.status.idle":"2022-05-27T10:31:41.071877Z","shell.execute_reply.started":"2022-05-27T10:31:40.988678Z","shell.execute_reply":"2022-05-27T10:31:41.071243Z"},"trusted":true},"execution_count":null,"outputs":[]}]}