{"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":"# 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)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\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\n\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":"2022-08-09T07:09:34.481465Z","iopub.execute_input":"2022-08-09T07:09:34.482024Z","iopub.status.idle":"2022-08-09T07:09:34.492229Z","shell.execute_reply.started":"2022-08-09T07:09:34.481970Z","shell.execute_reply":"2022-08-09T07:09:34.491243Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_csv('/kaggle/input/tabular-playground-series-aug-2022/train.csv')\nda=pd.read_csv('/kaggle/input/tabular-playground-series-aug-2022/test.csv')\ndf.set_index('id', inplace=True)\nda.set_index('id', inplace=True)\ndf.head().T# Transposing the head to visualize more of the dataset","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:34.628622Z","iopub.execute_input":"2022-08-09T07:09:34.629054Z","iopub.status.idle":"2022-08-09T07:09:34.824035Z","shell.execute_reply.started":"2022-08-09T07:09:34.629019Z","shell.execute_reply":"2022-08-09T07:09:34.822422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Transposing the head to visualize more of the dataset\nda.head().T","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:34.827188Z","iopub.execute_input":"2022-08-09T07:09:34.828752Z","iopub.status.idle":"2022-08-09T07:09:34.850451Z","shell.execute_reply.started":"2022-08-09T07:09:34.828674Z","shell.execute_reply":"2022-08-09T07:09:34.848863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Visualize the missing variable \nfig, ax = plt.subplots(1, 2, figsize=(16, 8), sharex=True, sharey=True)\nsns.histplot(\n    data=df.drop('failure', axis=1).isnull().melt(value_name=\"missing\"),\n    y=\"variable\",\n    hue=\"missing\",\n    multiple=\"fill\",\n    ax=ax[0]\n);\n\nsns.histplot(\n    data=da.isnull().melt(value_name=\"missing\"),\n    y=\"variable\",\n    hue=\"missing\",\n    multiple=\"fill\",\n    ax=ax[1]\n);\n\nplt.tight_layout()\nplt.draw()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:34.851918Z","iopub.execute_input":"2022-08-09T07:09:34.852519Z","iopub.status.idle":"2022-08-09T07:09:37.440853Z","shell.execute_reply.started":"2022-08-09T07:09:34.852484Z","shell.execute_reply":"2022-08-09T07:09:37.439330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Explore more detail information from the dataframe\nda.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.443541Z","iopub.execute_input":"2022-08-09T07:09:37.444841Z","iopub.status.idle":"2022-08-09T07:09:37.453885Z","shell.execute_reply.started":"2022-08-09T07:09:37.444791Z","shell.execute_reply":"2022-08-09T07:09:37.451993Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Explore more detail information from the dataframe\ndf.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.455547Z","iopub.execute_input":"2022-08-09T07:09:37.455983Z","iopub.status.idle":"2022-08-09T07:09:37.468607Z","shell.execute_reply.started":"2022-08-09T07:09:37.455948Z","shell.execute_reply":"2022-08-09T07:09:37.466776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Explore more detail information from the dataframe\nda.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.470510Z","iopub.execute_input":"2022-08-09T07:09:37.471224Z","iopub.status.idle":"2022-08-09T07:09:37.587393Z","shell.execute_reply.started":"2022-08-09T07:09:37.471061Z","shell.execute_reply":"2022-08-09T07:09:37.585869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Target distribution\ndf['failure'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.589041Z","iopub.execute_input":"2022-08-09T07:09:37.589755Z","iopub.status.idle":"2022-08-09T07:09:37.598622Z","shell.execute_reply.started":"2022-08-09T07:09:37.589717Z","shell.execute_reply":"2022-08-09T07:09:37.597561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Review the unique the quantity of values -- Train\ndf.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.601620Z","iopub.execute_input":"2022-08-09T07:09:37.602104Z","iopub.status.idle":"2022-08-09T07:09:37.640472Z","shell.execute_reply.started":"2022-08-09T07:09:37.602044Z","shell.execute_reply":"2022-08-09T07:09:37.639047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Review the unique the quantity of values -- Test\nda.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.641780Z","iopub.execute_input":"2022-08-09T07:09:37.643051Z","iopub.status.idle":"2022-08-09T07:09:37.672268Z","shell.execute_reply.started":"2022-08-09T07:09:37.643005Z","shell.execute_reply":"2022-08-09T07:09:37.670758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Review the product codes for the test dataset\ndf['product_code'].sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.674486Z","iopub.execute_input":"2022-08-09T07:09:37.675051Z","iopub.status.idle":"2022-08-09T07:09:37.687463Z","shell.execute_reply.started":"2022-08-09T07:09:37.675000Z","shell.execute_reply":"2022-08-09T07:09:37.685844Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Review the amount of empty in the dataframe\nda.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.689191Z","iopub.execute_input":"2022-08-09T07:09:37.690036Z","iopub.status.idle":"2022-08-09T07:09:37.707317Z","shell.execute_reply.started":"2022-08-09T07:09:37.689930Z","shell.execute_reply":"2022-08-09T07:09:37.706043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Try to find more information about the empty values\nda[da['loading'].isnull()]","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:37.709038Z","iopub.execute_input":"2022-08-09T07:09:37.709910Z","iopub.status.idle":"2022-08-09T07:09:37.753834Z","shell.execute_reply.started":"2022-08-09T07:09:37.709859Z","shell.execute_reply":"2022-08-09T07:09:37.752516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# ....\nprint(da['attribute_0'].unique())\nprint(da['attribute_1'].unique())\nprint(da['attribute_2'].unique())\nprint(da['attribute_3'].unique())","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:11:53.377704Z","iopub.execute_input":"2022-08-09T07:11:53.378282Z","iopub.status.idle":"2022-08-09T07:11:53.390952Z","shell.execute_reply.started":"2022-08-09T07:11:53.378242Z","shell.execute_reply":"2022-08-09T07:11:53.389774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"summary = da.groupby(['attribute_0', 'attribute_1', 'attribute_2'])['attribute_3'].mean().reset_index()\nsummary.head(100)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:12:21.281145Z","iopub.execute_input":"2022-08-09T07:12:21.281643Z","iopub.status.idle":"2022-08-09T07:12:21.309569Z","shell.execute_reply.started":"2022-08-09T07:12:21.281606Z","shell.execute_reply":"2022-08-09T07:12:21.308357Z"},"trusted":true},"execution_count":null,"outputs":[]}]}