{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":102335,"databundleVersionId":12518947,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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":{"iopub.status.busy":"2025-10-11T02:25:43.482709Z","iopub.execute_input":"2025-10-11T02:25:43.483354Z","iopub.status.idle":"2025-10-11T02:25:43.824928Z","shell.execute_reply.started":"2025-10-11T02:25:43.483330Z","shell.execute_reply":"2025-10-11T02:25:43.824161Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# CMI - Detect Behavior With Sensor Data","metadata":{}},{"cell_type":"markdown","source":"## Importing libraries","metadata":{}},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nimport math\nimport random\nimport matplotlib.pyplot as plt\nimport tensorflow as tf\nfrom datetime import datetime\nimport seaborn as sns\nimport gc\nimport warnings\nfrom itertools import groupby\nimport category_encoders as ce\nfrom sklearn.preprocessing import LabelEncoder","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:25:43.826688Z","iopub.execute_input":"2025-10-11T02:25:43.827083Z","iopub.status.idle":"2025-10-11T02:26:02.611374Z","shell.execute_reply.started":"2025-10-11T02:25:43.827061Z","shell.execute_reply":"2025-10-11T02:26:02.610632Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Setting timer","metadata":{}},{"cell_type":"code","source":"def timer(start_time):\n    if not start_time:\n        start_time = datetime.now()\n        return start_time\n    elif start_time:\n        thour, temp_sec = divmod((datetime.now() - start_time).total_seconds(), 3600)\n        tmin, tsec = divmod(temp_sec, 60)\n        print('Time taken: %i hours, %i minutes and %i seconds' %(thour, tmin, round(tsec, 2)))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:02.612189Z","iopub.execute_input":"2025-10-11T02:26:02.612675Z","iopub.status.idle":"2025-10-11T02:26:02.618067Z","shell.execute_reply.started":"2025-10-11T02:26:02.612653Z","shell.execute_reply":"2025-10-11T02:26:02.617141Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Setting GPU","metadata":{}},{"cell_type":"code","source":"device_name = tf.test.gpu_device_name()\n\nif \"GPU\" not in device_name:\n    print(\"GPU device not found\")\nprint(\"GPU device found at {}:\".format(device_name))\nprint(\"GPU\", \"available\" if tf.config.list_physical_devices(\"GPU\") else \"not available\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:02.619125Z","iopub.execute_input":"2025-10-11T02:26:02.619448Z","iopub.status.idle":"2025-10-11T02:26:02.780280Z","shell.execute_reply.started":"2025-10-11T02:26:02.619420Z","shell.execute_reply":"2025-10-11T02:26:02.779338Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Loading data","metadata":{}},{"cell_type":"markdown","source":"###  Loading train data","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_train_raw = pd.read_csv('/kaggle/input/cmi-detect-behavior-with-sensor-data/train.csv')\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:02.782544Z","iopub.execute_input":"2025-10-11T02:26:02.782907Z","iopub.status.idle":"2025-10-11T02:26:37.110987Z","shell.execute_reply.started":"2025-10-11T02:26:02.782874Z","shell.execute_reply":"2025-10-11T02:26:37.110204Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_raw.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.111806Z","iopub.execute_input":"2025-10-11T02:26:37.112188Z","iopub.status.idle":"2025-10-11T02:26:37.155047Z","shell.execute_reply.started":"2025-10-11T02:26:37.112157Z","shell.execute_reply":"2025-10-11T02:26:37.154184Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_raw.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.155985Z","iopub.execute_input":"2025-10-11T02:26:37.156298Z","iopub.status.idle":"2025-10-11T02:26:37.169265Z","shell.execute_reply.started":"2025-10-11T02:26:37.156270Z","shell.execute_reply":"2025-10-11T02:26:37.168367Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"np.any(pd.isna(df_train_raw))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.170096Z","iopub.execute_input":"2025-10-11T02:26:37.170349Z","iopub.status.idle":"2025-10-11T02:26:37.858764Z","shell.execute_reply.started":"2025-10-11T02:26:37.170324Z","shell.execute_reply":"2025-10-11T02:26:37.857946Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"start_time = timer(None)\ndf_train_demo = pd.read_csv('/kaggle/input/cmi-detect-behavior-with-sensor-data/train_demographics.csv')\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.859538Z","iopub.execute_input":"2025-10-11T02:26:37.859747Z","iopub.status.idle":"2025-10-11T02:26:37.869948Z","shell.execute_reply.started":"2025-10-11T02:26:37.859720Z","shell.execute_reply":"2025-10-11T02:26:37.869117Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_demo.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.870923Z","iopub.execute_input":"2025-10-11T02:26:37.871267Z","iopub.status.idle":"2025-10-11T02:26:37.888280Z","shell.execute_reply.started":"2025-10-11T02:26:37.871239Z","shell.execute_reply":"2025-10-11T02:26:37.887381Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_demo.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.889127Z","iopub.execute_input":"2025-10-11T02:26:37.889371Z","iopub.status.idle":"2025-10-11T02:26:37.906159Z","shell.execute_reply.started":"2025-10-11T02:26:37.889353Z","shell.execute_reply":"2025-10-11T02:26:37.905424Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"np.any(pd.isna(df_train_demo))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.906991Z","iopub.execute_input":"2025-10-11T02:26:37.907289Z","iopub.status.idle":"2025-10-11T02:26:37.924415Z","shell.execute_reply.started":"2025-10-11T02:26:37.907264Z","shell.execute_reply":"2025-10-11T02:26:37.923554Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Loading test data","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_test_raw = pd.read_csv('/kaggle/input/cmi-detect-behavior-with-sensor-data/test.csv')\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.925474Z","iopub.execute_input":"2025-10-11T02:26:37.925810Z","iopub.status.idle":"2025-10-11T02:26:37.960184Z","shell.execute_reply.started":"2025-10-11T02:26:37.925790Z","shell.execute_reply":"2025-10-11T02:26:37.959282Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_test_raw.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.964387Z","iopub.execute_input":"2025-10-11T02:26:37.964690Z","iopub.status.idle":"2025-10-11T02:26:37.986100Z","shell.execute_reply.started":"2025-10-11T02:26:37.964667Z","shell.execute_reply":"2025-10-11T02:26:37.985099Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_test_raw.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:37.986936Z","iopub.execute_input":"2025-10-11T02:26:37.987246Z","iopub.status.idle":"2025-10-11T02:26:38.002667Z","shell.execute_reply.started":"2025-10-11T02:26:37.987220Z","shell.execute_reply":"2025-10-11T02:26:38.001733Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"np.any(pd.isna(df_test_raw))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.003963Z","iopub.execute_input":"2025-10-11T02:26:38.004278Z","iopub.status.idle":"2025-10-11T02:26:38.020647Z","shell.execute_reply.started":"2025-10-11T02:26:38.004249Z","shell.execute_reply":"2025-10-11T02:26:38.019630Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"start_time = timer(None)\ndf_test_demo = pd.read_csv('/kaggle/input/cmi-detect-behavior-with-sensor-data/test_demographics.csv')\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.021607Z","iopub.execute_input":"2025-10-11T02:26:38.022097Z","iopub.status.idle":"2025-10-11T02:26:38.042308Z","shell.execute_reply.started":"2025-10-11T02:26:38.022068Z","shell.execute_reply":"2025-10-11T02:26:38.041210Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_test_demo.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.043397Z","iopub.execute_input":"2025-10-11T02:26:38.043697Z","iopub.status.idle":"2025-10-11T02:26:38.053722Z","shell.execute_reply.started":"2025-10-11T02:26:38.043678Z","shell.execute_reply":"2025-10-11T02:26:38.052806Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_test_demo.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.054681Z","iopub.execute_input":"2025-10-11T02:26:38.055131Z","iopub.status.idle":"2025-10-11T02:26:38.067809Z","shell.execute_reply.started":"2025-10-11T02:26:38.055103Z","shell.execute_reply":"2025-10-11T02:26:38.066874Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"np.any(pd.isna(df_test_demo))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.068961Z","iopub.execute_input":"2025-10-11T02:26:38.069218Z","iopub.status.idle":"2025-10-11T02:26:38.083331Z","shell.execute_reply.started":"2025-10-11T02:26:38.069190Z","shell.execute_reply":"2025-10-11T02:26:38.082392Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Exploratory Data Analysis","metadata":{}},{"cell_type":"code","source":"drop_columns_eda_train = ['row_id', 'sequence_type', 'sequence_id', 'sequence_counter', 'subject', \n                   'orientation', 'behavior', 'phase', 'gesture']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.084047Z","iopub.execute_input":"2025-10-11T02:26:38.084272Z","iopub.status.idle":"2025-10-11T02:26:38.096508Z","shell.execute_reply.started":"2025-10-11T02:26:38.084246Z","shell.execute_reply":"2025-10-11T02:26:38.095683Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"drop_columns_eda_test = ['row_id', 'sequence_id', 'sequence_counter', 'subject'] \n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.097259Z","iopub.execute_input":"2025-10-11T02:26:38.097481Z","iopub.status.idle":"2025-10-11T02:26:38.111798Z","shell.execute_reply.started":"2025-10-11T02:26:38.097456Z","shell.execute_reply":"2025-10-11T02:26:38.110787Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"start_time = timer(None)\nprint(df_train_raw.drop(columns = drop_columns_eda_train).describe())\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:38.112896Z","iopub.execute_input":"2025-10-11T02:26:38.113225Z","iopub.status.idle":"2025-10-11T02:26:46.646431Z","shell.execute_reply.started":"2025-10-11T02:26:38.113205Z","shell.execute_reply":"2025-10-11T02:26:46.645503Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"start_time = timer(None)\nprint(df_test_raw.drop(columns = drop_columns_eda_test).describe())\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:46.647366Z","iopub.execute_input":"2025-10-11T02:26:46.647661Z","iopub.status.idle":"2025-10-11T02:26:47.032086Z","shell.execute_reply.started":"2025-10-11T02:26:46.647637Z","shell.execute_reply":"2025-10-11T02:26:47.031162Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_values = df_train_raw.nunique().reset_index()\ndf_train_values.columns = ['column', 'unique_count']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:47.033014Z","iopub.execute_input":"2025-10-11T02:26:47.033306Z","iopub.status.idle":"2025-10-11T02:26:49.832456Z","shell.execute_reply.started":"2025-10-11T02:26:47.033280Z","shell.execute_reply":"2025-10-11T02:26:49.831737Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_values.head(30)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:49.833411Z","iopub.execute_input":"2025-10-11T02:26:49.833631Z","iopub.status.idle":"2025-10-11T02:26:49.842113Z","shell.execute_reply.started":"2025-10-11T02:26:49.833613Z","shell.execute_reply":"2025-10-11T02:26:49.841388Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_test_values = df_test_raw.nunique().reset_index()\ndf_test_values.columns = ['column', 'unique_count']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:49.842934Z","iopub.execute_input":"2025-10-11T02:26:49.843163Z","iopub.status.idle":"2025-10-11T02:26:49.883090Z","shell.execute_reply.started":"2025-10-11T02:26:49.843146Z","shell.execute_reply":"2025-10-11T02:26:49.882202Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_test_values.head(30)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:49.884108Z","iopub.execute_input":"2025-10-11T02:26:49.884313Z","iopub.status.idle":"2025-10-11T02:26:49.892631Z","shell.execute_reply.started":"2025-10-11T02:26:49.884297Z","shell.execute_reply":"2025-10-11T02:26:49.891767Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_null = df_train_raw.isnull().sum().reset_index()\ndf_train_null.columns = ['column', 'null_value_count']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:49.893564Z","iopub.execute_input":"2025-10-11T02:26:49.893821Z","iopub.status.idle":"2025-10-11T02:26:50.731574Z","shell.execute_reply.started":"2025-10-11T02:26:49.893804Z","shell.execute_reply":"2025-10-11T02:26:50.730942Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_null.head(30)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:50.732359Z","iopub.execute_input":"2025-10-11T02:26:50.732587Z","iopub.status.idle":"2025-10-11T02:26:50.741289Z","shell.execute_reply.started":"2025-10-11T02:26:50.732569Z","shell.execute_reply":"2025-10-11T02:26:50.740350Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_null.tail(30)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:50.742286Z","iopub.execute_input":"2025-10-11T02:26:50.742568Z","iopub.status.idle":"2025-10-11T02:26:50.758272Z","shell.execute_reply.started":"2025-10-11T02:26:50.742550Z","shell.execute_reply":"2025-10-11T02:26:50.757376Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"del df_train_values, df_test_values, df_train_null\ngc.collect()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:50.759140Z","iopub.execute_input":"2025-10-11T02:26:50.759421Z","iopub.status.idle":"2025-10-11T02:26:51.034160Z","shell.execute_reply.started":"2025-10-11T02:26:50.759387Z","shell.execute_reply":"2025-10-11T02:26:51.033322Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Boxplots for the various signals from the sensors","metadata":{}},{"cell_type":"markdown","source":"#### Acceleration signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw.boxplot(column = ['acc_x', 'acc_y', 'acc_z'])\nplt.suptitle('Boxplot of acceleration signals')\nplt.title('Train set')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:51.034968Z","iopub.execute_input":"2025-10-11T02:26:51.035220Z","iopub.status.idle":"2025-10-11T02:26:52.832665Z","shell.execute_reply.started":"2025-10-11T02:26:51.035202Z","shell.execute_reply":"2025-10-11T02:26:52.831812Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw.boxplot(column = ['acc_x', 'acc_y', 'acc_z'])\nplt.title('Test set')\nplt.suptitle('Boxplot of acceleration signals')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:52.833875Z","iopub.execute_input":"2025-10-11T02:26:52.834225Z","iopub.status.idle":"2025-10-11T02:26:52.992787Z","shell.execute_reply.started":"2025-10-11T02:26:52.834203Z","shell.execute_reply":"2025-10-11T02:26:52.991999Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Rotation signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw.boxplot(column = ['rot_x', 'rot_y', 'rot_z'])\nplt.title('Train set')\nplt.suptitle('Boxplot of rotation signals')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:52.994062Z","iopub.execute_input":"2025-10-11T02:26:52.994378Z","iopub.status.idle":"2025-10-11T02:26:54.602919Z","shell.execute_reply.started":"2025-10-11T02:26:52.994352Z","shell.execute_reply":"2025-10-11T02:26:54.602004Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw.boxplot(column = ['rot_x', 'rot_y', 'rot_z'])\nplt.title('Test set')\nplt.suptitle('Boxplot of rotation signals')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:54.603954Z","iopub.execute_input":"2025-10-11T02:26:54.604242Z","iopub.status.idle":"2025-10-11T02:26:54.762024Z","shell.execute_reply.started":"2025-10-11T02:26:54.604213Z","shell.execute_reply":"2025-10-11T02:26:54.761305Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Thermopile sensor signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw.boxplot(column = ['thm_1', 'thm_2', 'thm_3', 'thm_4', 'thm_5'])\nplt.title('Train set')\nplt.suptitle('Boxplot of thermopile sensor signals')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:54.762934Z","iopub.execute_input":"2025-10-11T02:26:54.763226Z","iopub.status.idle":"2025-10-11T02:26:57.508178Z","shell.execute_reply.started":"2025-10-11T02:26:54.763196Z","shell.execute_reply":"2025-10-11T02:26:57.507297Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw.boxplot(column = ['thm_1', 'thm_2', 'thm_3', 'thm_4', 'thm_5'])\nplt.title('Test set')\nplt.suptitle('Boxplot of thermopile sensor signals')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:57.509237Z","iopub.execute_input":"2025-10-11T02:26:57.509537Z","iopub.status.idle":"2025-10-11T02:26:57.680074Z","shell.execute_reply.started":"2025-10-11T02:26:57.509512Z","shell.execute_reply":"2025-10-11T02:26:57.679252Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 1 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_train_raw.boxplot(column = list(df_train_raw.columns[df_train_raw.columns.str.contains('tof_1')]),\n                    figsize = (12, 6))\nplt.title('Train set')\nplt.suptitle('Boxplot of time-of-flight sensor 1 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:26:57.680863Z","iopub.execute_input":"2025-10-11T02:26:57.681118Z","iopub.status.idle":"2025-10-11T02:27:28.785482Z","shell.execute_reply.started":"2025-10-11T02:26:57.681098Z","shell.execute_reply":"2025-10-11T02:27:28.784563Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_test_raw.boxplot(column = list(df_test_raw.columns[df_test_raw.columns.str.contains('tof_1')]),\n                   figsize = (12, 6))\nplt.title('Test set')\nplt.suptitle('Boxplot of time-of-flight sensor 1 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:27:28.786373Z","iopub.execute_input":"2025-10-11T02:27:28.786604Z","iopub.status.idle":"2025-10-11T02:27:29.313186Z","shell.execute_reply.started":"2025-10-11T02:27:28.786586Z","shell.execute_reply":"2025-10-11T02:27:29.312322Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 2 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_train_raw.boxplot(column = list(df_train_raw.columns[df_train_raw.columns.str.contains('tof_2')]),\n                    figsize = (12, 6))\nplt.title('Train set')\nplt.suptitle('Boxplot of time-of-flight sensor 2 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:27:29.319496Z","iopub.execute_input":"2025-10-11T02:27:29.319809Z","iopub.status.idle":"2025-10-11T02:28:00.863486Z","shell.execute_reply.started":"2025-10-11T02:27:29.319790Z","shell.execute_reply":"2025-10-11T02:28:00.862502Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_test_raw.boxplot(column = list(df_test_raw.columns[df_test_raw.columns.str.contains('tof_2')]),\n                   figsize = (12, 6))\nplt.title('Test set')\nplt.suptitle('Boxplot of time-of-flight sensor 2 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:28:00.864291Z","iopub.execute_input":"2025-10-11T02:28:00.864544Z","iopub.status.idle":"2025-10-11T02:28:01.940578Z","shell.execute_reply.started":"2025-10-11T02:28:00.864507Z","shell.execute_reply":"2025-10-11T02:28:01.939770Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 3 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_train_raw.boxplot(column = list(df_train_raw.columns[df_train_raw.columns.str.contains('tof_3')]),\n                    figsize = (12, 6))\nplt.title('Train set')\nplt.suptitle('Boxplot of time-of-flight sensor 3 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:28:01.941375Z","iopub.execute_input":"2025-10-11T02:28:01.941655Z","iopub.status.idle":"2025-10-11T02:28:39.572940Z","shell.execute_reply.started":"2025-10-11T02:28:01.941636Z","shell.execute_reply":"2025-10-11T02:28:39.571654Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_test_raw.boxplot(column = list(df_test_raw.columns[df_test_raw.columns.str.contains('tof_3')]),\n                   figsize = (12, 6))\nplt.title('Test set')\nplt.suptitle('Boxplot of time-of-flight sensor 3 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:28:39.574499Z","iopub.execute_input":"2025-10-11T02:28:39.574967Z","iopub.status.idle":"2025-10-11T02:28:40.091177Z","shell.execute_reply.started":"2025-10-11T02:28:39.574926Z","shell.execute_reply":"2025-10-11T02:28:40.090291Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 4 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_train_raw.boxplot(column = list(df_train_raw.columns[df_train_raw.columns.str.contains('tof_4')]),\n                    figsize = (12, 6))\nplt.title('Train set')\nplt.suptitle('Boxplot of time-of-flight sensor 4 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:28:40.092208Z","iopub.execute_input":"2025-10-11T02:28:40.092578Z","iopub.status.idle":"2025-10-11T02:29:11.157805Z","shell.execute_reply.started":"2025-10-11T02:28:40.092547Z","shell.execute_reply":"2025-10-11T02:29:11.156890Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_test_raw.boxplot(column = list(df_test_raw.columns[df_test_raw.columns.str.contains('tof_4')]),\n                   figsize = (12, 6))\nplt.title('Test set')\nplt.suptitle('Boxplot of time-of-flight sensor 4 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:29:11.158958Z","iopub.execute_input":"2025-10-11T02:29:11.159253Z","iopub.status.idle":"2025-10-11T02:29:11.659987Z","shell.execute_reply.started":"2025-10-11T02:29:11.159233Z","shell.execute_reply":"2025-10-11T02:29:11.659068Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 5 signals","metadata":{}},{"cell_type":"markdown","source":"#####   Train set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_train_raw.boxplot(column = list(df_train_raw.columns[df_train_raw.columns.str.contains('tof_5')]),\n                    figsize = (12, 6))\nplt.title('Train set')\nplt.suptitle('Boxplot of time-of-flight sensor 5 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:29:11.661049Z","iopub.execute_input":"2025-10-11T02:29:11.661357Z","iopub.status.idle":"2025-10-11T02:29:43.515620Z","shell.execute_reply.started":"2025-10-11T02:29:11.661337Z","shell.execute_reply":"2025-10-11T02:29:43.514786Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\ndf_test_raw.boxplot(column = list(df_test_raw.columns[df_test_raw.columns.str.contains('tof_5')]),\n                   figsize = (12, 6))\nplt.title('Test set')\nplt.suptitle('Boxplot of time-of-flight sensor 5 signals')\nplt.xticks(ticks = [])\nplt.show()\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:29:43.516733Z","iopub.execute_input":"2025-10-11T02:29:43.517097Z","iopub.status.idle":"2025-10-11T02:29:44.019452Z","shell.execute_reply.started":"2025-10-11T02:29:43.517065Z","shell.execute_reply":"2025-10-11T02:29:44.018575Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Handling outliers","metadata":{}},{"cell_type":"markdown","source":"###  Estimating outliers using formula","metadata":{}},{"cell_type":"markdown","source":"####  Acceleration signals","metadata":{}},{"cell_type":"code","source":"warnings.simplefilter('ignore', RuntimeWarning)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:29:44.020323Z","iopub.execute_input":"2025-10-11T02:29:44.020543Z","iopub.status.idle":"2025-10-11T02:29:44.024718Z","shell.execute_reply.started":"2025-10-11T02:29:44.020527Z","shell.execute_reply":"2025-10-11T02:29:44.023799Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def percent_of_outliers(df, col_str):\n    for col in list(df.columns[df.columns.str.contains(col_str)]):\n        q1 = df[col].quantile(0.25)\n        q3 = df[col].quantile(0.75)\n        iqr = q3 - q1\n        ub = q3 + 1.5 * iqr\n        lb = q1 - 1.5 * iqr\n        count = len(df[(df[col] > ub) | (df[col] < lb)])\n        percentage = count / len(df[col])\n        print(col + ': ' + str(round(percentage, 2)) + '%')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:29:44.025655Z","iopub.execute_input":"2025-10-11T02:29:44.025960Z","iopub.status.idle":"2025-10-11T02:29:44.041584Z","shell.execute_reply.started":"2025-10-11T02:29:44.025931Z","shell.execute_reply":"2025-10-11T02:29:44.040756Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\nprint('Train set')\nprint('Acceleration signals')\npercent_of_outliers(df_train_raw, 'acc')\nprint('Rotation signals')\npercent_of_outliers(df_train_raw, 'rot')\nprint('Thermopile sensor signals')\npercent_of_outliers(df_train_raw, 'thm')\nprint('Time-of-flight sensor signals')\npercent_of_outliers(df_train_raw, 'tof')\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:29:44.042743Z","iopub.execute_input":"2025-10-11T02:29:44.043076Z","iopub.status.idle":"2025-10-11T02:30:05.054447Z","shell.execute_reply.started":"2025-10-11T02:29:44.043031Z","shell.execute_reply":"2025-10-11T02:30:05.053715Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"start_time = timer(None)\nprint('Test set')\nprint('Acceleration signals')\npercent_of_outliers(df_test_raw, 'acc')\nprint('Rotation signals')\npercent_of_outliers(df_test_raw, 'rot')\nprint('Thermopile sensor signals')\npercent_of_outliers(df_test_raw, 'thm')\nprint('Time-of-flight sensor signals')\npercent_of_outliers(df_test_raw, 'tof')\ntimer(start_time)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.055366Z","iopub.execute_input":"2025-10-11T02:30:05.055630Z","iopub.status.idle":"2025-10-11T02:30:05.515681Z","shell.execute_reply.started":"2025-10-11T02:30:05.055600Z","shell.execute_reply":"2025-10-11T02:30:05.514874Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Estimating outliers for acceleration signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('acc')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.516752Z","iopub.execute_input":"2025-10-11T02:30:05.517541Z","iopub.status.idle":"2025-10-11T02:30:05.599029Z","shell.execute_reply.started":"2025-10-11T02:30:05.517509Z","shell.execute_reply":"2025-10-11T02:30:05.598153Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('acc')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.600140Z","iopub.execute_input":"2025-10-11T02:30:05.600441Z","iopub.status.idle":"2025-10-11T02:30:05.617311Z","shell.execute_reply.started":"2025-10-11T02:30:05.600413Z","shell.execute_reply":"2025-10-11T02:30:05.616409Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Estimating outliers for rotation signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('rot')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.618382Z","iopub.execute_input":"2025-10-11T02:30:05.618707Z","iopub.status.idle":"2025-10-11T02:30:05.739633Z","shell.execute_reply.started":"2025-10-11T02:30:05.618680Z","shell.execute_reply":"2025-10-11T02:30:05.738894Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('rot')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.740529Z","iopub.execute_input":"2025-10-11T02:30:05.740762Z","iopub.status.idle":"2025-10-11T02:30:05.759199Z","shell.execute_reply.started":"2025-10-11T02:30:05.740744Z","shell.execute_reply":"2025-10-11T02:30:05.758304Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Estimating outliers for thermopile signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('thm')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.760072Z","iopub.execute_input":"2025-10-11T02:30:05.760309Z","iopub.status.idle":"2025-10-11T02:30:05.912715Z","shell.execute_reply.started":"2025-10-11T02:30:05.760289Z","shell.execute_reply":"2025-10-11T02:30:05.911842Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('thm')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.913782Z","iopub.execute_input":"2025-10-11T02:30:05.914112Z","iopub.status.idle":"2025-10-11T02:30:05.935342Z","shell.execute_reply.started":"2025-10-11T02:30:05.914083Z","shell.execute_reply":"2025-10-11T02:30:05.934404Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Estimation of time-of-flight sensor signals","metadata":{}},{"cell_type":"markdown","source":"####  Time-of-flght sensor 1 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('tof_1')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:05.936342Z","iopub.execute_input":"2025-10-11T02:30:05.937060Z","iopub.status.idle":"2025-10-11T02:30:07.643485Z","shell.execute_reply.started":"2025-10-11T02:30:05.937039Z","shell.execute_reply":"2025-10-11T02:30:07.642624Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('tof_1')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:07.644419Z","iopub.execute_input":"2025-10-11T02:30:07.644757Z","iopub.status.idle":"2025-10-11T02:30:07.742901Z","shell.execute_reply.started":"2025-10-11T02:30:07.644738Z","shell.execute_reply":"2025-10-11T02:30:07.742018Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 2 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('tof_2')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:07.744003Z","iopub.execute_input":"2025-10-11T02:30:07.744316Z","iopub.status.idle":"2025-10-11T02:30:09.332738Z","shell.execute_reply.started":"2025-10-11T02:30:07.744294Z","shell.execute_reply":"2025-10-11T02:30:09.331816Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('tof_2')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:09.333638Z","iopub.execute_input":"2025-10-11T02:30:09.333934Z","iopub.status.idle":"2025-10-11T02:30:09.437004Z","shell.execute_reply.started":"2025-10-11T02:30:09.333914Z","shell.execute_reply":"2025-10-11T02:30:09.436192Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 3 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('tof_3')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:09.437867Z","iopub.execute_input":"2025-10-11T02:30:09.438146Z","iopub.status.idle":"2025-10-11T02:30:11.076398Z","shell.execute_reply.started":"2025-10-11T02:30:09.438115Z","shell.execute_reply":"2025-10-11T02:30:11.075591Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('tof_3')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:11.077527Z","iopub.execute_input":"2025-10-11T02:30:11.077870Z","iopub.status.idle":"2025-10-11T02:30:11.173882Z","shell.execute_reply.started":"2025-10-11T02:30:11.077820Z","shell.execute_reply":"2025-10-11T02:30:11.173093Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 4 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('tof_4')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:11.174925Z","iopub.execute_input":"2025-10-11T02:30:11.175213Z","iopub.status.idle":"2025-10-11T02:30:12.834784Z","shell.execute_reply.started":"2025-10-11T02:30:11.175194Z","shell.execute_reply":"2025-10-11T02:30:12.834034Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('tof_4')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:12.835668Z","iopub.execute_input":"2025-10-11T02:30:12.835961Z","iopub.status.idle":"2025-10-11T02:30:12.935858Z","shell.execute_reply.started":"2025-10-11T02:30:12.835931Z","shell.execute_reply":"2025-10-11T02:30:12.935065Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"####  Time-of-flight sensor 5 signals","metadata":{}},{"cell_type":"markdown","source":"#####  Train set","metadata":{}},{"cell_type":"code","source":"df_train_raw[df_train_raw.columns[df_train_raw.columns.str.contains('tof_5')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:12.936695Z","iopub.execute_input":"2025-10-11T02:30:12.936964Z","iopub.status.idle":"2025-10-11T02:30:14.555524Z","shell.execute_reply.started":"2025-10-11T02:30:12.936945Z","shell.execute_reply":"2025-10-11T02:30:14.554729Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"#####  Test set","metadata":{}},{"cell_type":"code","source":"df_test_raw[df_test_raw.columns[df_test_raw.columns.str.contains('tof_5')]].describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:14.556528Z","iopub.execute_input":"2025-10-11T02:30:14.557307Z","iopub.status.idle":"2025-10-11T02:30:14.654520Z","shell.execute_reply.started":"2025-10-11T02:30:14.557287Z","shell.execute_reply":"2025-10-11T02:30:14.653657Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## EDA of demographic data","metadata":{}},{"cell_type":"markdown","source":"###  Countplot of adult/child feature","metadata":{}},{"cell_type":"code","source":"ax = sns.countplot(x = 'adult_child', data = df_train_demo)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:14.655474Z","iopub.execute_input":"2025-10-11T02:30:14.655821Z","iopub.status.idle":"2025-10-11T02:30:14.790169Z","shell.execute_reply.started":"2025-10-11T02:30:14.655703Z","shell.execute_reply":"2025-10-11T02:30:14.789279Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Histogram of age","metadata":{}},{"cell_type":"code","source":"plt.hist(df_train_demo.age)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:14.791190Z","iopub.execute_input":"2025-10-11T02:30:14.791502Z","iopub.status.idle":"2025-10-11T02:30:14.945268Z","shell.execute_reply.started":"2025-10-11T02:30:14.791476Z","shell.execute_reply":"2025-10-11T02:30:14.944461Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Boxplot of age","metadata":{}},{"cell_type":"code","source":"ax = df_train_demo.boxplot(column = 'age')\nax.set_title('Train set')\nax.set_xlabel('')\nplt.suptitle('Bixplot of age feature')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:14.946593Z","iopub.execute_input":"2025-10-11T02:30:14.946970Z","iopub.status.idle":"2025-10-11T02:30:15.067367Z","shell.execute_reply.started":"2025-10-11T02:30:14.946943Z","shell.execute_reply":"2025-10-11T02:30:15.066490Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Countplot of the sex feature","metadata":{}},{"cell_type":"code","source":"sns.countplot(x = 'sex', data = df_train_demo)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:15.068317Z","iopub.execute_input":"2025-10-11T02:30:15.068524Z","iopub.status.idle":"2025-10-11T02:30:15.186653Z","shell.execute_reply.started":"2025-10-11T02:30:15.068507Z","shell.execute_reply":"2025-10-11T02:30:15.185766Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Countplot of handedness feature","metadata":{}},{"cell_type":"code","source":"sns.countplot(x = 'handedness', data = df_train_demo)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:15.187598Z","iopub.execute_input":"2025-10-11T02:30:15.187953Z","iopub.status.idle":"2025-10-11T02:30:15.315115Z","shell.execute_reply.started":"2025-10-11T02:30:15.187934Z","shell.execute_reply":"2025-10-11T02:30:15.314258Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Histogram of height feature","metadata":{}},{"cell_type":"code","source":"plt.hist(df_train_demo.height_cm)\nplt.title('Histogram of height feature in the train set')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:15.316056Z","iopub.execute_input":"2025-10-11T02:30:15.316310Z","iopub.status.idle":"2025-10-11T02:30:15.529882Z","shell.execute_reply.started":"2025-10-11T02:30:15.316278Z","shell.execute_reply":"2025-10-11T02:30:15.528881Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Boxplot of height feature","metadata":{}},{"cell_type":"code","source":"ax = df_train_demo.boxplot(column = 'height_cm')\nax.set_title('Train set')\nax.set_xlabel('')\nplt.suptitle('Boxplot of height feature')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:15.530800Z","iopub.execute_input":"2025-10-11T02:30:15.531133Z","iopub.status.idle":"2025-10-11T02:30:15.666115Z","shell.execute_reply.started":"2025-10-11T02:30:15.531106Z","shell.execute_reply":"2025-10-11T02:30:15.665245Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Histogram of shoulder to wrist length feature","metadata":{}},{"cell_type":"code","source":"plt.hist(df_train_demo.shoulder_to_wrist_cm)\nplt.title('Histogram of shoulder to wrist length feature in the train set')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:15.667025Z","iopub.execute_input":"2025-10-11T02:30:15.667282Z","iopub.status.idle":"2025-10-11T02:30:15.867038Z","shell.execute_reply.started":"2025-10-11T02:30:15.667257Z","shell.execute_reply":"2025-10-11T02:30:15.865893Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Boxplot of shoulder to wrist length feature","metadata":{}},{"cell_type":"code","source":"ax = df_train_demo.boxplot(column = 'shoulder_to_wrist_cm')\nax.set_title('Train set')\nax.set_xlabel('')\nplt.title('Boxplot of shoulder to wrist length feature')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:15.868242Z","iopub.execute_input":"2025-10-11T02:30:15.868517Z","iopub.status.idle":"2025-10-11T02:30:16.010443Z","shell.execute_reply.started":"2025-10-11T02:30:15.868496Z","shell.execute_reply":"2025-10-11T02:30:16.009507Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Histogram of elbow to wrist length feature","metadata":{}},{"cell_type":"code","source":"plt.hist(df_train_demo.elbow_to_wrist_cm)\nplt.title('Histogram of elbow to wrist length feature in train set')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:16.011424Z","iopub.execute_input":"2025-10-11T02:30:16.011703Z","iopub.status.idle":"2025-10-11T02:30:16.242552Z","shell.execute_reply.started":"2025-10-11T02:30:16.011672Z","shell.execute_reply":"2025-10-11T02:30:16.241703Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  Boxplot of elbow to wrist length feature","metadata":{}},{"cell_type":"code","source":"ax = df_train_demo.boxplot(column = 'elbow_to_wrist_cm')\nax.set_title('Train set')\nax.set_xlabel('')\nplt.suptitle('Boxplot of elbow to wrist length feature')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:30:16.243516Z","iopub.execute_input":"2025-10-11T02:30:16.243775Z","iopub.status.idle":"2025-10-11T02:30:16.381820Z","shell.execute_reply.started":"2025-10-11T02:30:16.243746Z","shell.execute_reply":"2025-10-11T02:30:16.380912Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Analysis of target labels","metadata":{}},{"cell_type":"markdown","source":"###  sequence_type label","metadata":{}},{"cell_type":"code","source":"seq_type_list = list(df_train_raw['sequence_type'].unique())\nseq_type_value_counts = list(df_train_raw['sequence_type'].value_counts())\nseq_type_dict = {seq_type_item: round(seq_type_value_counts[i] * 100 / len(df_train_raw['sequence_type']), 2) for i, seq_type_item in enumerate(seq_type_list)}\nseq_type_dict","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T02:56:49.278085Z","iopub.execute_input":"2025-10-11T02:56:49.278421Z","iopub.status.idle":"2025-10-11T02:56:49.356801Z","shell.execute_reply.started":"2025-10-11T02:56:49.278398Z","shell.execute_reply":"2025-10-11T02:56:49.356100Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  orientation label","metadata":{}},{"cell_type":"code","source":"orient_list = list(df_train_raw['orientation'].unique())\norient_value_counts = list(df_train_raw['orientation'].value_counts())\norient_dict = {orient_item: round(orient_value_counts[i] * 100 / len(df_train_raw['orientation']), 2) for i, orient_item in enumerate(orient_list)}\norient_dict","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T03:00:46.684174Z","iopub.execute_input":"2025-10-11T03:00:46.684541Z","iopub.status.idle":"2025-10-11T03:00:46.781205Z","shell.execute_reply.started":"2025-10-11T03:00:46.684517Z","shell.execute_reply":"2025-10-11T03:00:46.780223Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  behavior label","metadata":{}},{"cell_type":"code","source":"behavior_list = list(df_train_raw['behavior'].unique())\nbehavior_value_counts = list(df_train_raw['behavior'].value_counts())\nbehavior_dict = {behavior_item: round(behavior_value_counts[i] * 100 / len(df_train_raw['behavior']), 2) for i, behavior_item in enumerate(behavior_list)}\nbehavior_dict","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T03:03:44.763758Z","iopub.execute_input":"2025-10-11T03:03:44.764664Z","iopub.status.idle":"2025-10-11T03:03:44.858316Z","shell.execute_reply.started":"2025-10-11T03:03:44.764635Z","shell.execute_reply":"2025-10-11T03:03:44.857510Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  phase label","metadata":{}},{"cell_type":"code","source":"phase_list = list(df_train_raw['phase'].unique())\nphase_value_counts = list(df_train_raw['phase'].value_counts())\nphase_dict = {phase_item: round(phase_value_counts[i] * 100 / len(df_train_raw['phase']), 2) for i, phase_item in enumerate(phase_list)}\nphase_dict","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T03:06:20.222302Z","iopub.execute_input":"2025-10-11T03:06:20.222718Z","iopub.status.idle":"2025-10-11T03:06:20.305379Z","shell.execute_reply.started":"2025-10-11T03:06:20.222691Z","shell.execute_reply":"2025-10-11T03:06:20.304473Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"###  gesture label","metadata":{}},{"cell_type":"code","source":"gesture_list = list(df_train_raw['gesture'].unique())\ngesture_value_counts = list(df_train_raw['gesture'].value_counts())\ngesture_dict = {gesture_item: round(gesture_value_counts[i] * 100 / len(df_train_raw['gesture']), 2) for i, gesture_item in enumerate(gesture_list)}\ngesture_dict","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-11T03:08:48.604429Z","iopub.execute_input":"2025-10-11T03:08:48.604818Z","iopub.status.idle":"2025-10-11T03:08:48.699316Z","shell.execute_reply.started":"2025-10-11T03:08:48.604792Z","shell.execute_reply":"2025-10-11T03:08:48.698394Z"}},"outputs":[],"execution_count":null}]}