{"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":" import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport plotly.express as px #graphing\nimport plotly.graph_objects as go #graphing\nfrom plotly.subplots import make_subplots #graphing\nimport plotly.figure_factory as ff #graphing\nimport matplotlib.pyplot as plt #graphing\nimport seaborn as sns #graphing\nimport missingno as msno #describe data\nimport os\n\ncolors = [\"#FFFFFF\", \"#6CD4FF\", \"#F7DF00\", \"#E60000\"]\nrace_colors = [ 'Set2', 'Set2_r', 'Set3', 'crest_r', 'BuPu', 'cubehelix', 'CMRmap', 'CMRmap_r', 'Dark2', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn',]\n\nfrom plotly.offline import plot, iplot, init_notebook_mode\nimport plotly.graph_objs as go\ninit_notebook_mode(connected=True)\n\nplt.rcParams[\"figure.figsize\"] = (12, 8)\n\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-12T21:09:29.173091Z","iopub.execute_input":"2022-08-12T21:09:29.173704Z","iopub.status.idle":"2022-08-12T21:09:29.191163Z","shell.execute_reply.started":"2022-08-12T21:09:29.173627Z","shell.execute_reply":"2022-08-12T21:09:29.190066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The goal of this competition is to analyze horse racing tactics, drafting strategies, and path efficiency. You will develop a model using never-before-released coordinate data along with basic race information.","metadata":{}},{"cell_type":"code","source":"nyra_tracking = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_tracking_table.csv\")\nnyra_start = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_start_table.csv\")\nnyra_race = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_race_table.csv\")\nnyra_2019 = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_2019_complete.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:29.200604Z","iopub.execute_input":"2022-08-12T21:09:29.202234Z","iopub.status.idle":"2022-08-12T21:09:42.448630Z","shell.execute_reply.started":"2022-08-12T21:09:29.202183Z","shell.execute_reply":"2022-08-12T21:09:42.447369Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_2019.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:42.450971Z","iopub.execute_input":"2022-08-12T21:09:42.451452Z","iopub.status.idle":"2022-08-12T21:09:42.471826Z","shell.execute_reply.started":"2022-08-12T21:09:42.451407Z","shell.execute_reply":"2022-08-12T21:09:42.470696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:42.473215Z","iopub.execute_input":"2022-08-12T21:09:42.474263Z","iopub.status.idle":"2022-08-12T21:09:42.494794Z","shell.execute_reply.started":"2022-08-12T21:09:42.474229Z","shell.execute_reply":"2022-08-12T21:09:42.493241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking.describe().style.background_gradient(cmap = \"Purples\")","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:42.497248Z","iopub.execute_input":"2022-08-12T21:09:42.497564Z","iopub.status.idle":"2022-08-12T21:09:43.114886Z","shell.execute_reply.started":"2022-08-12T21:09:42.497536Z","shell.execute_reply":"2022-08-12T21:09:43.113735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking.track_id.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:43.116561Z","iopub.execute_input":"2022-08-12T21:09:43.116913Z","iopub.status.idle":"2022-08-12T21:09:43.470192Z","shell.execute_reply.started":"2022-08-12T21:09:43.116882Z","shell.execute_reply":"2022-08-12T21:09:43.469188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking.program_number.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:43.471328Z","iopub.execute_input":"2022-08-12T21:09:43.471869Z","iopub.status.idle":"2022-08-12T21:09:43.799752Z","shell.execute_reply.started":"2022-08-12T21:09:43.471834Z","shell.execute_reply":"2022-08-12T21:09:43.798508Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking['race_date'] = pd.to_datetime(nyra_tracking['race_date'])\nnyra_tracking['day'], nyra_tracking['month'] = nyra_tracking['race_date'].dt.day, nyra_tracking['race_date'].dt.month","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:43.801273Z","iopub.execute_input":"2022-08-12T21:09:43.801637Z","iopub.status.idle":"2022-08-12T21:09:45.508205Z","shell.execute_reply.started":"2022-08-12T21:09:43.801605Z","shell.execute_reply":"2022-08-12T21:09:45.507248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"track_id = AQU¶","metadata":{}},{"cell_type":"code","source":"nyra_tracking0 = nyra_tracking[nyra_tracking[\"track_id\"] == \"AQU\"]\nnyra_tracking1 = nyra_tracking0[nyra_tracking0[\"month\"] == 11]\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = nyra_tracking1, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = \"Set2\")\n\nplt.title(\"track_id = AQU, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:09:45.509513Z","iopub.execute_input":"2022-08-12T21:09:45.510493Z","iopub.status.idle":"2022-08-12T21:10:01.634370Z","shell.execute_reply.started":"2022-08-12T21:09:45.510448Z","shell.execute_reply":"2022-08-12T21:10:01.633179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"track_id = BEL","metadata":{}},{"cell_type":"code","source":"nyra_tracking0 = nyra_tracking[nyra_tracking[\"track_id\"] == \"BEL\"]\nnyra_tracking1 = nyra_tracking0[nyra_tracking0[\"month\"] == 5]\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = nyra_tracking1, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = \"Set2\")\n\nplt.title(\"track_id = BEL, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:01.635925Z","iopub.execute_input":"2022-08-12T21:10:01.636357Z","iopub.status.idle":"2022-08-12T21:10:13.490807Z","shell.execute_reply.started":"2022-08-12T21:10:01.636324Z","shell.execute_reply":"2022-08-12T21:10:13.489733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"track_id = SAR","metadata":{}},{"cell_type":"code","source":"nyra_tracking0 = nyra_tracking[nyra_tracking[\"track_id\"] == \"SAR\"]\nnyra_tracking1 = nyra_tracking0[nyra_tracking0[\"month\"] == 9]\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = nyra_tracking1, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = \"Set2\")\n\nplt.title(\"track_id = SAR, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:13.495272Z","iopub.execute_input":"2022-08-12T21:10:13.495736Z","iopub.status.idle":"2022-08-12T21:10:15.950759Z","shell.execute_reply.started":"2022-08-12T21:10:13.495682Z","shell.execute_reply":"2022-08-12T21:10:15.946940Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_start.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:15.952292Z","iopub.execute_input":"2022-08-12T21:10:15.952698Z","iopub.status.idle":"2022-08-12T21:10:15.966334Z","shell.execute_reply.started":"2022-08-12T21:10:15.952635Z","shell.execute_reply":"2022-08-12T21:10:15.965525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_start['race_date'] = pd.to_datetime(nyra_start['race_date'])\nnyra_start['day'], nyra_start['month'] = nyra_start['race_date'].dt.day, nyra_start['race_date'].dt.month","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:15.967362Z","iopub.execute_input":"2022-08-12T21:10:15.968196Z","iopub.status.idle":"2022-08-12T21:10:15.987432Z","shell.execute_reply.started":"2022-08-12T21:10:15.968163Z","shell.execute_reply":"2022-08-12T21:10:15.986363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Odds of winning race","metadata":{}},{"cell_type":"code","source":"fig = px.scatter(nyra_start, x = \"program_number\", y = \"race_number\", hover_data = [ \"jockey\"],\n                 color = \"odds\", color_continuous_scale = colors, range_color = (0, 9999),\n                 title = \"Odds by Race Number & Program Number\")\n\nfig.update_traces(marker = dict(size = 16, symbol = \"square\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:15.988840Z","iopub.execute_input":"2022-08-12T21:10:15.989175Z","iopub.status.idle":"2022-08-12T21:10:16.487941Z","shell.execute_reply.started":"2022-08-12T21:10:15.989145Z","shell.execute_reply":"2022-08-12T21:10:16.486766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_start, x = \"weight_carried\", y = \"odds\", hover_data = [\"race_number\", \"jockey\"],\n                 color = \"odds\", color_continuous_scale = colors, range_color = (0, 9999),\n                 title = \"Odds by Weight Carried\")\n\nfig.update_traces(marker = dict(size = 8, symbol = \"circle\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:16.489395Z","iopub.execute_input":"2022-08-12T21:10:16.490061Z","iopub.status.idle":"2022-08-12T21:10:16.963186Z","shell.execute_reply.started":"2022-08-12T21:10:16.490001Z","shell.execute_reply":"2022-08-12T21:10:16.961928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_start, x = \"weight_carried\", y = \"day\", hover_data = [\"race_number\", \"jockey\"],\n                 color = \"odds\", color_continuous_scale = colors, range_color = (0, 9999),\n                 title = \"Odds by Day of Event and Weight Carried\")\n\nfig.update_traces(marker = dict(size = 9, symbol = \"square\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:16.965217Z","iopub.execute_input":"2022-08-12T21:10:16.966161Z","iopub.status.idle":"2022-08-12T21:10:17.274393Z","shell.execute_reply.started":"2022-08-12T21:10:16.966122Z","shell.execute_reply":"2022-08-12T21:10:17.273248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_start, x = \"weight_carried\", y = \"month\", hover_data = [\"race_number\", \"jockey\"],\n                 color = \"odds\", color_continuous_scale = colors, range_color = (0, 9999),\n                 title = \"Odds by Month of Event and Weight Carried\")\n\nfig.update_traces(marker = dict(size = 11, symbol = \"circle\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:17.275919Z","iopub.execute_input":"2022-08-12T21:10:17.276238Z","iopub.status.idle":"2022-08-12T21:10:17.739293Z","shell.execute_reply.started":"2022-08-12T21:10:17.276208Z","shell.execute_reply":"2022-08-12T21:10:17.738360Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_race.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:17.740573Z","iopub.execute_input":"2022-08-12T21:10:17.741090Z","iopub.status.idle":"2022-08-12T21:10:17.754419Z","shell.execute_reply.started":"2022-08-12T21:10:17.741058Z","shell.execute_reply":"2022-08-12T21:10:17.753527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_race.track_condition.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:17.756183Z","iopub.execute_input":"2022-08-12T21:10:17.756591Z","iopub.status.idle":"2022-08-12T21:10:17.771443Z","shell.execute_reply.started":"2022-08-12T21:10:17.756559Z","shell.execute_reply":"2022-08-12T21:10:17.770241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_race, x = \"post_time\", y = \"run_up_distance\", hover_data = [\"race_number\", \"course_type\"],\n                 color = \"race_number\", color_discrete_sequence = colors, #range_color = (0, 9999),\n                 title = \"Post Time by Run Up Distance\")\n\nfig.update_traces(marker = dict(size = 4, symbol = \"circle\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-12T21:10:17.773344Z","iopub.execute_input":"2022-08-12T21:10:17.774141Z","iopub.status.idle":"2022-08-12T21:10:17.907064Z","shell.execute_reply.started":"2022-08-12T21:10:17.774098Z","shell.execute_reply":"2022-08-12T21:10:17.906046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Thank you for viewing this notebook. Please feel free to provide any feedback","metadata":{}}]}