{"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":"markdown","source":"## 📋 Table of Contents\n* [Train Data - Events](#train_1)\n* [Train Data](#train_2)\n* [Test Data](#test)","metadata":{}},{"cell_type":"code","source":"# packages\n\n# standard\nimport numpy as np\nimport pandas as pd\nimport time\n\n# plots\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# other stuff\nimport gc","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-09-10T19:23:55.825735Z","iopub.execute_input":"2023-09-10T19:23:55.826166Z","iopub.status.idle":"2023-09-10T19:23:57.655637Z","shell.execute_reply.started":"2023-09-10T19:23:55.826098Z","shell.execute_reply":"2023-09-10T19:23:57.654282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# config\ndefault_color_1 = 'darkblue'\ndefault_color_2 = 'darkgreen'\ndefault_color_3 = 'darkred'\n\npd.set_option('display.max_columns', None)","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:15:33.153272Z","iopub.execute_input":"2023-09-10T19:15:33.154176Z","iopub.status.idle":"2023-09-10T19:15:33.160004Z","shell.execute_reply.started":"2023-09-10T19:15:33.154133Z","shell.execute_reply":"2023-09-10T19:15:33.158537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# show files\n!ls -l '../input/child-mind-institute-detect-sleep-states'","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:15:33.161582Z","iopub.execute_input":"2023-09-10T19:15:33.162280Z","iopub.status.idle":"2023-09-10T19:15:34.221509Z","shell.execute_reply.started":"2023-09-10T19:15:33.162244Z","shell.execute_reply":"2023-09-10T19:15:34.220352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load csv data\ndf_train_events = pd.read_csv('../input/child-mind-institute-detect-sleep-states/train_events.csv')","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:15:34.223898Z","iopub.execute_input":"2023-09-10T19:15:34.224272Z","iopub.status.idle":"2023-09-10T19:15:34.270800Z","shell.execute_reply.started":"2023-09-10T19:15:34.224238Z","shell.execute_reply":"2023-09-10T19:15:34.269733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# load parquet data\nt1 = time.time()\ndf_train = pd.read_parquet('../input/child-mind-institute-detect-sleep-states/train_series.parquet')\ndf_test = pd.read_parquet('../input/child-mind-institute-detect-sleep-states/test_series.parquet')\nt2 = time.time()\nprint('Elapsed time [s]:', np.round(t2-t1,4))","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:15:34.272193Z","iopub.execute_input":"2023-09-10T19:15:34.272637Z","iopub.status.idle":"2023-09-10T19:16:25.769954Z","shell.execute_reply.started":"2023-09-10T19:15:34.272599Z","shell.execute_reply":"2023-09-10T19:16:25.768872Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='train_1'></a>\n# Train Data - Events","metadata":{}},{"cell_type":"code","source":"# overview\ndf_train_events.info()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:16:25.771942Z","iopub.execute_input":"2023-09-10T19:16:25.773325Z","iopub.status.idle":"2023-09-10T19:16:25.795893Z","shell.execute_reply.started":"2023-09-10T19:16:25.773295Z","shell.execute_reply":"2023-09-10T19:16:25.794945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview\ndf_train_events.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:16:25.797145Z","iopub.execute_input":"2023-09-10T19:16:25.797633Z","iopub.status.idle":"2023-09-10T19:16:25.816873Z","shell.execute_reply.started":"2023-09-10T19:16:25.797607Z","shell.execute_reply":"2023-09-10T19:16:25.815766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# basic stats\ndf_train_events.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:16:25.818253Z","iopub.execute_input":"2023-09-10T19:16:25.818737Z","iopub.status.idle":"2023-09-10T19:16:25.855072Z","shell.execute_reply.started":"2023-09-10T19:16:25.818700Z","shell.execute_reply":"2023-09-10T19:16:25.853870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# distribution of events\ndf_train_events.event.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:19:11.122051Z","iopub.execute_input":"2023-09-10T19:19:11.122758Z","iopub.status.idle":"2023-09-10T19:19:11.132898Z","shell.execute_reply.started":"2023-09-10T19:19:11.122714Z","shell.execute_reply":"2023-09-10T19:19:11.131510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='train_2'></a>\n# Train Data","metadata":{}},{"cell_type":"code","source":"# train data overview\ndf_train.info(show_counts=True)","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:16:25.856671Z","iopub.execute_input":"2023-09-10T19:16:25.856957Z","iopub.status.idle":"2023-09-10T19:16:38.215462Z","shell.execute_reply.started":"2023-09-10T19:16:25.856933Z","shell.execute_reply":"2023-09-10T19:16:38.214433Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# preview\ndf_train.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:16:38.219990Z","iopub.execute_input":"2023-09-10T19:16:38.220360Z","iopub.status.idle":"2023-09-10T19:16:38.233443Z","shell.execute_reply.started":"2023-09-10T19:16:38.220326Z","shell.execute_reply":"2023-09-10T19:16:38.232307Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# basic stats\ndf_train.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:16:38.235206Z","iopub.execute_input":"2023-09-10T19:16:38.236001Z","iopub.status.idle":"2023-09-10T19:18:12.365646Z","shell.execute_reply.started":"2023-09-10T19:16:38.235963Z","shell.execute_reply":"2023-09-10T19:18:12.364503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot angle feature\ndf_train.anglez.plot(kind='hist', bins=100,\n                     color=default_color_1)\nplt.title('anglez')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:18:12.366852Z","iopub.execute_input":"2023-09-10T19:18:12.367175Z","iopub.status.idle":"2023-09-10T19:18:24.539797Z","shell.execute_reply.started":"2023-09-10T19:18:12.367149Z","shell.execute_reply":"2023-09-10T19:18:24.538784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot enmo feature\ndf_train.enmo.plot(kind='hist', bins=100,\n                   color=default_color_1)\nplt.title('enmo')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:18:24.541275Z","iopub.execute_input":"2023-09-10T19:18:24.541922Z","iopub.status.idle":"2023-09-10T19:18:34.940481Z","shell.execute_reply.started":"2023-09-10T19:18:24.541883Z","shell.execute_reply":"2023-09-10T19:18:34.939687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot enmo feature - boxplot\nplt.figure(figsize=(10,1))\ndf_train.enmo.plot(kind='box', vert=False)\nplt.title('enmo')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:18:34.941583Z","iopub.execute_input":"2023-09-10T19:18:34.942130Z","iopub.status.idle":"2023-09-10T19:18:53.507232Z","shell.execute_reply.started":"2023-09-10T19:18:34.942081Z","shell.execute_reply":"2023-09-10T19:18:53.506031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# plot enmo feature - log scale\ndf_train['enmo_log'] = np.log10(0.001+df_train.enmo)\ndf_train.enmo_log.plot(kind='hist', bins=100,\n                       color=default_color_1)\nplt.title('enmo - log trafo')\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:20:20.146346Z","iopub.execute_input":"2023-09-10T19:20:20.147519Z","iopub.status.idle":"2023-09-10T19:20:34.858064Z","shell.execute_reply.started":"2023-09-10T19:20:20.147469Z","shell.execute_reply":"2023-09-10T19:20:34.856925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gc.collect();","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:24:16.224656Z","iopub.execute_input":"2023-09-10T19:24:16.225029Z","iopub.status.idle":"2023-09-10T19:24:16.314983Z","shell.execute_reply.started":"2023-09-10T19:24:16.224998Z","shell.execute_reply":"2023-09-10T19:24:16.313856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# scatter plot\nsns.jointplot(data=df_train,\n             x='anglez',\n             y='enmo_log',\n             kind='hist',\n             color=default_color_1)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:21:23.467747Z","iopub.execute_input":"2023-09-10T19:21:23.468220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id='test'></a>\n# Test Data","metadata":{}},{"cell_type":"code","source":"# test set overview\ndf_test.info(show_counts=True)","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:19:09.279613Z","iopub.status.idle":"2023-09-10T19:19:09.280237Z","shell.execute_reply.started":"2023-09-10T19:19:09.280018Z","shell.execute_reply":"2023-09-10T19:19:09.280037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# basic stats\ndf_test.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2023-09-10T19:19:09.281778Z","iopub.status.idle":"2023-09-10T19:19:09.282293Z","shell.execute_reply.started":"2023-09-10T19:19:09.282024Z","shell.execute_reply":"2023-09-10T19:19:09.282048Z"},"trusted":true},"execution_count":null,"outputs":[]}]}