{"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 pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:18.926039Z","iopub.execute_input":"2022-08-28T21:58:18.926440Z","iopub.status.idle":"2022-08-28T21:58:18.933098Z","shell.execute_reply.started":"2022-08-28T21:58:18.926407Z","shell.execute_reply":"2022-08-28T21:58:18.931661Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/big-data-derby-2022/nyra_2019_complete.csv', low_memory=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:18.939504Z","iopub.execute_input":"2022-08-28T21:58:18.941131Z","iopub.status.idle":"2022-08-28T21:58:35.855890Z","shell.execute_reply.started":"2022-08-28T21:58:18.941076Z","shell.execute_reply":"2022-08-28T21:58:35.854483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df.shape)\ndf.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:35.858550Z","iopub.execute_input":"2022-08-28T21:58:35.859438Z","iopub.status.idle":"2022-08-28T21:58:35.897039Z","shell.execute_reply.started":"2022-08-28T21:58:35.859388Z","shell.execute_reply":"2022-08-28T21:58:35.896072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:35.898173Z","iopub.execute_input":"2022-08-28T21:58:35.899084Z","iopub.status.idle":"2022-08-28T21:58:37.729553Z","shell.execute_reply.started":"2022-08-28T21:58:35.899047Z","shell.execute_reply":"2022-08-28T21:58:37.727811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:37.733403Z","iopub.execute_input":"2022-08-28T21:58:37.733979Z","iopub.status.idle":"2022-08-28T21:58:39.399944Z","shell.execute_reply.started":"2022-08-28T21:58:37.733923Z","shell.execute_reply":"2022-08-28T21:58:39.398437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:39.401650Z","iopub.execute_input":"2022-08-28T21:58:39.402121Z","iopub.status.idle":"2022-08-28T21:58:49.293913Z","shell.execute_reply.started":"2022-08-28T21:58:39.402076Z","shell.execute_reply":"2022-08-28T21:58:49.292666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:49.295284Z","iopub.execute_input":"2022-08-28T21:58:49.295838Z","iopub.status.idle":"2022-08-28T21:58:49.312770Z","shell.execute_reply.started":"2022-08-28T21:58:49.295805Z","shell.execute_reply":"2022-08-28T21:58:49.311426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.options.display.float_format = '{:.2f}'.format","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:49.314894Z","iopub.execute_input":"2022-08-28T21:58:49.315865Z","iopub.status.idle":"2022-08-28T21:58:49.326415Z","shell.execute_reply.started":"2022-08-28T21:58:49.315816Z","shell.execute_reply":"2022-08-28T21:58:49.325021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:49.329724Z","iopub.execute_input":"2022-08-28T21:58:49.330715Z","iopub.status.idle":"2022-08-28T21:58:49.356207Z","shell.execute_reply.started":"2022-08-28T21:58:49.330675Z","shell.execute_reply":"2022-08-28T21:58:49.354983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## Here I used a basic histogram function to plot all the numerical variables in the dataset.\n\ndf.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":"2022-08-28T21:58:49.357468Z","iopub.execute_input":"2022-08-28T21:58:49.357803Z","iopub.status.idle":"2022-08-28T21:58:52.817853Z","shell.execute_reply.started":"2022-08-28T21:58:49.357774Z","shell.execute_reply":"2022-08-28T21:58:52.816473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plotting histogram for average jockey weight\n\ndf.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":"2022-08-28T21:58:52.822242Z","iopub.execute_input":"2022-08-28T21:58:52.822890Z","iopub.status.idle":"2022-08-28T21:58:53.219738Z","shell.execute_reply.started":"2022-08-28T21:58:52.822852Z","shell.execute_reply":"2022-08-28T21:58:53.218497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Looks like there may be some outliers in this data.\n\n# Lets remove those so our result scan be stastically more significant.\n\n# Dropping outliers \n\ndf.drop(df[df.weight_carried >= 140].index, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:53.221624Z","iopub.execute_input":"2022-08-28T21:58:53.222047Z","iopub.status.idle":"2022-08-28T21:58:54.207341Z","shell.execute_reply.started":"2022-08-28T21:58:53.222012Z","shell.execute_reply":"2022-08-28T21:58:54.206072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plottin histogram after removing outliers\n\ndf.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":"2022-08-28T21:58:54.208820Z","iopub.execute_input":"2022-08-28T21:58:54.209621Z","iopub.status.idle":"2022-08-28T21:58:54.594885Z","shell.execute_reply.started":"2022-08-28T21:58:54.209553Z","shell.execute_reply":"2022-08-28T21:58:54.593968Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Deleting the features that won't affect injuries of horses","metadata":{}},{"cell_type":"code","source":"df.head(2)","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:54.596065Z","iopub.execute_input":"2022-08-28T21:58:54.596543Z","iopub.status.idle":"2022-08-28T21:58:54.616678Z","shell.execute_reply.started":"2022-08-28T21:58:54.596489Z","shell.execute_reply":"2022-08-28T21:58:54.615066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['distance_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:54.618122Z","iopub.execute_input":"2022-08-28T21:58:54.618945Z","iopub.status.idle":"2022-08-28T21:58:54.675612Z","shell.execute_reply.started":"2022-08-28T21:58:54.618908Z","shell.execute_reply":"2022-08-28T21:58:54.674109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['track_condition'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:54.677128Z","iopub.execute_input":"2022-08-28T21:58:54.677715Z","iopub.status.idle":"2022-08-28T21:58:54.905492Z","shell.execute_reply.started":"2022-08-28T21:58:54.677666Z","shell.execute_reply":"2022-08-28T21:58:54.904440Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20,20))\nsns.scatterplot(df['weight_carried'],df['trakus_index'],hue=df['track_condition'])","metadata":{"execution":{"iopub.status.busy":"2022-08-28T21:58:54.907254Z","iopub.execute_input":"2022-08-28T21:58:54.907670Z","iopub.status.idle":"2022-08-28T22:02:42.634688Z","shell.execute_reply.started":"2022-08-28T21:58:54.907632Z","shell.execute_reply":"2022-08-28T22:02:42.633348Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plotting bargraph comparing track_condition with the odds of winning races depicting which is most suitable track while racing\nsns.barplot(x=df['track_condition'],y=df['odds'])\nplt.xticks(rotation='vertical')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T22:02:42.636726Z","iopub.execute_input":"2022-08-28T22:02:42.637809Z","iopub.status.idle":"2022-08-28T22:05:33.888101Z","shell.execute_reply.started":"2022-08-28T22:02:42.637771Z","shell.execute_reply":"2022-08-28T22:05:33.886775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Depicts track_condition vs distance_id indicating the distance in various track_conditions\nsns.barplot(x=df['track_condition'],y=df['distance_id'])\nplt.xticks(rotation='vertical')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T22:05:33.889739Z","iopub.execute_input":"2022-08-28T22:05:33.890082Z","iopub.status.idle":"2022-08-28T22:08:27.441340Z","shell.execute_reply.started":"2022-08-28T22:05:33.890053Z","shell.execute_reply":"2022-08-28T22:08:27.440347Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['trakus_index'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T22:08:27.442906Z","iopub.execute_input":"2022-08-28T22:08:27.443298Z","iopub.status.idle":"2022-08-28T22:08:27.505719Z","shell.execute_reply.started":"2022-08-28T22:08:27.443263Z","shell.execute_reply":"2022-08-28T22:08:27.504526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['weight_carried'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-28T22:08:27.507151Z","iopub.execute_input":"2022-08-28T22:08:27.507892Z","iopub.status.idle":"2022-08-28T22:08:27.563747Z","shell.execute_reply.started":"2022-08-28T22:08:27.507840Z","shell.execute_reply":"2022-08-28T22:08:27.562128Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"_kg_hide-output":true},"execution_count":null,"outputs":[]}]}