{"cells":[{"metadata":{"papermill":{"duration":0.020627,"end_time":"2021-02-05T08:08:06.227361","exception":false,"start_time":"2021-02-05T08:08:06.206734","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# Indoor Location & Navigation - Basic EDA - Traces and Features Visualization"},{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","execution":{"iopub.execute_input":"2021-02-05T08:08:06.272903Z","iopub.status.busy":"2021-02-05T08:08:06.272177Z","iopub.status.idle":"2021-02-05T08:08:07.259687Z","shell.execute_reply":"2021-02-05T08:08:07.258920Z"},"papermill":{"duration":1.012991,"end_time":"2021-02-05T08:08:07.259921","exception":false,"start_time":"2021-02-05T08:08:06.246930","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"import os\nimport json\n\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Defined tools"},{"metadata":{},"cell_type":"markdown","source":"Here is some defined visualization and data loading tools what will be used later. Feel free to use it if you like =)\n\nTrace parsing script (function `load_trace_as_dataframe`) taken from [this post](https://www.kaggle.com/c/indoor-location-navigation/discussion/215381).  \nThanks [Tolga Dincer](https://www.kaggle.com/tolgadincer) for this =)"},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"def load_trace_as_dataframe(filepath):\n    # Returns trace dataframe sorted by timestamp\n    \n    names = ['time', 'type'] + [f'col_{i}' for i in range(1, 9)]\n    \n    trace_df = pd.read_csv(\n        filepath, sep='\\t', comment='#', header=None, names=names\n    )\n    \n    trace_df.sort_values(by='time', inplace=True)\n    trace_df.reset_index(drop=True, inplace=True)\n    return trace_df\n\n\ndef extract_feature_df(trace_df, \n                       feature_name, \n                       col_names=('x', 'y', 'z', 'accuracy')):\n    \n    ''' \n    Extracts feature dataframe from trace dataframe by feature name.\n    \n    Suitable for features: \n    ----------------------\n        TYPE_WAYPOINT, if set col_names=('x', 'y'),\n        TYPE_ACCELEROMETER,\n        TYPE_GYROSCOPE,\n        TYPE_MAGNETIC_FIELD, \n        TYPE_ROTATION_VECTOR,\n        \n        TYPE_ACCELEROMETER_UNCALIBRATED, \n                    if set col_names=('x', 'y', 'z', 'x_2', 'y_2', 'z_2', 'accuracy'),\n                    \n        TYPE_GYROSCOPE_UNCALIBRATED, \n                    if set col_names=('x', 'y', 'z', 'x_2', 'y_2', 'z_2', 'accuracy'),\n                    \n        TYPE_MAGNETIC_FIELD_UNCALIBRATED, \n                    if set col_names=('x', 'y', 'z', 'x_2', 'y_2', 'z_2', 'accuracy')\n    '''\n    \n    feature_df = trace_df[trace_df['type'] == feature_name].copy()\n    for i, col in enumerate(col_names, start=1):\n        feature_df[col] = feature_df[f'col_{i}'].astype('float64')\n        \n    feature_df.drop(columns=[f'col_{i}' for i in range(1, 9)], inplace=True)\n    feature_df.drop(columns=['type'], inplace=True)\n    feature_df.reset_index(drop=True, inplace=True)\n    \n    return feature_df\n\n\ndef load_points(filepath):\n    # Takes the path to the trace file.\n    # Returns pandas dataframe which consists of device locations \n    # as x and y coordinates (values from TYPE_WAYPOINT) and their timestamps.\n    \n    trace_df = load_trace_as_dataframe(filepath)\n    points_df = extract_feature_df(\n        trace_df, 'TYPE_WAYPOINT', col_names=('x', 'y')\n    )\n    \n    return points_df\n\n\ndef visualize_many_traces_on_the_map(traces_dataframes, map_image, width, height, \n                                     traces_filenames=None, \n                                     figsize=None):\n    \n    \n    '''\n    Draws traces on the floor map.\n    \n    Parameters\n    ----------\n        traces_dataframes: list of pandas DataFrames\n            Each DataFrame should consist of device locations as x and y \n            coordinates and their timestamps.\n\n        map_image : numpy.array\n            Image of floor map.\n\n        width : float,\n            Width of floor. Should be taken from floor_info.json\n\n        height : float, \n            Height of floor. Should be taken from floor_info.json\n\n        traces_filenames : list of strings, optional, default: None\n            List of filenames. Used to display the legend. \n            There will be no legend if you pass traces_filenames=None\n\n        figsize : (float, float), optional, default: None\n            Size of the result image in terms of matplotlib.\n    \n    '''\n    \n    fig = plt.figure(figsize=figsize)\n    ax = plt.subplot(111)\n\n    plt.imshow(map_image, extent=[0, width, 0, height])\n\n    if traces_filenames:\n        \n        for filename, points in zip(traces_filenames, traces_dataframes):\n            plt.scatter(points['x'], points['y'], label=filename)\n            plt.plot(points['x'], points['y'])\n            \n        ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n    else:\n        for points in traces_dataframes:\n            plt.scatter(points['x'], points['y'])\n            plt.plot(points['x'], points['y'])\n\n\n    plt.show()\n\n    \ndef visualize_single_trace_on_the_map(points_df, map_image, width, height, \n                                      scaling_coef=0.3, figsize=None):\n    \n    '''\n    Draws single trace on the floor map.\n    \n    Parameters\n    ----------\n        points_df: pandas DataFrame\n            Should consist of device locations as x and y \n            coordinates and their timestamps.\n\n        map_image : numpy.array\n            Image of floor map.\n\n        width : float,\n            Width of floor. Should be taken from floor_info.json\n\n        height : float, \n            Height of floor. Should be taken from floor_info.json\n\n        scaling_coef : float\n            Scaling Coefficient. \n\n        figsize : (float, float), optional, default: None\n            Size of the result image in terms of matplotlib.\n    \n    '''\n    \n    fig = plt.figure(figsize=figsize)\n    ax = plt.subplot(111)\n\n    plt.imshow(map_image, extent=[0, width, 0, height])\n    plt.plot(points_df['x'], points_df['y'], linewidth=5, linestyle='-', color='blue')\n\n    for i in range(len(points_df)):\n        ax.text(\n            points_df.loc[i, 'x'], points_df.loc[i, 'y'], i, \n            ha=\"center\", size=15, \n            bbox=dict(boxstyle=\"circle, pad=0.3\", \n                      fc=\"cyan\", lw=2)\n        )\n \n    x_min, x_max = points_df['x'].min(), points_df['x'].max()\n    y_min, y_max = points_df['y'].min(), points_df['y'].max()\n\n    ax.set_xlim(x_min - scaling_coef*(x_max - x_min), x_max + scaling_coef*(x_max - x_min))\n    ax.set_ylim(y_min - scaling_coef*(y_max - y_min), y_max + scaling_coef*(y_max - y_min))\n\n    plt.show()\n\n    \ndef plot_trace_features(feature_df, timestamps=None, figsize=None):\n    \n    '''\n    Plots the trace features.\n    \n    Parameters\n    ----------\n        feature_df : pandas DataFrame\n            Can be exctracted from trace dataframe \n            using extract_feature_df function.\n        \n        timestamps : array-like, optional, default: None\n            Array of timestamps. \n            Used to mark timestamps on the chart in the form of vertical lines.\n            Pass timestamps=None if you don't want to use this feature.\n\n        figsize : (float, float), optional, default: None\n            Size of the result image in terms of matplotlib.\n    \n    Suitable for features: \n    ----------------------\n        TYPE_ACCELEROMETER \n        TYPE_GYROSCOPE \n        TYPE_MAGNETIC_FIELD \n        TYPE_ROTATION_VECTOR \n        TYPE_ACCELEROMETER_UNCALIBRATED \n        TYPE_GYROSCOPE_UNCALIBRATED \n        TYPE_MAGNETIC_FIELD_UNCALIBRATED\n    '''\n    \n    fig = plt.figure(figsize=figsize)\n    ax = plt.subplot(111)\n\n    for col in ['x', 'y', 'z']:\n        plt.plot(feature_df['time'], feature_df[col], label=col)\n\n\n    if points_df is not None:\n        xmin, xmax, ymin, ymax = plt.axis()\n\n        for i, timestamp in enumerate(timestamps):\n            plt.axvline(x=timestamp, c='k', ls='--')\n\n            ax.text(\n            timestamp, ymax, i, \n            ha=\"center\", size=15, \n            bbox=dict(boxstyle=\"circle, pad=0.3\", \n                      fc=\"white\", lw=2)\n            )\n    ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))\n    plt.show()","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.019409,"end_time":"2021-02-05T08:08:07.299615","exception":false,"start_time":"2021-02-05T08:08:07.280206","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# Let's take a look into data directory."},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:07.342893Z","iopub.status.busy":"2021-02-05T08:08:07.342208Z","iopub.status.idle":"2021-02-05T08:08:07.350684Z","shell.execute_reply":"2021-02-05T08:08:07.351989Z"},"papermill":{"duration":0.032792,"end_time":"2021-02-05T08:08:07.352181","exception":false,"start_time":"2021-02-05T08:08:07.319389","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"data_path = '/kaggle/input/indoor-location-navigation'\nos.listdir(data_path)","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.019966,"end_time":"2021-02-05T08:08:07.393035","exception":false,"start_time":"2021-02-05T08:08:07.373069","status":"completed"},"tags":[]},"cell_type":"markdown","source":"* **train** directory contains sites (shopping malls) directories that consists of floor direcories. And each floor directory contains txt files, that have information about paths (smarthones).\n\n* **metedata** directory contains floor map, its size and geo inforamation for each site and each floor.\n\nIn this competition we should predict smartphone location: floor number and x, y coordinates (TYPE_WAYPOINT). \n"},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:07.441308Z","iopub.status.busy":"2021-02-05T08:08:07.440669Z","iopub.status.idle":"2021-02-05T08:08:07.467367Z","shell.execute_reply":"2021-02-05T08:08:07.466839Z"},"papermill":{"duration":0.052782,"end_time":"2021-02-05T08:08:07.467544","exception":false,"start_time":"2021-02-05T08:08:07.414762","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"floor = '5a0546857ecc773753327266/F1'\nfloor_metadata_dir = os.path.join(data_path, 'metadata', floor)\nfloor_train_dir = os.path.join(data_path, 'train', floor)\n\nos.listdir(floor_metadata_dir)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# os.listdir(os.path.join(data_path, 'train'))[:10]","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:07.513764Z","iopub.status.busy":"2021-02-05T08:08:07.513115Z","iopub.status.idle":"2021-02-05T08:08:07.547663Z","shell.execute_reply":"2021-02-05T08:08:07.548188Z"},"papermill":{"duration":0.05999,"end_time":"2021-02-05T08:08:07.548392","exception":false,"start_time":"2021-02-05T08:08:07.488402","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"# os.listdir(floor_train_dir)[:5]","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.021315,"end_time":"2021-02-05T08:08:07.765255","exception":false,"start_time":"2021-02-05T08:08:07.743940","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# Loading coordinates of paths points"},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:07.872738Z","iopub.status.busy":"2021-02-05T08:08:07.872001Z","iopub.status.idle":"2021-02-05T08:08:13.014299Z","shell.execute_reply":"2021-02-05T08:08:13.014854Z"},"papermill":{"duration":5.171559,"end_time":"2021-02-05T08:08:13.015060","exception":false,"start_time":"2021-02-05T08:08:07.843501","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"paths = []\nfor filename in os.listdir(floor_train_dir):\n    if '.txt' not in filename:\n        continue\n    points = load_points(os.path.join(floor_train_dir, filename))\n    paths.append((filename, points))\n\npaths = sorted(paths, key=lambda path: len(path[1]), reverse=True)\npaths = paths[:20]\n\n\ntraces_dataframes = [trace for filename, trace in paths]\ntraces_filenames = [filename for filename, trace in paths]","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Loading floor map and its size"},{"metadata":{"trusted":true},"cell_type":"code","source":"MAP_IMAGE = plt.imread(\n    os.path.join(floor_metadata_dir, 'floor_image.png')\n)\n\nwith open(os.path.join(floor_metadata_dir, 'floor_info.json')) as f:\n    content = f.read()\n    floor_info = json.loads(content)\n\nMAP_HEIGHT = float(floor_info['map_info']['height'])\nMAP_WIDTH = float(floor_info['map_info']['width'])\n    \nfloor_info","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.02168,"end_time":"2021-02-05T08:08:13.059052","exception":false,"start_time":"2021-02-05T08:08:13.037372","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# Visualization of Traces (Paths) on the Floor Map"},{"metadata":{"trusted":true},"cell_type":"code","source":"visualize_many_traces_on_the_map(\n    traces_dataframes, MAP_IMAGE, MAP_WIDTH, MAP_HEIGHT, \n    traces_filenames=traces_filenames, \n    figsize=(15, 12)\n)","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.030613,"end_time":"2021-02-05T08:08:14.181601","exception":false,"start_time":"2021-02-05T08:08:14.150988","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# Features Visualization"},{"metadata":{},"cell_type":"markdown","source":"Let's take a closer look at single trace (path) and its attributes."},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:14.408565Z","iopub.status.busy":"2021-02-05T08:08:14.407885Z","iopub.status.idle":"2021-02-05T08:08:14.501533Z","shell.execute_reply":"2021-02-05T08:08:14.502049Z"},"papermill":{"duration":0.130966,"end_time":"2021-02-05T08:08:14.502229","exception":false,"start_time":"2021-02-05T08:08:14.371263","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"filename='5e15b0171506f2000638fe49.txt'\ntrace_filepath = os.path.join(floor_train_dir, filename)\n\ntrace_df = load_trace_as_dataframe(trace_filepath)\ntrace_df","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Here is a table of the attributes we need to deal with in this competition. \n\nAs you can see it contains feature names and its params. We will describe some of these features in more detail below.\n\nEach feature can be extracted from trace as dataframe with params as columns. For this we are using function `extract_feature_df` which is suitable for all features except TYPE_WIFI and TYPE_BEACON.\n\nThe table is taken from [competition's official github repo](https://github.com/location-competition/indoor-location-competition-20). (I've slightly modified it just for a more compact view)."},{"metadata":{},"cell_type":"markdown","source":"| Feature\t\t                    | Values |       |        |        |                   |        |           |                                   |\n|:----------------------------------|:------:|:-----:|:------:|:-------|:-----------------:|:------:|:---------:|:---------------------------------:|\n|TYPE_WAYPOINT                      |X axis  |Y axis |       |         |                   |        |           |                                   |\n|TYPE_ACCELEROMETER                 |X axis  |Y axis |Z axis |accuracy |                   |        |           |                                   |\n|TYPE_GYROSCOPE                     |X axis  |Y axis |Z axis |accuracy |                   |        |           |                                   | \n|TYPE_MAGNETIC_FIELD                |X axis  |Y axis |Z axis |accuracy |                   |        |           |                                   | \n|TYPE_ROTATION_VECTOR               |X axis  |Y axis |Z axis |accuracy |                   |        |           |                                   |\n|TYPE_ACCELEROMETER_UNCALIBRATED    |X axis  |Y axis |Z axis |X axis   |Y axis             |Z axis  |accuracy   |                                   |\n|TYPE_GYROSCOPE_UNCALIBRATED        |X axis  |Y axis |Z axis |X axis   |Y axis             |Z axis  |accuracy   |                                   |\n|TYPE_MAGNETIC_FIELD_UNCALIBRATED   |X axis  |Y axis |Z axis |X axis   |Y axis             |Z axis  |accuracy   |                                   |\n|TYPE_WIFI                          |ssid    |bssid  |RSSI   |frequency|last seen timestamp|        |           |                                   |\n|TYPE_BEACON                        |UUID    |MajorID|MinorID|Tx Power |RSSI               |Distance|MAC Address|same with Unix time, padding data  |\n"},{"metadata":{"papermill":{"duration":0.031648,"end_time":"2021-02-05T08:08:14.565590","exception":false,"start_time":"2021-02-05T08:08:14.533942","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# TYPE_WAYPOINT"},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:14.651263Z","iopub.status.busy":"2021-02-05T08:08:14.650572Z","iopub.status.idle":"2021-02-05T08:08:14.654715Z","shell.execute_reply":"2021-02-05T08:08:14.654118Z"},"papermill":{"duration":0.055924,"end_time":"2021-02-05T08:08:14.654856","exception":false,"start_time":"2021-02-05T08:08:14.598932","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"points_df = extract_feature_df(trace_df, 'TYPE_WAYPOINT', col_names=('x', 'y'))\npoints_df","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"visualize_single_trace_on_the_map(\n    points_df, MAP_IMAGE, MAP_WIDTH, MAP_HEIGHT, figsize=(10, 8)\n)","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.035529,"end_time":"2021-02-05T08:08:15.070657","exception":false,"start_time":"2021-02-05T08:08:15.035128","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# TYPE_ACCELEROMETER"},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:15.145433Z","iopub.status.busy":"2021-02-05T08:08:15.144493Z","iopub.status.idle":"2021-02-05T08:08:15.173015Z","shell.execute_reply":"2021-02-05T08:08:15.172393Z"},"papermill":{"duration":0.067015,"end_time":"2021-02-05T08:08:15.173154","exception":false,"start_time":"2021-02-05T08:08:15.106139","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"acc_df = extract_feature_df(trace_df, 'TYPE_ACCELEROMETER')\nacc_df","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:15.273086Z","iopub.status.busy":"2021-02-05T08:08:15.272034Z","iopub.status.idle":"2021-02-05T08:08:15.536283Z","shell.execute_reply":"2021-02-05T08:08:15.536802Z"},"papermill":{"duration":0.327609,"end_time":"2021-02-05T08:08:15.536973","exception":false,"start_time":"2021-02-05T08:08:15.209364","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"plot_trace_features(acc_df, points_df['time'], figsize=(20, 5))","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:15.630651Z","iopub.status.busy":"2021-02-05T08:08:15.629563Z","iopub.status.idle":"2021-02-05T08:08:17.662805Z","shell.execute_reply":"2021-02-05T08:08:17.662251Z"},"papermill":{"duration":2.083419,"end_time":"2021-02-05T08:08:17.662960","exception":false,"start_time":"2021-02-05T08:08:15.579541","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"sns.pairplot(acc_df[['x', 'y', 'z']])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.047012,"end_time":"2021-02-05T08:08:17.756991","exception":false,"start_time":"2021-02-05T08:08:17.709979","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# TYPE_GYROSCOPE"},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:17.866012Z","iopub.status.busy":"2021-02-05T08:08:17.859419Z","iopub.status.idle":"2021-02-05T08:08:17.883473Z","shell.execute_reply":"2021-02-05T08:08:17.882929Z"},"papermill":{"duration":0.079758,"end_time":"2021-02-05T08:08:17.883627","exception":false,"start_time":"2021-02-05T08:08:17.803869","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"gyro_df = extract_feature_df(trace_df, 'TYPE_GYROSCOPE')\ngyro_df","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:18.000958Z","iopub.status.busy":"2021-02-05T08:08:18.000251Z","iopub.status.idle":"2021-02-05T08:08:18.280265Z","shell.execute_reply":"2021-02-05T08:08:18.280793Z"},"papermill":{"duration":0.349333,"end_time":"2021-02-05T08:08:18.280971","exception":false,"start_time":"2021-02-05T08:08:17.931638","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"plot_trace_features(gyro_df, points_df['time'], figsize=(20, 5))","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:18.396656Z","iopub.status.busy":"2021-02-05T08:08:18.395932Z","iopub.status.idle":"2021-02-05T08:08:20.628301Z","shell.execute_reply":"2021-02-05T08:08:20.628835Z"},"papermill":{"duration":2.294228,"end_time":"2021-02-05T08:08:20.629047","exception":false,"start_time":"2021-02-05T08:08:18.334819","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"sns.pairplot(gyro_df[['x', 'y', 'z']])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.059088,"end_time":"2021-02-05T08:08:20.746637","exception":false,"start_time":"2021-02-05T08:08:20.687549","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# TYPE_MAGNETIC_FIELD"},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:20.867007Z","iopub.status.busy":"2021-02-05T08:08:20.866268Z","iopub.status.idle":"2021-02-05T08:08:20.892781Z","shell.execute_reply":"2021-02-05T08:08:20.893310Z"},"papermill":{"duration":0.088116,"end_time":"2021-02-05T08:08:20.893534","exception":false,"start_time":"2021-02-05T08:08:20.805418","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"magn_df = extract_feature_df(trace_df, 'TYPE_MAGNETIC_FIELD')\nmagn_df","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:21.013985Z","iopub.status.busy":"2021-02-05T08:08:21.013271Z","iopub.status.idle":"2021-02-05T08:08:21.291081Z","shell.execute_reply":"2021-02-05T08:08:21.290381Z"},"papermill":{"duration":0.339576,"end_time":"2021-02-05T08:08:21.291238","exception":false,"start_time":"2021-02-05T08:08:20.951662","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"plot_trace_features(magn_df, points_df['time'], figsize=(20, 5))","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:21.439556Z","iopub.status.busy":"2021-02-05T08:08:21.420656Z","iopub.status.idle":"2021-02-05T08:08:23.268969Z","shell.execute_reply":"2021-02-05T08:08:23.268439Z"},"papermill":{"duration":1.916574,"end_time":"2021-02-05T08:08:23.269124","exception":false,"start_time":"2021-02-05T08:08:21.352550","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"sns.pairplot(magn_df[['x', 'y', 'z']])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"papermill":{"duration":0.065002,"end_time":"2021-02-05T08:08:23.400495","exception":false,"start_time":"2021-02-05T08:08:23.335493","status":"completed"},"tags":[]},"cell_type":"markdown","source":"# TYPE_ROTATION_VECTOR"},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:23.540161Z","iopub.status.busy":"2021-02-05T08:08:23.539102Z","iopub.status.idle":"2021-02-05T08:08:23.562928Z","shell.execute_reply":"2021-02-05T08:08:23.562375Z"},"papermill":{"duration":0.097645,"end_time":"2021-02-05T08:08:23.563068","exception":false,"start_time":"2021-02-05T08:08:23.465423","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"rot_df = extract_feature_df(trace_df, 'TYPE_ROTATION_VECTOR')\nrot_df","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:23.728715Z","iopub.status.busy":"2021-02-05T08:08:23.723483Z","iopub.status.idle":"2021-02-05T08:08:23.978115Z","shell.execute_reply":"2021-02-05T08:08:23.977446Z"},"papermill":{"duration":0.348967,"end_time":"2021-02-05T08:08:23.978284","exception":false,"start_time":"2021-02-05T08:08:23.629317","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"plot_trace_features(rot_df, points_df['time'], figsize=(20, 5))","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-05T08:08:24.122553Z","iopub.status.busy":"2021-02-05T08:08:24.121861Z","iopub.status.idle":"2021-02-05T08:08:26.159437Z","shell.execute_reply":"2021-02-05T08:08:26.158910Z"},"papermill":{"duration":2.112074,"end_time":"2021-02-05T08:08:26.159590","exception":false,"start_time":"2021-02-05T08:08:24.047516","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"sns.pairplot(rot_df[['x', 'y', 'z']])\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# References\n* [Trace Parsing Script](https://www.kaggle.com/c/indoor-location-navigation/discussion/215381)\n* [Competition's Github Repository](https://github.com/location-competition/indoor-location-competition-20)"},{"metadata":{"papermill":{"duration":0.071209,"end_time":"2021-02-05T08:08:26.302734","exception":false,"start_time":"2021-02-05T08:08:26.231525","status":"completed"},"tags":[]},"cell_type":"markdown","source":"## Hope this notebook will be helpful for you. I wish you good fortune in the competition!"}],"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":4,"nbformat_minor":4}