{"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":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.model_selection import train_test_split\n\nfrom fastai.tabular.core import cont_cat_split\n\nfrom yellowbrick.classifier import confusion_matrix\nfrom yellowbrick.classifier.rocauc import roc_auc# 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\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":"2023-01-09T10:50:10.510404Z","iopub.execute_input":"2023-01-09T10:50:10.511293Z","iopub.status.idle":"2023-01-09T10:50:14.128821Z","shell.execute_reply.started":"2023-01-09T10:50:10.511189Z","shell.execute_reply":"2023-01-09T10:50:14.127576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\npd.reset_option('display.max_colwidth', None)\n\ntrain = pd.read_csv('/kaggle/input/emsi-5iir-ds/train.csv')\ntest = pd.read_csv('/kaggle/input/emsi-5iir-ds/test.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T10:50:14.130998Z","iopub.execute_input":"2023-01-09T10:50:14.131629Z","iopub.status.idle":"2023-01-09T10:50:32.537146Z","shell.execute_reply.started":"2023-01-09T10:50:14.131587Z","shell.execute_reply":"2023-01-09T10:50:32.535863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T10:50:32.539379Z","iopub.execute_input":"2023-01-09T10:50:32.539931Z","iopub.status.idle":"2023-01-09T10:50:32.586295Z","shell.execute_reply.started":"2023-01-09T10:50:32.539880Z","shell.execute_reply":"2023-01-09T10:50:32.585395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import seaborn as sns\nimport matplotlib.pyplot as plt\n\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.model_selection import train_test_split\n\nfrom fastai.tabular.core import cont_cat_split\n\nfrom yellowbrick.classifier import confusion_matrix\nfrom yellowbrick.classifier.rocauc import roc_auc","metadata":{"execution":{"iopub.status.busy":"2023-01-09T10:50:32.588676Z","iopub.execute_input":"2023-01-09T10:50:32.589902Z","iopub.status.idle":"2023-01-09T10:50:32.598995Z","shell.execute_reply.started":"2023-01-09T10:50:32.589857Z","shell.execute_reply":"2023-01-09T10:50:32.597589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def basic_info(df:pd.DataFrame):\n    s = \"\"\n    count = 1\n    for c in df.columns:\n        s+= f\"{count} - {c}\\n\"\n        s+= f\"    No. of unique values {df[c].nunique()}\\n\"\n        s+= f\"    Sample of unique values {df[c].unique()[0:10]}\\n\"\n        s+= \"\\n\"\n        count += 1\n    return s\ndef expand_feature_27(data):\n    # This function was adapted from the following notebooks:\n    # https://www.kaggle.com/code/paultimothymooney/getting-started-with-tensorflow-decision-forests\n    for df in [data]:\n        # Extract the 10 letters of f_27 into individual features\n        for i in range(10):   # defines a number from 0 to 25 for each letter, for example if ch1 is A then get 0 and so on\n            df[f'ch{i}'] = df.f_27.str.get(i).apply(ord) - ord('A')\n    return data","metadata":{"execution":{"iopub.status.busy":"2023-01-09T10:50:32.605047Z","iopub.execute_input":"2023-01-09T10:50:32.605417Z","iopub.status.idle":"2023-01-09T10:50:32.614060Z","shell.execute_reply.started":"2023-01-09T10:50:32.605384Z","shell.execute_reply":"2023-01-09T10:50:32.612655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# loading the data into a pandas DataFrame (for exploratory analysis)\ntrain_df = pd.read_csv('/kaggle/input/emsi-5iir-ds/train.csv')    # reading training file\ntest_df = pd.read_csv('/kaggle/input/emsi-5iir-ds/test.csv')    # reading test file\ntrain_df.shape    # viewing dataframe dimension","metadata":{"execution":{"iopub.status.busy":"2023-01-09T10:50:32.615713Z","iopub.execute_input":"2023-01-09T10:50:32.616754Z","iopub.status.idle":"2023-01-09T10:50:42.090386Z","shell.execute_reply.started":"2023-01-09T10:50:32.616714Z","shell.execute_reply":"2023-01-09T10:50:42.089118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.head()    # viewing some examples","metadata":{"execution":{"iopub.status.busy":"2023-01-09T10:50:42.091974Z","iopub.execute_input":"2023-01-09T10:50:42.092844Z","iopub.status.idle":"2023-01-09T10:50:42.116480Z","shell.execute_reply.started":"2023-01-09T10:50:42.092800Z","shell.execute_reply":"2023-01-09T10:50:42.115636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.info()    # information about the data, number of non-null (non-missing) values and the data type","metadata":{"execution":{"iopub.status.busy":"2023-01-09T10:50:42.117513Z","iopub.execute_input":"2023-01-09T10:50:42.118037Z","iopub.status.idle":"2023-01-09T10:50:42.241740Z","shell.execute_reply.started":"2023-01-09T10:50:42.118006Z","shell.execute_reply":"2023-01-09T10:50:42.240401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}