{"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 matplotlib.pyplot as plt\nimport pandas as pd","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:47.875181Z","iopub.execute_input":"2022-06-07T17:09:47.875643Z","iopub.status.idle":"2022-06-07T17:09:47.886497Z","shell.execute_reply.started":"2022-06-07T17:09:47.875548Z","shell.execute_reply":"2022-06-07T17:09:47.885304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv('../input/amex-default-prediction/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:48.622104Z","iopub.execute_input":"2022-06-07T17:09:48.623186Z","iopub.status.idle":"2022-06-07T17:09:49.882174Z","shell.execute_reply.started":"2022-06-07T17:09:48.623121Z","shell.execute_reply":"2022-06-07T17:09:49.881392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:49.884492Z","iopub.execute_input":"2022-06-07T17:09:49.884962Z","iopub.status.idle":"2022-06-07T17:09:49.900586Z","shell.execute_reply.started":"2022-06-07T17:09:49.884913Z","shell.execute_reply":"2022-06-07T17:09:49.899615Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.columns","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:49.920242Z","iopub.execute_input":"2022-06-07T17:09:49.920672Z","iopub.status.idle":"2022-06-07T17:09:49.926541Z","shell.execute_reply.started":"2022-06-07T17:09:49.920638Z","shell.execute_reply":"2022-06-07T17:09:49.925678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.describe()","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:50.745025Z","iopub.execute_input":"2022-06-07T17:09:50.745679Z","iopub.status.idle":"2022-06-07T17:09:50.792717Z","shell.execute_reply.started":"2022-06-07T17:09:50.745639Z","shell.execute_reply":"2022-06-07T17:09:50.791741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:51.36096Z","iopub.execute_input":"2022-06-07T17:09:51.361376Z","iopub.status.idle":"2022-06-07T17:09:51.368662Z","shell.execute_reply.started":"2022-06-07T17:09:51.361344Z","shell.execute_reply":"2022-06-07T17:09:51.367722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.info()","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:51.88798Z","iopub.execute_input":"2022-06-07T17:09:51.88854Z","iopub.status.idle":"2022-06-07T17:09:51.950437Z","shell.execute_reply.started":"2022-06-07T17:09:51.8885Z","shell.execute_reply":"2022-06-07T17:09:51.949392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"na_cols = data.isna().any()\nna_cols = na_cols[na_cols == True].reset_index()\nna_cols = na_cols[\"index\"].tolist()\nfor col in data.columns[1:]:\n     if col in na_cols:\n        if data[col].dtype != 'object':\n             data[col] =  data[col].fillna(data[col].mean()).round(0)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:52.681275Z","iopub.execute_input":"2022-06-07T17:09:52.681683Z","iopub.status.idle":"2022-06-07T17:09:52.739717Z","shell.execute_reply.started":"2022-06-07T17:09:52.681649Z","shell.execute_reply":"2022-06-07T17:09:52.73878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isnull().any()","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:53.462994Z","iopub.execute_input":"2022-06-07T17:09:53.463716Z","iopub.status.idle":"2022-06-07T17:09:53.517585Z","shell.execute_reply.started":"2022-06-07T17:09:53.463676Z","shell.execute_reply":"2022-06-07T17:09:53.51681Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder, OneHotEncoder\n","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:54.175115Z","iopub.execute_input":"2022-06-07T17:09:54.176335Z","iopub.status.idle":"2022-06-07T17:09:54.635801Z","shell.execute_reply.started":"2022-06-07T17:09:54.176285Z","shell.execute_reply":"2022-06-07T17:09:54.63479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le = LabelEncoder()","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:54.82013Z","iopub.execute_input":"2022-06-07T17:09:54.820526Z","iopub.status.idle":"2022-06-07T17:09:54.824771Z","shell.execute_reply.started":"2022-06-07T17:09:54.820497Z","shell.execute_reply":"2022-06-07T17:09:54.823856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"values=[]\nle_count = 0\nfor col in data.columns[1:]:\n    if data[col].dtype == 'object':\n        if len(list(data[col].unique())) <= 2:\n            le.fit(data[col])\n            data[col] = le.transform(data[col])\n            le_count += 1\nprint('{} columns were label encoded.'.format(le_count))","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:55.381291Z","iopub.execute_input":"2022-06-07T17:09:55.381966Z","iopub.status.idle":"2022-06-07T17:09:55.388975Z","shell.execute_reply.started":"2022-06-07T17:09:55.381925Z","shell.execute_reply":"2022-06-07T17:09:55.388116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(15, 12))\nplt.suptitle('Amex Prediction\\n',horizontalalignment=\"center\",fontstyle = \"normal\", fontsize = 24, fontfamily = \"sans-serif\")\nfor i in range(data.shape[1]):\n    plt.subplot(6, 3, i + 1)\n    f = plt.gca()\n    f.set_title(data.columns.values[i])\nvals = np.size(data.iloc[:, i].unique())\nif vals >= 100:\n        vals = 100\n    \nplt.hist(data.iloc[:, i], bins=vals, color = '#93E2EB')\nplt.tight_layout(rect=[0, 0.03, 1, 0.95])","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:09:56.500722Z","iopub.execute_input":"2022-06-07T17:09:56.501598Z","iopub.status.idle":"2022-06-07T17:09:56.85793Z","shell.execute_reply.started":"2022-06-07T17:09:56.501553Z","shell.execute_reply":"2022-06-07T17:09:56.856686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-06-07T17:13:33.770133Z","iopub.execute_input":"2022-06-07T17:13:33.770524Z","iopub.status.idle":"2022-06-07T17:13:35.768372Z","shell.execute_reply.started":"2022-06-07T17:13:33.770495Z","shell.execute_reply":"2022-06-07T17:13:35.767157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}