{"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\n# import numpy as np # linear algebra\n# import 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-08-13T02:41:44.983601Z","iopub.execute_input":"2022-08-13T02:41:44.984310Z","iopub.status.idle":"2022-08-13T02:41:45.021600Z","shell.execute_reply.started":"2022-08-13T02:41:44.984172Z","shell.execute_reply":"2022-08-13T02:41:45.019934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nimport re\nimport time\nfrom datetime import datetime\n\nimport numpy as np\nfrom scipy import stats\nimport pandas as pd\npd.set_option('max_columns', 30)\npd.options.display.float_format = '{:.4f}'.format\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport plotly.graph_objects as go\nimport plotly.express as px\n%matplotlib inline\n\nfrom sklearn.metrics import mean_squared_error\nfrom sklearn.metrics import mean_squared_error\nfrom sklearn.preprocessing import MinMaxScaler,StandardScaler\nfrom sklearn.model_selection import StratifiedKFold, GroupKFold, train_test_split\n\nimport warnings\nwarnings.simplefilter('ignore')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:41:45.050577Z","iopub.execute_input":"2022-08-13T02:41:45.051159Z","iopub.status.idle":"2022-08-13T02:41:47.145599Z","shell.execute_reply.started":"2022-08-13T02:41:45.051103Z","shell.execute_reply":"2022-08-13T02:41:47.144364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking_table = '/kaggle/input/big-data-derby-2022/nyra_tracking_table.csv'\nnyra_start_table = '/kaggle/input/big-data-derby-2022/nyra_start_table.csv'\nnyra_race_table = '/kaggle/input/big-data-derby-2022/nyra_race_table.csv'\nnyra_2019_complete = '/kaggle/input/big-data-derby-2022/nyra_2019_complete.csv'","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:41:47.148124Z","iopub.execute_input":"2022-08-13T02:41:47.148516Z","iopub.status.idle":"2022-08-13T02:41:47.153597Z","shell.execute_reply.started":"2022-08-13T02:41:47.148477Z","shell.execute_reply":"2022-08-13T02:41:47.152503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking = pd.read_csv(nyra_tracking_table)\nstart = pd.read_csv(nyra_start_table)\nrace = pd.read_csv(nyra_race_table)\ncomplete = pd.read_csv(nyra_2019_complete)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:41:47.155362Z","iopub.execute_input":"2022-08-13T02:41:47.155935Z","iopub.status.idle":"2022-08-13T02:42:11.252992Z","shell.execute_reply.started":"2022-08-13T02:41:47.155870Z","shell.execute_reply":"2022-08-13T02:42:11.251712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'tracking data size is {tracking.size}')\nprint(f'start data size is {start.size}')\nprint(f'race data size is {race.size}')\nprint(f'complete data size is {complete.size}')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:11.255713Z","iopub.execute_input":"2022-08-13T02:42:11.256112Z","iopub.status.idle":"2022-08-13T02:42:11.262633Z","shell.execute_reply.started":"2022-08-13T02:42:11.256077Z","shell.execute_reply":"2022-08-13T02:42:11.261229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'tracking data info is {tracking.info()}\\n')\nprint(f'start data info is {start.info()}\\n')\nprint(f'race data info is {race.info()}\\n')\nprint(f'complete info size is {complete.info()}\\n')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:11.264159Z","iopub.execute_input":"2022-08-13T02:42:11.264504Z","iopub.status.idle":"2022-08-13T02:42:11.323655Z","shell.execute_reply.started":"2022-08-13T02:42:11.264474Z","shell.execute_reply":"2022-08-13T02:42:11.322422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'{tracking.head()}\\n')\nprint(f'{start.head()}\\n')\nprint(f'{race.head()}\\n')\nprint(f'{complete.head()}\\n')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:11.325409Z","iopub.execute_input":"2022-08-13T02:42:11.325830Z","iopub.status.idle":"2022-08-13T02:42:11.355544Z","shell.execute_reply.started":"2022-08-13T02:42:11.325792Z","shell.execute_reply":"2022-08-13T02:42:11.354013Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'{tracking.nunique()}\\n')\nprint(f'{start.nunique()}\\n')\nprint(f'{race.nunique()}\\n')\nprint(f'{complete.nunique()}\\n')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:11.357838Z","iopub.execute_input":"2022-08-13T02:42:11.358334Z","iopub.status.idle":"2022-08-13T02:42:19.102149Z","shell.execute_reply.started":"2022-08-13T02:42:11.358291Z","shell.execute_reply":"2022-08-13T02:42:19.100845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking['track_id'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:19.103994Z","iopub.execute_input":"2022-08-13T02:42:19.104633Z","iopub.status.idle":"2022-08-13T02:42:19.432445Z","shell.execute_reply.started":"2022-08-13T02:42:19.104595Z","shell.execute_reply":"2022-08-13T02:42:19.431347Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'Start date {tracking[\"race_date\"].min()}')\nprint(f'End date   {tracking[\"race_date\"].max()}')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:19.433891Z","iopub.execute_input":"2022-08-13T02:42:19.434292Z","iopub.status.idle":"2022-08-13T02:42:20.164528Z","shell.execute_reply.started":"2022-08-13T02:42:19.434259Z","shell.execute_reply":"2022-08-13T02:42:20.163091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(start[\"jockey\"].nunique())\nprint(start[\"jockey\"].unique())","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:20.169618Z","iopub.execute_input":"2022-08-13T02:42:20.170435Z","iopub.status.idle":"2022-08-13T02:42:20.182215Z","shell.execute_reply.started":"2022-08-13T02:42:20.170381Z","shell.execute_reply":"2022-08-13T02:42:20.180024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start[\"jockey\"].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:20.184662Z","iopub.execute_input":"2022-08-13T02:42:20.185217Z","iopub.status.idle":"2022-08-13T02:42:20.197360Z","shell.execute_reply.started":"2022-08-13T02:42:20.185171Z","shell.execute_reply":"2022-08-13T02:42:20.195996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'Start date {complete[\"race_date\"].min()}')\nprint(f'End date   {complete[\"race_date\"].max()}')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:42:49.418766Z","iopub.execute_input":"2022-08-13T02:42:49.419293Z","iopub.status.idle":"2022-08-13T02:42:50.147957Z","shell.execute_reply.started":"2022-08-13T02:42:49.419254Z","shell.execute_reply":"2022-08-13T02:42:50.146436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"complete data is splited tracking, start, race ","metadata":{}},{"cell_type":"code","source":"tracking.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:44:35.665969Z","iopub.execute_input":"2022-08-13T02:44:35.666411Z","iopub.status.idle":"2022-08-13T02:44:35.684948Z","shell.execute_reply.started":"2022-08-13T02:44:35.666374Z","shell.execute_reply":"2022-08-13T02:44:35.683550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.groupby(['race_number','program_number']).count()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:49:33.587685Z","iopub.execute_input":"2022-08-13T02:49:33.588248Z","iopub.status.idle":"2022-08-13T02:49:34.885744Z","shell.execute_reply.started":"2022-08-13T02:49:33.588199Z","shell.execute_reply":"2022-08-13T02:49:34.884249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(tracking['trakus_index'].unique())\nprint(tracking['trakus_index'].nunique())\nprint(tracking['trakus_index'].min())\nprint(tracking['trakus_index'].max())","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:50:28.521117Z","iopub.execute_input":"2022-08-13T02:50:28.521691Z","iopub.status.idle":"2022-08-13T02:50:28.616464Z","shell.execute_reply.started":"2022-08-13T02:50:28.521641Z","shell.execute_reply":"2022-08-13T02:50:28.613667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking['trakus_index'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:59:02.949264Z","iopub.execute_input":"2022-08-13T02:59:02.950604Z","iopub.status.idle":"2022-08-13T02:59:02.996652Z","shell.execute_reply.started":"2022-08-13T02:59:02.950531Z","shell.execute_reply":"2022-08-13T02:59:02.995254Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(tracking['trakus_index'])","metadata":{"execution":{"iopub.status.busy":"2022-08-13T02:59:23.353303Z","iopub.execute_input":"2022-08-13T02:59:23.354895Z","iopub.status.idle":"2022-08-13T02:59:23.363126Z","shell.execute_reply.started":"2022-08-13T02:59:23.354838Z","shell.execute_reply":"2022-08-13T02:59:23.361867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.groupby('trakus_index').count()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T03:05:32.987287Z","iopub.execute_input":"2022-08-13T03:05:32.987902Z","iopub.status.idle":"2022-08-13T03:05:34.065432Z","shell.execute_reply.started":"2022-08-13T03:05:32.987863Z","shell.execute_reply":"2022-08-13T03:05:34.064526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T03:05:56.575212Z","iopub.execute_input":"2022-08-13T03:05:56.575736Z","iopub.status.idle":"2022-08-13T03:05:57.322191Z","shell.execute_reply.started":"2022-08-13T03:05:56.575695Z","shell.execute_reply":"2022-08-13T03:05:57.320918Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking['race_number'].mode()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T03:09:16.143800Z","iopub.execute_input":"2022-08-13T03:09:16.144934Z","iopub.status.idle":"2022-08-13T03:09:16.200249Z","shell.execute_reply.started":"2022-08-13T03:09:16.144862Z","shell.execute_reply":"2022-08-13T03:09:16.198933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking[tracking['race_number'] == 8]","metadata":{"execution":{"iopub.status.busy":"2022-08-13T03:10:49.890427Z","iopub.execute_input":"2022-08-13T03:10:49.890884Z","iopub.status.idle":"2022-08-13T03:10:49.967451Z","shell.execute_reply.started":"2022-08-13T03:10:49.890849Z","shell.execute_reply":"2022-08-13T03:10:49.965972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T03:16:53.726832Z","iopub.execute_input":"2022-08-13T03:16:53.727248Z","iopub.status.idle":"2022-08-13T03:16:53.741017Z","shell.execute_reply.started":"2022-08-13T03:16:53.727214Z","shell.execute_reply":"2022-08-13T03:16:53.739474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"raw","source":"","metadata":{}},{"cell_type":"code","source":"aqu = tracking[tracking['track_id'] == 'BEL']\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = aqu, x = \"longitude\", y = \"latitude\", hue = \"race_number\")\n\nplt.title(\"track_id = BEL, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T03:23:43.659936Z","iopub.execute_input":"2022-08-13T03:23:43.660472Z","iopub.status.idle":"2022-08-13T03:24:31.070406Z","shell.execute_reply.started":"2022-08-13T03:23:43.660433Z","shell.execute_reply":"2022-08-13T03:24:31.069092Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"aqu = tracking[tracking['track_id'] == 'AQU']\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = aqu, x = \"longitude\", y = \"latitude\", hue = \"race_number\")\n\nplt.title(\"track_id = AQU, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T03:25:16.066198Z","iopub.execute_input":"2022-08-13T03:25:16.067158Z","iopub.status.idle":"2022-08-13T03:26:14.753995Z","shell.execute_reply.started":"2022-08-13T03:25:16.067111Z","shell.execute_reply":"2022-08-13T03:26:14.752522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"aqu = tracking[tracking['track_id'] == 'SAR']\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = aqu, x = \"longitude\", y = \"latitude\", hue = \"race_number\")\n\nplt.title(\"track_id = SAR, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{},"execution_count":null,"outputs":[]}]}