{"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":"conda install -c conda-forge lightgbm","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:11.901127Z","iopub.execute_input":"2022-11-03T04:37:11.902694Z","iopub.status.idle":"2022-11-03T04:37:16.739218Z","shell.execute_reply.started":"2022-11-03T04:37:11.902635Z","shell.execute_reply":"2022-11-03T04:37:16.737145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport matplotlib\nimport matplotlib.pyplot as plt\nimport pandas as pd\nimport seaborn as sns\nimport os\n!pip install folium\n!pip install simdkalman\nimport pickle\nimport sys\nimport warnings\nfrom glob import glob\nimport requests\nimport folium\nfrom shapely.geometry import Point, shape\nimport shapely.wkt\nfrom geopandas import GeoDataFrame\nimport simdkalman\nimport shap\nimport xgboost\nfrom scipy.stats import spearmanr\nfrom sklearn.ensemble import (\n    ExtraTreesRegressor,\n    GradientBoostingRegressor,\n    RandomForestRegressor,\n)\nfrom sklearn.metrics import accuracy_score, mean_squared_error\nfrom tqdm.notebook import tqdm\npd.options.mode.use_inf_as_na = True","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:16.742128Z","iopub.execute_input":"2022-11-03T04:37:16.742681Z","iopub.status.idle":"2022-11-03T04:37:40.019879Z","shell.execute_reply.started":"2022-11-03T04:37:16.742629Z","shell.execute_reply":"2022-11-03T04:37:40.018660Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for dirname, _,filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname,filename))","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.021318Z","iopub.execute_input":"2022-11-03T04:37:40.021700Z","iopub.status.idle":"2022-11-03T04:37:40.661569Z","shell.execute_reply.started":"2022-11-03T04:37:40.021665Z","shell.execute_reply":"2022-11-03T04:37:40.660149Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nos.listdir('/kaggle/input/')","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.665181Z","iopub.execute_input":"2022-11-03T04:37:40.665734Z","iopub.status.idle":"2022-11-03T04:37:40.674619Z","shell.execute_reply.started":"2022-11-03T04:37:40.665686Z","shell.execute_reply":"2022-11-03T04:37:40.673414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data=pd.read_csv('../input/smartphone-decimeter-2022/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.676069Z","iopub.execute_input":"2022-11-03T04:37:40.677537Z","iopub.status.idle":"2022-11-03T04:37:40.758618Z","shell.execute_reply.started":"2022-11-03T04:37:40.677496Z","shell.execute_reply":"2022-11-03T04:37:40.757266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.760252Z","iopub.execute_input":"2022-11-03T04:37:40.760829Z","iopub.status.idle":"2022-11-03T04:37:40.766598Z","shell.execute_reply.started":"2022-11-03T04:37:40.760793Z","shell.execute_reply":"2022-11-03T04:37:40.765126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.768552Z","iopub.execute_input":"2022-11-03T04:37:40.768960Z","iopub.status.idle":"2022-11-03T04:37:40.790110Z","shell.execute_reply.started":"2022-11-03T04:37:40.768927Z","shell.execute_reply":"2022-11-03T04:37:40.788780Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.info()","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.791581Z","iopub.execute_input":"2022-11-03T04:37:40.792697Z","iopub.status.idle":"2022-11-03T04:37:40.814717Z","shell.execute_reply.started":"2022-11-03T04:37:40.792660Z","shell.execute_reply":"2022-11-03T04:37:40.813699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['tripId'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.815734Z","iopub.execute_input":"2022-11-03T04:37:40.816176Z","iopub.status.idle":"2022-11-03T04:37:40.830396Z","shell.execute_reply.started":"2022-11-03T04:37:40.816110Z","shell.execute_reply":"2022-11-03T04:37:40.828811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X=data[['UnixTimeMillis','LatitudeDegrees','LongitudeDegrees']]\ny=data['tripId']","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.836693Z","iopub.execute_input":"2022-11-03T04:37:40.837170Z","iopub.status.idle":"2022-11-03T04:37:40.848964Z","shell.execute_reply.started":"2022-11-03T04:37:40.837132Z","shell.execute_reply":"2022-11-03T04:37:40.847744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data=pd.DataFrame(data)\nprint(df)","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.850882Z","iopub.execute_input":"2022-11-03T04:37:40.851554Z","iopub.status.idle":"2022-11-03T04:37:40.869632Z","shell.execute_reply.started":"2022-11-03T04:37:40.851509Z","shell.execute_reply":"2022-11-03T04:37:40.868678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":" X=data.iloc[:,[2,3]].values\nprint(X)","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.870966Z","iopub.execute_input":"2022-11-03T04:37:40.871339Z","iopub.status.idle":"2022-11-03T04:37:40.886690Z","shell.execute_reply.started":"2022-11-03T04:37:40.871293Z","shell.execute_reply":"2022-11-03T04:37:40.885664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y=data.iloc[:,0:4].values\nprint(y)","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.888090Z","iopub.execute_input":"2022-11-03T04:37:40.888481Z","iopub.status.idle":"2022-11-03T04:37:40.920834Z","shell.execute_reply.started":"2022-11-03T04:37:40.888447Z","shell.execute_reply":"2022-11-03T04:37:40.919532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cname_ = glob('../input/smartphone-decimeter-2022/train/*')\ntmp = []\nfor i in cname_:\n    tmp.extend(glob(f'{i}/*'))\n\ncname=[]\n\nfor r in tmp:\n    cname.append([r.split('/')[4],r.split('/')[5]])\n    \ncname = pd.DataFrame(sorted(cname))\ncname","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.922244Z","iopub.execute_input":"2022-11-03T04:37:40.922631Z","iopub.status.idle":"2022-11-03T04:37:40.973830Z","shell.execute_reply.started":"2022-11-03T04:37:40.922598Z","shell.execute_reply":"2022-11-03T04:37:40.972937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cname[1].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.975574Z","iopub.execute_input":"2022-11-03T04:37:40.975902Z","iopub.status.idle":"2022-11-03T04:37:40.984851Z","shell.execute_reply.started":"2022-11-03T04:37:40.975869Z","shell.execute_reply":"2022-11-03T04:37:40.983771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cname_ = glob('../input/smartphone-decimeter-2022/test/*')\ntmp = []\nfor i in cname_:\n    tmp.extend(glob(f'{i}/*'))\n\ncname=[]\n\nfor r in tmp:\n    cname.append([r.split('/')[4],r.split('/')[5]])\n    \ncname = pd.DataFrame(sorted(cname))\ncname[1].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:40.986210Z","iopub.execute_input":"2022-11-03T04:37:40.986553Z","iopub.status.idle":"2022-11-03T04:37:41.022639Z","shell.execute_reply.started":"2022-11-03T04:37:40.986523Z","shell.execute_reply":"2022-11-03T04:37:41.021849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import json\nraw = open('../input/smartphone-decimeter-2022/metadata/raw_state_bit_map.json', 'r')\njson.load(raw)","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:41.024057Z","iopub.execute_input":"2022-11-03T04:37:41.024585Z","iopub.status.idle":"2022-11-03T04:37:41.034953Z","shell.execute_reply.started":"2022-11-03T04:37:41.024552Z","shell.execute_reply":"2022-11-03T04:37:41.034080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import json\nbit = open('../input/smartphone-decimeter-2022/metadata/accumulated_delta_range_state_bit_map.json', 'r')\njson.load(bit)","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:41.036276Z","iopub.execute_input":"2022-11-03T04:37:41.036826Z","iopub.status.idle":"2022-11-03T04:37:41.050534Z","shell.execute_reply.started":"2022-11-03T04:37:41.036787Z","shell.execute_reply":"2022-11-03T04:37:41.049070Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mapping = pd.read_csv('../input/smartphone-decimeter-2022/metadata/constellation_type_mapping.csv')\nmapping","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:41.054335Z","iopub.execute_input":"2022-11-03T04:37:41.055823Z","iopub.status.idle":"2022-11-03T04:37:41.074844Z","shell.execute_reply.started":"2022-11-03T04:37:41.055768Z","shell.execute_reply":"2022-11-03T04:37:41.073410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ground = pd.read_csv('../input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1/GooglePixel4XL/ground_truth.csv')\nground","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:41.076272Z","iopub.execute_input":"2022-11-03T04:37:41.076649Z","iopub.status.idle":"2022-11-03T04:37:41.113413Z","shell.execute_reply.started":"2022-11-03T04:37:41.076615Z","shell.execute_reply":"2022-11-03T04:37:41.112109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imu= pd.read_csv('../input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1/GooglePixel4XL/device_imu.csv')\nimu","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:41.115146Z","iopub.execute_input":"2022-11-03T04:37:41.116561Z","iopub.status.idle":"2022-11-03T04:37:42.512570Z","shell.execute_reply.started":"2022-11-03T04:37:41.116510Z","shell.execute_reply":"2022-11-03T04:37:42.511134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gnss = pd.read_csv('../input/smartphone-decimeter-2022/train/2020-05-15-US-MTV-1/GooglePixel4XL/device_gnss.csv')\ngnss","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:42.515342Z","iopub.execute_input":"2022-11-03T04:37:42.516673Z","iopub.status.idle":"2022-11-03T04:37:44.201190Z","shell.execute_reply.started":"2022-11-03T04:37:42.516625Z","shell.execute_reply":"2022-11-03T04:37:44.199836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from folium import plugins\ndf_locs = list(ground[['LatitudeDegrees','LongitudeDegrees']].values)\nfol_map = folium.Map([ground['LatitudeDegrees'].median(), ground['LongitudeDegrees'].median()],zoom_start=11)\nheat_map = plugins.HeatMap(df_locs)\nfol_map.add_child(heat_map)\nmarkers = plugins.MarkerCluster(locations = df_locs)\nfol_map.add_child(markers)","metadata":{"execution":{"iopub.status.busy":"2022-11-03T04:37:44.203400Z","iopub.execute_input":"2022-11-03T04:37:44.203945Z","iopub.status.idle":"2022-11-03T04:37:46.629858Z","shell.execute_reply.started":"2022-11-03T04:37:44.203897Z","shell.execute_reply":"2022-11-03T04:37:46.627602Z"},"trusted":true},"execution_count":null,"outputs":[]}]}