{"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":"2023-05-20T17:51:10.707861Z","iopub.execute_input":"2023-05-20T17:51:10.708287Z","iopub.status.idle":"2023-05-20T17:51:10.718542Z","shell.execute_reply.started":"2023-05-20T17:51:10.708255Z","shell.execute_reply":"2023-05-20T17:51:10.717304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nimport statsmodels as sm\nimport time\n%matplotlib inline\nplt.rcParams['font.size'] = 12\nplt.rcParams['figure.figsize'] = (15, 10)","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:51:19.237661Z","iopub.execute_input":"2023-05-20T17:51:19.238103Z","iopub.status.idle":"2023-05-20T17:51:19.955044Z","shell.execute_reply.started":"2023-05-20T17:51:19.238068Z","shell.execute_reply":"2023-05-20T17:51:19.953875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install utm\nimport utm\n\nimport re\nimport warnings\n\nfrom shapely.geometry import Point\nfrom shapely.geometry.polygon import Polygon\nfrom tqdm.auto import tqdm\ntqdm.pandas()","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:51:21.390836Z","iopub.execute_input":"2023-05-20T17:51:21.391259Z","iopub.status.idle":"2023-05-20T17:51:38.458593Z","shell.execute_reply.started":"2023-05-20T17:51:21.391224Z","shell.execute_reply":"2023-05-20T17:51:38.457202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objects as go\n\nwarnings.simplefilter('ignore')\nsns.set_style(\"darkgrid\")","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:51:38.462035Z","iopub.execute_input":"2023-05-20T17:51:38.462526Z","iopub.status.idle":"2023-05-20T17:51:38.470272Z","shell.execute_reply.started":"2023-05-20T17:51:38.462460Z","shell.execute_reply":"2023-05-20T17:51:38.469099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"colnames=['track_id','race_date','race_number','program_number','trakus_index','latitude','longitude','distance_id','course_type','track_condition','run_up_distance','race_type','purse','post_time','weight_carried','jockey','odds','position_at_finish']\ndf = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_2019_complete.csv', names=colnames, header=None)","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:51:38.472183Z","iopub.execute_input":"2023-05-20T17:51:38.472654Z","iopub.status.idle":"2023-05-20T17:52:01.038744Z","shell.execute_reply.started":"2023-05-20T17:51:38.472615Z","shell.execute_reply":"2023-05-20T17:52:01.037282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:01.041533Z","iopub.execute_input":"2023-05-20T17:52:01.041994Z","iopub.status.idle":"2023-05-20T17:52:01.096448Z","shell.execute_reply.started":"2023-05-20T17:52:01.041951Z","shell.execute_reply":"2023-05-20T17:52:01.095235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:01.097926Z","iopub.execute_input":"2023-05-20T17:52:01.098617Z","iopub.status.idle":"2023-05-20T17:52:01.128665Z","shell.execute_reply.started":"2023-05-20T17:52:01.098573Z","shell.execute_reply":"2023-05-20T17:52:01.127236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:01.356121Z","iopub.execute_input":"2023-05-20T17:52:01.356630Z","iopub.status.idle":"2023-05-20T17:52:01.364033Z","shell.execute_reply.started":"2023-05-20T17:52:01.356582Z","shell.execute_reply":"2023-05-20T17:52:01.362784Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sum(df.duplicated())","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:17.805349Z","iopub.execute_input":"2023-05-20T17:52:17.805777Z","iopub.status.idle":"2023-05-20T17:52:30.073618Z","shell.execute_reply.started":"2023-05-20T17:52:17.805745Z","shell.execute_reply":"2023-05-20T17:52:30.072302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:30.075269Z","iopub.execute_input":"2023-05-20T17:52:30.075609Z","iopub.status.idle":"2023-05-20T17:52:41.249084Z","shell.execute_reply.started":"2023-05-20T17:52:30.075580Z","shell.execute_reply":"2023-05-20T17:52:41.247940Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.options.display.float_format = '{:.2f}'.format\n\ndf","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:41.251315Z","iopub.execute_input":"2023-05-20T17:52:41.251797Z","iopub.status.idle":"2023-05-20T17:52:41.281086Z","shell.execute_reply.started":"2023-05-20T17:52:41.251762Z","shell.execute_reply":"2023-05-20T17:52:41.279932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.hist(alpha=.5, rwidth=1, ec='black', figsize=(20,15));\nplt.suptitle('Big Data Derby 2022', x=0.5, y=1, fontsize='xx-large');\nplt.ticklabel_format(style='plain', useOffset=True)","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:45.413464Z","iopub.execute_input":"2023-05-20T17:52:45.413951Z","iopub.status.idle":"2023-05-20T17:52:50.676381Z","shell.execute_reply.started":"2023-05-20T17:52:45.413918Z","shell.execute_reply":"2023-05-20T17:52:50.675027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.hist(column='weight_carried', alpha=.5, rwidth=1, ec='black', figsize=(10,8));\nplt.suptitle('Average Jockey Weight', x=0.5, y=1, fontsize='xx-large');\nplt.ticklabel_format(style='plain')\nplt.xlabel('Weight');\nplt.ylabel('Count');\nplt.title(\"\");","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:52:55.395351Z","iopub.execute_input":"2023-05-20T17:52:55.396606Z","iopub.status.idle":"2023-05-20T17:52:55.948764Z","shell.execute_reply.started":"2023-05-20T17:52:55.396550Z","shell.execute_reply":"2023-05-20T17:52:55.947609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop(df[df.weight_carried >= 140].index, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:53:30.184804Z","iopub.execute_input":"2023-05-20T17:53:30.185228Z","iopub.status.idle":"2023-05-20T17:53:31.165266Z","shell.execute_reply.started":"2023-05-20T17:53:30.185198Z","shell.execute_reply":"2023-05-20T17:53:31.163428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.hist(column='weight_carried', alpha=.5, rwidth=1, ec='black', figsize=(10,8));\nplt.suptitle('Average Jockey Weight', x=0.5, y=1, fontsize='xx-large');\nplt.ticklabel_format(style='plain')\nplt.xlabel('Weight');\nplt.ylabel('Count');\nplt.title(\"\");","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:53:37.778607Z","iopub.execute_input":"2023-05-20T17:53:37.779029Z","iopub.status.idle":"2023-05-20T17:53:38.334631Z","shell.execute_reply.started":"2023-05-20T17:53:37.778997Z","shell.execute_reply":"2023-05-20T17:53:38.333559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.scatterplot(data=df, x='race_number', y='odds', hue='odds')\nplt.xlabel('Race Number')\nplt.ylabel('Odds')\nplt.title('Winning Odds and Race Number')\n\n# Remove plot and paper background color\nsns.set(style='white')\nsns.despine()\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:53:49.213818Z","iopub.execute_input":"2023-05-20T17:53:49.214226Z","iopub.status.idle":"2023-05-20T17:58:52.058901Z","shell.execute_reply.started":"2023-05-20T17:53:49.214189Z","shell.execute_reply":"2023-05-20T17:58:52.057563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings(\"ignore\", category=DeprecationWarning)\nwarnings.filterwarnings(\"ignore\", category=UserWarning)\nwarnings.filterwarnings(\"ignore\", category=FutureWarning)\n\nimport numpy as np\nimport pandas as pd \nimport plotly.express as px\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n%matplotlib inline\nplt.rcParams['font.size'] = 12\nplt.rcParams['figure.figsize'] = (15, 10)\n","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:58:52.061646Z","iopub.execute_input":"2023-05-20T17:58:52.062305Z","iopub.status.idle":"2023-05-20T17:58:52.074216Z","shell.execute_reply.started":"2023-05-20T17:58:52.062261Z","shell.execute_reply":"2023-05-20T17:58:52.073203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots()\n\nsns.histplot(data=df, x=\"track_condition\", hue=\"track_condition\", y=\"weight_carried\", log_scale=(False, True), ax=ax)\n\n# Set labels and title\nax.set_xlabel(\"Track Condition\")\nax.set_ylabel(\"Weight Carried\")\nax.set_title(\"Weight Carried and Track Condition\")\n\n# Reorder x-axis categories in descending order\nax.set_xticklabels(ax.get_xticks(), rotation=45, ha=\"right\")  # Rotate x-axis labels if needed\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:58:52.075561Z","iopub.execute_input":"2023-05-20T17:58:52.075868Z","iopub.status.idle":"2023-05-20T17:59:28.133790Z","shell.execute_reply.started":"2023-05-20T17:58:52.075841Z","shell.execute_reply":"2023-05-20T17:59:28.132436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Anshu Patel","metadata":{"execution":{"iopub.status.busy":"2023-05-20T17:59:28.142793Z","iopub.execute_input":"2023-05-20T17:59:28.143612Z","iopub.status.idle":"2023-05-20T17:59:28.156761Z","shell.execute_reply.started":"2023-05-20T17:59:28.143581Z","shell.execute_reply":"2023-05-20T17:59:28.155411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}