{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\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","execution":{"iopub.status.busy":"2022-05-05T12:57:00.497954Z","iopub.execute_input":"2022-05-05T12:57:00.498322Z","iopub.status.idle":"2022-05-05T12:57:03.480423Z","shell.execute_reply.started":"2022-05-05T12:57:00.498223Z","shell.execute_reply":"2022-05-05T12:57:03.479486Z"},"_kg_hide-output":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Reference Notebook: https://www.kaggle.com/code/nayuts/let-s-visualize-dataset-to-understand\n\nI am participating in this competitions with no prior experience of working on this kind of data, I have used the reference notebook above to visualize the data, the credit for this notebook goes to the original contributor!","metadata":{}},{"cell_type":"markdown","source":"# How input data is structured?","metadata":{}},{"cell_type":"code","source":"!ls /kaggle/input/smartphone-decimeter-2022/train","metadata":{"execution":{"iopub.status.busy":"2022-05-05T12:57:35.481830Z","iopub.execute_input":"2022-05-05T12:57:35.482112Z","iopub.status.idle":"2022-05-05T12:57:36.303679Z","shell.execute_reply.started":"2022-05-05T12:57:35.482082Z","shell.execute_reply":"2022-05-05T12:57:36.302354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls /kaggle/input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1","metadata":{"execution":{"iopub.status.busy":"2022-05-05T12:58:48.015756Z","iopub.execute_input":"2022-05-05T12:58:48.016373Z","iopub.status.idle":"2022-05-05T12:58:48.842843Z","shell.execute_reply.started":"2022-05-05T12:58:48.016326Z","shell.execute_reply":"2022-05-05T12:58:48.841220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls /kaggle/input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1/GooglePixel4XL","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:00:17.278797Z","iopub.execute_input":"2022-05-05T13:00:17.279151Z","iopub.status.idle":"2022-05-05T13:00:18.100072Z","shell.execute_reply.started":"2022-05-05T13:00:17.279111Z","shell.execute_reply":"2022-05-05T13:00:18.098826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls /kaggle/input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1/GooglePixel4XL/supplemental","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:01:14.969667Z","iopub.execute_input":"2022-05-05T13:01:14.969966Z","iopub.status.idle":"2022-05-05T13:01:15.794067Z","shell.execute_reply.started":"2022-05-05T13:01:14.969926Z","shell.execute_reply":"2022-05-05T13:01:15.793092Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#loading data\n\ndf_dev_imu = pd.read_csv(\"/kaggle/input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1/GooglePixel4XL/device_imu.csv\")\ndf_dev_gt = pd.read_csv(\"/kaggle/input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1/GooglePixel4XL/ground_truth.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:08:10.816302Z","iopub.execute_input":"2022-05-05T13:08:10.816595Z","iopub.status.idle":"2022-05-05T13:08:11.469168Z","shell.execute_reply.started":"2022-05-05T13:08:10.816562Z","shell.execute_reply":"2022-05-05T13:08:11.468496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_dev_imu.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:08:13.231676Z","iopub.execute_input":"2022-05-05T13:08:13.232840Z","iopub.status.idle":"2022-05-05T13:08:13.251821Z","shell.execute_reply.started":"2022-05-05T13:08:13.232777Z","shell.execute_reply":"2022-05-05T13:08:13.250755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_dev_gt.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:08:26.873962Z","iopub.execute_input":"2022-05-05T13:08:26.874266Z","iopub.status.idle":"2022-05-05T13:08:26.889933Z","shell.execute_reply.started":"2022-05-05T13:08:26.874234Z","shell.execute_reply":"2022-05-05T13:08:26.889320Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def visualize_traffic(df, zoom=9):\n    fig = px.scatter_mapbox(df,\n                            \n                            # Here, plotly gets, (x,y) coordinates\n                            lat=\"LatitudeDegrees\",\n                            lon=\"LongitudeDegrees\",\n                            \n                            #Here, plotly detects color of series\n                            \n                            zoom=zoom,\n                            height=600,\n                            width=800)\n    fig.update_layout(mapbox_style='stamen-terrain')\n    fig.update_layout(margin={\"r\": 0, \"t\": 0, \"l\": 0, \"b\": 0})\n    fig.update_layout(title_text=\"GPS trafic\")\n    fig.show()","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:16:32.544238Z","iopub.execute_input":"2022-05-05T13:16:32.544792Z","iopub.status.idle":"2022-05-05T13:16:32.550893Z","shell.execute_reply.started":"2022-05-05T13:16:32.544758Z","shell.execute_reply":"2022-05-05T13:16:32.549848Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nvisualize_traffic(df_dev_gt)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:17:15.685259Z","iopub.execute_input":"2022-05-05T13:17:15.686344Z","iopub.status.idle":"2022-05-05T13:17:18.925641Z","shell.execute_reply.started":"2022-05-05T13:17:15.686282Z","shell.execute_reply":"2022-05-05T13:17:18.924818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Plotting tracks for the same route from different phones","metadata":{}},{"cell_type":"code","source":"!ls /kaggle/input/smartphone-decimeter-2022/train/2021-12-28-US-MTV-1","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:22:20.311480Z","iopub.execute_input":"2022-05-05T13:22:20.311787Z","iopub.status.idle":"2022-05-05T13:22:21.152933Z","shell.execute_reply.started":"2022-05-05T13:22:20.311741Z","shell.execute_reply":"2022-05-05T13:22:21.151827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_dev_gt2 = pd.read_csv(\"/kaggle/input/smartphone-decimeter-2022/train/2021-12-28-US-MTV-1/GooglePixel5/ground_truth.csv\")\ndf_dev_gt3 = pd.read_csv(\"/kaggle/input/smartphone-decimeter-2022/train/2021-12-28-US-MTV-1/GooglePixel6Pro/ground_truth.csv\")\ndf_dev_gt4 = pd.read_csv(\"/kaggle/input/smartphone-decimeter-2022/train/2021-12-28-US-MTV-1/SamsungGalaxyS20Ultra/ground_truth.csv\")\ndf_dev_gt5 = pd.read_csv(\"/kaggle/input/smartphone-decimeter-2022/train/2021-12-28-US-MTV-1/XiaomiMi8/ground_truth.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:24:52.428449Z","iopub.execute_input":"2022-05-05T13:24:52.428924Z","iopub.status.idle":"2022-05-05T13:24:52.483005Z","shell.execute_reply.started":"2022-05-05T13:24:52.428876Z","shell.execute_reply":"2022-05-05T13:24:52.482307Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"visualize_traffic(df_dev_gt2)\nvisualize_traffic(df_dev_gt3)\nvisualize_traffic(df_dev_gt4)\nvisualize_traffic(df_dev_gt5)","metadata":{"execution":{"iopub.status.busy":"2022-05-05T13:25:56.679751Z","iopub.execute_input":"2022-05-05T13:25:56.680162Z","iopub.status.idle":"2022-05-05T13:25:56.912015Z","shell.execute_reply.started":"2022-05-05T13:25:56.680118Z","shell.execute_reply":"2022-05-05T13:25:56.911081Z"},"trusted":true},"execution_count":null,"outputs":[]}]}