{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"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)\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\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","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport scipy.stats as stats\nimport warnings\nwarnings.filterwarnings('ignore')\npd.options.display.max_columns=None","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:02.982712Z","iopub.execute_input":"2023-02-27T07:02:02.983351Z","iopub.status.idle":"2023-02-27T07:02:03.487789Z","shell.execute_reply.started":"2023-02-27T07:02:02.9833Z","shell.execute_reply":"2023-02-27T07:02:03.486232Z"},"trusted":true},"execution_count":1,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/otto-recommender-system/sample_submission.csv')\ndf.head()\n","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:03.494274Z","iopub.execute_input":"2023-02-27T07:02:03.494753Z","iopub.status.idle":"2023-02-27T07:02:08.179726Z","shell.execute_reply.started":"2023-02-27T07:02:03.494707Z","shell.execute_reply":"2023-02-27T07:02:08.178203Z"},"trusted":true},"execution_count":2,"outputs":[{"execution_count":2,"output_type":"execute_result","data":{"text/plain":"      session_type                labels\n0  12899779_clicks  129004 126836 118524\n1   12899779_carts  129004 126836 118524\n2  12899779_orders  129004 126836 118524\n3  12899780_clicks  129004 126836 118524\n4   12899780_carts  129004 126836 118524","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>session_type</th>\n      <th>labels</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>12899779_clicks</td>\n      <td>129004 126836 118524</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>12899779_carts</td>\n      <td>129004 126836 118524</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>12899779_orders</td>\n      <td>129004 126836 118524</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>12899780_clicks</td>\n      <td>129004 126836 118524</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>12899780_carts</td>\n      <td>129004 126836 118524</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:08.181455Z","iopub.execute_input":"2023-02-27T07:02:08.181832Z","iopub.status.idle":"2023-02-27T07:02:08.196367Z","shell.execute_reply.started":"2023-02-27T07:02:08.181795Z","shell.execute_reply":"2023-02-27T07:02:08.194931Z"},"trusted":true},"execution_count":3,"outputs":[{"name":"stdout","text":"<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 5015409 entries, 0 to 5015408\nData columns (total 2 columns):\n #   Column        Dtype \n---  ------        ----- \n 0   session_type  object\n 1   labels        object\ndtypes: object(2)\nmemory usage: 76.5+ MB\n","output_type":"stream"}]},{"cell_type":"code","source":"df.dtypes","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:08.199905Z","iopub.execute_input":"2023-02-27T07:02:08.200442Z","iopub.status.idle":"2023-02-27T07:02:08.212971Z","shell.execute_reply.started":"2023-02-27T07:02:08.200381Z","shell.execute_reply":"2023-02-27T07:02:08.211429Z"},"trusted":true},"execution_count":4,"outputs":[{"execution_count":4,"output_type":"execute_result","data":{"text/plain":"session_type    object\nlabels          object\ndtype: object"},"metadata":{}}]},{"cell_type":"code","source":"\ndf.corr","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:08.214443Z","iopub.execute_input":"2023-02-27T07:02:08.214928Z","iopub.status.idle":"2023-02-27T07:02:08.231525Z","shell.execute_reply.started":"2023-02-27T07:02:08.214864Z","shell.execute_reply":"2023-02-27T07:02:08.230316Z"},"trusted":true},"execution_count":5,"outputs":[{"execution_count":5,"output_type":"execute_result","data":{"text/plain":"<bound method DataFrame.corr of             session_type                labels\n0        12899779_clicks  129004 126836 118524\n1         12899779_carts  129004 126836 118524\n2        12899779_orders  129004 126836 118524\n3        12899780_clicks  129004 126836 118524\n4         12899780_carts  129004 126836 118524\n...                  ...                   ...\n5015404   14571580_carts  129004 126836 118524\n5015405  14571580_orders  129004 126836 118524\n5015406  14571581_clicks  129004 126836 118524\n5015407   14571581_carts  129004 126836 118524\n5015408  14571581_orders  129004 126836 118524\n\n[5015409 rows x 2 columns]>"},"metadata":{}}]},{"cell_type":"code","source":"df.describe().T","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:08.232713Z","iopub.execute_input":"2023-02-27T07:02:08.233137Z","iopub.status.idle":"2023-02-27T07:02:15.468945Z","shell.execute_reply.started":"2023-02-27T07:02:08.233099Z","shell.execute_reply":"2023-02-27T07:02:15.467436Z"},"trusted":true},"execution_count":6,"outputs":[{"execution_count":6,"output_type":"execute_result","data":{"text/plain":"                count   unique                   top     freq\nsession_type  5015409  5015409       12899779_clicks        1\nlabels        5015409        1  129004 126836 118524  5015409","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>count</th>\n      <th>unique</th>\n      <th>top</th>\n      <th>freq</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>session_type</th>\n      <td>5015409</td>\n      <td>5015409</td>\n      <td>12899779_clicks</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>labels</th>\n      <td>5015409</td>\n      <td>1</td>\n      <td>129004 126836 118524</td>\n      <td>5015409</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:15.470727Z","iopub.execute_input":"2023-02-27T07:02:15.471918Z","iopub.status.idle":"2023-02-27T07:02:15.480256Z","shell.execute_reply.started":"2023-02-27T07:02:15.47186Z","shell.execute_reply":"2023-02-27T07:02:15.478856Z"},"trusted":true},"execution_count":7,"outputs":[{"execution_count":7,"output_type":"execute_result","data":{"text/plain":"(5015409, 2)"},"metadata":{}}]},{"cell_type":"code","source":"Q1 = df.quantile (0.25)\nQ2 = df.quantile (0.5)\nQ3 = df.quantile (0.75)\nIQR = Q3-Q1\nprint(IQR)","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:24.965752Z","iopub.execute_input":"2023-02-27T07:02:24.967156Z","iopub.status.idle":"2023-02-27T07:02:24.979763Z","shell.execute_reply.started":"2023-02-27T07:02:24.967092Z","shell.execute_reply":"2023-02-27T07:02:24.97827Z"},"trusted":true},"execution_count":9,"outputs":[{"name":"stdout","text":"Series([], dtype: float64)\n","output_type":"stream"}]},{"cell_type":"code","source":"UL = Q3+(1.5*IQR)\nLL = Q1-(1.5*IQR)","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:02:31.673448Z","iopub.execute_input":"2023-02-27T07:02:31.673916Z","iopub.status.idle":"2023-02-27T07:02:31.680329Z","shell.execute_reply.started":"2023-02-27T07:02:31.673875Z","shell.execute_reply":"2023-02-27T07:02:31.679131Z"},"trusted":true},"execution_count":10,"outputs":[]},{"cell_type":"code","source":"df_new = df[~((df<LL) | (df>UL)).any(axis=1)]","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:05:18.654744Z","iopub.execute_input":"2023-02-27T07:05:18.65539Z","iopub.status.idle":"2023-02-27T07:05:21.144761Z","shell.execute_reply.started":"2023-02-27T07:05:18.655328Z","shell.execute_reply":"2023-02-27T07:05:21.143255Z"},"trusted":true},"execution_count":15,"outputs":[]},{"cell_type":"code","source":"df_new.shape","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:07:41.706591Z","iopub.execute_input":"2023-02-27T07:07:41.707078Z","iopub.status.idle":"2023-02-27T07:07:41.716304Z","shell.execute_reply.started":"2023-02-27T07:07:41.707027Z","shell.execute_reply":"2023-02-27T07:07:41.714787Z"},"trusted":true},"execution_count":16,"outputs":[{"execution_count":16,"output_type":"execute_result","data":{"text/plain":"(5015409, 2)"},"metadata":{}}]},{"cell_type":"code","source":"df.value_counts('labels')","metadata":{"execution":{"iopub.status.busy":"2023-02-27T07:10:56.316732Z","iopub.execute_input":"2023-02-27T07:10:56.317578Z","iopub.status.idle":"2023-02-27T07:10:56.794932Z","shell.execute_reply.started":"2023-02-27T07:10:56.317525Z","shell.execute_reply":"2023-02-27T07:10:56.7936Z"},"trusted":true},"execution_count":22,"outputs":[{"execution_count":22,"output_type":"execute_result","data":{"text/plain":"labels\n129004 126836 118524    5015409\ndtype: int64"},"metadata":{}}]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2023-02-27T08:48:14.110114Z","iopub.execute_input":"2023-02-27T08:48:14.110528Z","iopub.status.idle":"2023-02-27T08:48:14.214806Z","shell.execute_reply.started":"2023-02-27T08:48:14.110494Z","shell.execute_reply":"2023-02-27T08:48:14.213067Z"},"trusted":true},"execution_count":1,"outputs":[{"traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)","\u001b[0;32m/tmp/ipykernel_27/964094849.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m","\u001b[0;31mNameError\u001b[0m: name 'df' is not defined"],"ename":"NameError","evalue":"name 'df' is not defined","output_type":"error"}]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}