{"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)\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport plotly.express as px\nimport plotly.graph_objs as go\n\nimport plotly\nplotly.offline.init_notebook_mode(connected=True)\n\nimport time\n\nnotebookstart = time.time()\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\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","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-08-26T00:49:09.898702Z","iopub.execute_input":"2022-08-26T00:49:09.899078Z","iopub.status.idle":"2022-08-26T00:49:09.937382Z","shell.execute_reply.started":"2022-08-26T00:49:09.899048Z","shell.execute_reply":"2022-08-26T00:49:09.936636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Big Data Derby 2022 Analystics Competition - Context\n\n\"Injury prevention is a critical component in modern athletics. Sports that involve animals, such as horse racing, are no different than human sport. Typically, efficiency in movement correlates to both improvements in performance and injury prevention.\"\n\n\"A wealth of data is now collected, including measures for heart rate, EKG, longitudinal movement, dorsal/ventral movement, medial/lateral deviation, total power and total landing vibration. Your data science skills and analysis are needed to decipher what makes the most positive impact.\"\n\nhttps://www.kaggle.com/competitions/big-data-derby-2022/overview/description","metadata":{}},{"cell_type":"markdown","source":"\"The report shows that, most commonly, horses die from catastrophic limb injuries, or breaks and fractures of their forelegs. Others die of cardiac issues, internal bleeding, or hind leg injuries, or they simply collapse after being pushed past their limits.\"\n\n![](https://www.peta.org.au/wp-content/uploads/Screen-Shot-2018-09-04-at-9.00.21-pm.png)https://www.peta.org.au/news/racing-to-an-early-grave/","metadata":{}},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/cusersmarildownloadsequinecsv/equine.csv\", delimiter=';', encoding='utf8')\npd.set_option('display.max_columns', None)\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:10:23.900597Z","iopub.execute_input":"2022-08-25T23:10:23.900937Z","iopub.status.idle":"2022-08-25T23:10:23.933741Z","shell.execute_reply.started":"2022-08-25T23:10:23.900910Z","shell.execute_reply":"2022-08-25T23:10:23.932823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\"Over recent years racing has taken some commendable actions to improve safety for horses. These efforts have borne some success, though to what degree is difficult to scale because the sport has been contracting for a long time and fewer horses are setting foot on tracks than 20 or 30 years ago.\"\n\n\"The best that can be said is that racing may be able to make itself safer for horses, but never safe. Having endured countless existential crises, perhaps now is the true do or die moment.\"\n\n\"If horse racing as an industry chooses to acknowledge reality, the most honorable next step is to be publicly honest: horse racing kills horses. The sport you love and live by kills horses.\"\n\nhttps://www.theguardian.com/sport/2022/may/05/horse-racing-deaths-equine-welfare-kentucky-derby","metadata":{}},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-25T22:29:43.242701Z","iopub.execute_input":"2022-08-25T22:29:43.243098Z","iopub.status.idle":"2022-08-25T22:29:43.253174Z","shell.execute_reply.started":"2022-08-25T22:29:43.243067Z","shell.execute_reply":"2022-08-25T22:29:43.252146Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install watermark\n!pip install nicaviz","metadata":{"_kg_hide-output":true,"execution":{"iopub.status.busy":"2022-08-25T23:14:41.480205Z","iopub.execute_input":"2022-08-25T23:14:41.480526Z","iopub.status.idle":"2022-08-25T23:14:57.839749Z","shell.execute_reply.started":"2022-08-25T23:14:41.480499Z","shell.execute_reply":"2022-08-25T23:14:57.838516Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%reload_ext autoreload\n%autoreload 2","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:11:57.149752Z","iopub.execute_input":"2022-08-25T23:11:57.150177Z","iopub.status.idle":"2022-08-25T23:11:57.196756Z","shell.execute_reply.started":"2022-08-25T23:11:57.150146Z","shell.execute_reply":"2022-08-25T23:11:57.195906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Why Are So Many Racehorses Dying? - By Emily Barone. May 13, 2019\n\nTrack conditions: surface inconsistancies. Tracks with uniform cushioning and moisture levels are safer.\n\nPainkillers: pain-suppressing drugs. A horse that can't fully feel an injury may exarcebate it.\n\nOther drugs: The industry tolerate Lasix for a lung condition. It's widely used because induces urination. Tha makes the horse lighter and faster, but dehydrated for days. \n\nhttps://pt.scribd.com/article/408514386/Why-Are-So-Many-Racehorses-Dying","metadata":{}},{"cell_type":"code","source":"df['incident_date'] = pd.to_datetime(df['incident_date'])","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:13:30.776415Z","iopub.execute_input":"2022-08-25T23:13:30.776753Z","iopub.status.idle":"2022-08-25T23:13:30.821811Z","shell.execute_reply.started":"2022-08-25T23:13:30.776726Z","shell.execute_reply":"2022-08-25T23:13:30.821087Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import nicaviz","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:17:45.014846Z","iopub.execute_input":"2022-08-25T23:17:45.015150Z","iopub.status.idle":"2022-08-25T23:17:45.080439Z","shell.execute_reply.started":"2022-08-25T23:17:45.015125Z","shell.execute_reply":"2022-08-25T23:17:45.079742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Interval One day","metadata":{}},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/covid-digital-learning-data-exploration\n\nwith nicaviz.timer(\"Timeserie Resample Plot\"):\n    df.nica.mass_plot(\n        plt_set= [\"incident_date\"],\n        plottype = \"ts_resample\",\n        resample=True,\n        resample_interval=\"1D\"\n    );","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:18:15.381644Z","iopub.execute_input":"2022-08-25T23:18:15.381994Z","iopub.status.idle":"2022-08-25T23:18:15.821166Z","shell.execute_reply.started":"2022-08-25T23:18:15.381967Z","shell.execute_reply":"2022-08-25T23:18:15.820075Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Interval One week","metadata":{}},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/covid-digital-learning-data-exploration\n\nwith nicaviz.timer(\"Timeserie Resample Plot\"):\n    df.nica.mass_plot(\n        plt_set= [\"incident_date\"],\n        plottype = \"ts_resample\",\n        resample=True,\n        resample_interval=\"1W\"\n    );","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:20:03.170301Z","iopub.execute_input":"2022-08-25T23:20:03.170963Z","iopub.status.idle":"2022-08-25T23:20:03.437584Z","shell.execute_reply.started":"2022-08-25T23:20:03.170932Z","shell.execute_reply":"2022-08-25T23:20:03.436736Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Interval 1 year ","metadata":{}},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/covid-digital-learning-data-exploration\n\nwith nicaviz.timer(\"Timeserie Resample Plot\"):\n    df.nica.mass_plot(\n        plt_set= [\"incident_date\"],\n        plottype = \"ts_resample\",\n        resample=True,\n        resample_interval=\"1Y\"\n    )","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:21:26.969734Z","iopub.execute_input":"2022-08-25T23:21:26.970130Z","iopub.status.idle":"2022-08-25T23:21:27.244627Z","shell.execute_reply.started":"2022-08-25T23:21:26.970101Z","shell.execute_reply":"2022-08-25T23:21:27.243697Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Above, it seems that incidents are decreasing.","metadata":{}},{"cell_type":"code","source":"dfInt = ['year']#We have only one integer (year)","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:28:19.773349Z","iopub.execute_input":"2022-08-25T23:28:19.773690Z","iopub.status.idle":"2022-08-25T23:28:19.804824Z","shell.execute_reply.started":"2022-08-25T23:28:19.773662Z","shell.execute_reply":"2022-08-25T23:28:19.803966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\"The fatality rate among Thoroughbred racehorses in the United States continues to edge down, latest statistics show.\"\n\n\"The US Jockey Club has released data from the Equine Injury Database for 2021 – the 13th year of reporting fatalities under the database system.\"\n\n\"It shows a rate of fatal injury in 2021 of 1.39 per 1000 starts, down slightly from the 2020 result of 1.41 deaths per 1000 starts.\"\n\n\"It is the third year in a row that the number has decreased. The 2021 rate is the lowest since the database started collecting information in 2009. The figure represents a decline of 1.4% from 2020 and 30.5% overall since 2009.\"\n\n\"Based on the 2021 data, 99.86% of flat racing starts at racetracks participating in the database were completed without a fatality.\"\n\nhttps://www.horsetalk.co.nz/2022/04/01/us-thoroughbred-fatality-rate-lower-in-2021/","metadata":{}},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/covid-digital-learning-data-exploration\n\n#Sample was reduced to 500. In the Original code was 500000\n\nwith nicaviz.timer(\"Timeserie Rolling Plot\"):\n    df.sample(500).nica.mass_plot(\n        plt_set= dfInt,\n        plottype = \"ts_rolling\",\n        x_var=\"incident_date\",\n        rolling=True,\n        r=30\n    )","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:28:24.884301Z","iopub.execute_input":"2022-08-25T23:28:24.884629Z","iopub.status.idle":"2022-08-25T23:28:25.202626Z","shell.execute_reply.started":"2022-08-25T23:28:24.884603Z","shell.execute_reply":"2022-08-25T23:28:25.201743Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Track Surfaces\n\n\"Synthetic track surfaces carried the lowest overall fatality rate at 0.73, followed by turf at 1.25 and dirt at 1.51 per 1000 starts. The rate on synthetic dropped below 1 for only the second time since the database was established, and is the lowest since 2009.\"\n\n\"There has been a statistically significant drop overall since 2009 in the risk of fatal injury across all surfaces: The risk on dirt has fallen 28.1%, while on turf it has fallen by 35.6%. The fatality risk on synthetic surfaces since 2009 has fallen 51%.\"\n\n\"The database statistics are based on injuries that resulted in fatalities within 72 hours from the date of the race. The statistics are for official Thoroughbred races only and exclude steeplechase races.\"\n\n\"The database was launched by the Jockey Club in July 2008 in a bid to identify the frequencies, types, and outcomes of racing injuries using a standardized format that generates valid statistics. It also identifies factors for horses at increased risk of injury, and serves as a source for research directed at improving safety and preventing injuries.\"\n\nhttps://www.horsetalk.co.nz/2022/04/01/us-thoroughbred-fatality-rate-lower-in-2021/","metadata":{}},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/covid-digital-learning-data-exploration\n\nwith nicaviz.timer(\"Boxplots\"):\n    df.nica.mass_plot(\n        plt_set= dfInt,\n        plottype = \"boxplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:29:37.440453Z","iopub.execute_input":"2022-08-25T23:29:37.440794Z","iopub.status.idle":"2022-08-25T23:29:37.639806Z","shell.execute_reply.started":"2022-08-25T23:29:37.440752Z","shell.execute_reply":"2022-08-25T23:29:37.638899Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"death_or_injury\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:53:30.956968Z","iopub.execute_input":"2022-08-25T23:53:30.957766Z","iopub.status.idle":"2022-08-25T23:53:30.996579Z","shell.execute_reply.started":"2022-08-25T23:53:30.957731Z","shell.execute_reply":"2022-08-25T23:53:30.995503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"incident_type\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:37:18.296600Z","iopub.execute_input":"2022-08-25T23:37:18.296948Z","iopub.status.idle":"2022-08-25T23:37:18.333966Z","shell.execute_reply.started":"2022-08-25T23:37:18.296920Z","shell.execute_reply":"2022-08-25T23:37:18.332967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"weather_conditions\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-26T01:46:27.638702Z","iopub.execute_input":"2022-08-26T01:46:27.639150Z","iopub.status.idle":"2022-08-26T01:46:27.679135Z","shell.execute_reply.started":"2022-08-26T01:46:27.639117Z","shell.execute_reply":"2022-08-26T01:46:27.678256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#There are many (1331) weather conditions listed.","metadata":{}},{"cell_type":"code","source":"#Code by Nicapotato https://www.kaggle.com/nicapotato/covid-digital-learning-data-exploration\n\ncategoricals = [\n    \"incident_type\",\n    \"track\",\n    \"racing_type_description\",\n    \"death_or_injury\",\n    \n]\n\nwith nicaviz.timer(\"Small Hue Boxplots\"):\n    for hue_col in categoricals:\n        df.nica.mass_plot(\n            plt_set= dfInt,\n            hue = hue_col,\n            columns = 2,\n            plottype = \"boxplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:38:01.556132Z","iopub.execute_input":"2022-08-25T23:38:01.556481Z","iopub.status.idle":"2022-08-25T23:38:02.828661Z","shell.execute_reply.started":"2022-08-25T23:38:01.556453Z","shell.execute_reply":"2022-08-25T23:38:02.827654Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb\n\nwith nicaviz.timer(\"Wordcloud Plot\"):\n    df.nica.mass_plot(\n        plt_set= [\"death_or_injury\", \"track\"],\n        plottype = \"wordcloud\")","metadata":{"execution":{"iopub.status.busy":"2022-08-25T23:59:42.185958Z","iopub.execute_input":"2022-08-25T23:59:42.186299Z","iopub.status.idle":"2022-08-25T23:59:42.985512Z","shell.execute_reply.started":"2022-08-25T23:59:42.186271Z","shell.execute_reply":"2022-08-25T23:59:42.984490Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb\n\nwith nicaviz.timer(\"Count Plot\"):\n    df.nica.mass_plot(\n        plt_set= [\"year\", \"death_or_injury\"],\n        plottype = \"countplot\");","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:01:31.266951Z","iopub.execute_input":"2022-08-26T00:01:31.267311Z","iopub.status.idle":"2022-08-26T00:01:31.611351Z","shell.execute_reply.started":"2022-08-26T00:01:31.267281Z","shell.execute_reply":"2022-08-26T00:01:31.610369Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#I hope those racehorses deaths are decreasing, as it's shown on the charts above.","metadata":{}},{"cell_type":"code","source":"#Code by Nick Brooks https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb\n\nwith nicaviz.timer(\"Bar Plot\"):\n    df.nica.mass_plot(\n        plt_set= [\"death_or_injury\", \"track\"],\n        x_var = \"year\",\n        plottype = \"bar\")","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:06:04.842430Z","iopub.execute_input":"2022-08-26T00:06:04.842805Z","iopub.status.idle":"2022-08-26T00:06:05.681672Z","shell.execute_reply.started":"2022-08-26T00:06:04.842759Z","shell.execute_reply":"2022-08-26T00:06:05.680812Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb\n\nwith nicaviz.timer(\"Boxplots\"):\n    df.nica.mass_plot(\n        plt_set= [\"year\"],#We have only one integer\n        plottype = \"boxplot\")\n\n    df.nica.mass_plot(\n        plt_set= [\"year\"],\n        hue = \"death_or_injury\",\n        plottype = \"boxplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:09:45.830157Z","iopub.execute_input":"2022-08-26T00:09:45.831123Z","iopub.status.idle":"2022-08-26T00:09:46.296135Z","shell.execute_reply.started":"2022-08-26T00:09:45.831074Z","shell.execute_reply":"2022-08-26T00:09:46.295165Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb\n\nwith nicaviz.timer(\"Distplots\"):\n    df.nica.mass_plot(\n        plt_set= [\"year\"],#We have only one integer\n        plottype = \"distplot\")\n\n    df.nica.mass_plot(\n        plt_set= [\"year\"],\n        hue = \"track\",\n        plottype = \"distplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:13:27.679564Z","iopub.execute_input":"2022-08-26T00:13:27.679914Z","iopub.status.idle":"2022-08-26T00:13:28.552007Z","shell.execute_reply.started":"2022-08-26T00:13:27.679887Z","shell.execute_reply":"2022-08-26T00:13:28.551070Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb\n\nwith nicaviz.timer(\"Distplots\"):\n    df.nica.mass_plot(\n        plt_set= [\"year\"],#we have only one integer\n        hue = \"death_or_injury\",\n        plottype = \"distplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:15:45.004963Z","iopub.execute_input":"2022-08-26T00:15:45.005851Z","iopub.status.idle":"2022-08-26T00:15:45.593233Z","shell.execute_reply.started":"2022-08-26T00:15:45.005813Z","shell.execute_reply":"2022-08-26T00:15:45.592070Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb\n\nwith nicaviz.timer(\"Countplot\"):\n    df.nica.mass_plot(\n        plt_set= [\"year\", \"track\"],\n        hue = \"death_or_injury\",\n        plottype = \"countplot\")\n\n    df.nica.mass_plot(\n        plt_set= [\"year\", \"track\"],\n        plottype = \"countplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:21:48.475880Z","iopub.execute_input":"2022-08-26T00:21:48.476250Z","iopub.status.idle":"2022-08-26T00:21:51.028837Z","shell.execute_reply.started":"2022-08-26T00:21:48.476218Z","shell.execute_reply":"2022-08-26T00:21:51.027971Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/ventilator-pressure-prediction-nicaviz-eda/notebook\n\ncategoricals = [\"track\", \"death_or_injury\", \"incident_type\", \"weather_conditions\", \"inv_location\"]\n#continuous = ['x', 'y', \"s\", \"a\", \"dis\", \"o\", \"dir\", \"nflId\", \"jerseyNumber\"] #I reduced since it took many time\n#continuous = [\"dir\", \"nflId\", \"jerseyNumber\"]#Test below with only 3 continuous\ninteger = ['year']\ntimevar = 'incident_date '","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:29:38.177821Z","iopub.execute_input":"2022-08-26T00:29:38.178424Z","iopub.status.idle":"2022-08-26T00:29:38.213105Z","shell.execute_reply.started":"2022-08-26T00:29:38.178376Z","shell.execute_reply":"2022-08-26T00:29:38.211741Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with nicaviz.timer(\"Distplots\"):\n    df.nica.mass_plot(\n        plt_set= [\"year\"], #we have only one integer\n        plottype = \"distplot\")\n\n    df.nica.mass_plot(\n        plt_set= [\"year\"],\n        hue = \"death_or_injury\",\n        plottype = \"distplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:27:19.419405Z","iopub.execute_input":"2022-08-26T00:27:19.419845Z","iopub.status.idle":"2022-08-26T00:27:20.324016Z","shell.execute_reply.started":"2022-08-26T00:27:19.419800Z","shell.execute_reply":"2022-08-26T00:27:20.322956Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/ventilator-pressure-prediction-nicaviz-eda/notebook\n\ndf.nica.mass_plot(\n    plt_set = categoricals,\n    columns = 3,\n    plottype = \"countplot\")","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:29:44.955884Z","iopub.execute_input":"2022-08-26T00:29:44.956669Z","iopub.status.idle":"2022-08-26T00:29:45.952938Z","shell.execute_reply.started":"2022-08-26T00:29:44.956630Z","shell.execute_reply":"2022-08-26T00:29:45.951814Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Nick Brooks https://www.kaggle.com/nicapotato/ventilator-pressure-prediction-nicaviz-eda/notebook\n\n#It took 3 minutes to plot the reduced continuous features\n\n#df.nica.mass_plot(\n    #plt_set = continuous,#We don't have continuous\n    #columns = 3,\n   # plottype = \"distplot\")\n\n#print(\"['year', 'track'] Correlation: {}\".format(df[['year', 'track']].corr().iloc[0,1]))","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:32:37.614122Z","iopub.execute_input":"2022-08-26T00:32:37.615177Z","iopub.status.idle":"2022-08-26T00:32:37.651268Z","shell.execute_reply.started":"2022-08-26T00:32:37.615101Z","shell.execute_reply":"2022-08-26T00:32:37.650191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#save for next time. We have No continuous\n\n#Code by Nick Brooks https://www.kaggle.com/nicapotato/ventilator-pressure-prediction-nicaviz-eda/notebook\n\nfor cont in continuous:\n    track20.nica.pivot_plots(\n        categoricalcols = categoricals,\n        valuecol = cont,\n        aggfunc = np.mean,\n        columns = 1)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#with nicaviz.timer(\"Correlation Plot\"):\n #   df.nica.rank_correlations_plots([\"year\", \"track\", \"weather_conditions\"], 9)","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:35:45.525953Z","iopub.execute_input":"2022-08-26T00:35:45.526304Z","iopub.status.idle":"2022-08-26T00:35:45.559084Z","shell.execute_reply.started":"2022-08-26T00:35:45.526276Z","shell.execute_reply":"2022-08-26T00:35:45.558296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with nicaviz.timer(\"Pivot Heatmap Plot\"):\n    categorical = ['racing_type_description', 'inv_location', 'division']\n    df.nica.pivot_plots(categorical, \"year\", np.sum)","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:40:30.430984Z","iopub.execute_input":"2022-08-26T00:40:30.431323Z","iopub.status.idle":"2022-08-26T00:40:31.718756Z","shell.execute_reply.started":"2022-08-26T00:40:30.431297Z","shell.execute_reply":"2022-08-26T00:40:31.717472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#We don't have continuous. Save for next time.\n\n#Code by Nick Brooks https://www.kaggle.com/nicapotato/ventilator-pressure-prediction-nicaviz-eda/notebook\n\nfor cont in continuous:\n    df.nica.pivot_plots(categoricals, cont, np.mean)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Notebook Runtime: %0.2f Minutes\"%((time.time() - notebookstart)/60))","metadata":{"execution":{"iopub.status.busy":"2022-08-26T00:49:29.884594Z","iopub.execute_input":"2022-08-26T00:49:29.885509Z","iopub.status.idle":"2022-08-26T00:49:29.919842Z","shell.execute_reply.started":"2022-08-26T00:49:29.885467Z","shell.execute_reply":"2022-08-26T00:49:29.918814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Acknowledgements:\n\n1Horse racing is too far gone to be saved. The next best thing is to be honest about it\nBy Elizabeth Banicki\nhttps://www.theguardian.com/sport/2022/may/05/horse-racing-deaths-equine-welfare-kentucky-derby\n\n2Nick Brooks (a.k.a Nicapotato)\n\nCode by Nicapotato https://www.kaggle.com/nicapotato/ventilator-pressure-prediction-nicaviz-eda/notebook\n\nVentilator Pressure Prediction Nicaviz EDA By Nick Brooks, September 2021\n\nResources\n\nhttps://github.com/nicapotato/nicaviz https://github.com/nicapotato/nicaviz/blob/master/notebooks/Plot_Examples.ipynb","metadata":{}},{"cell_type":"markdown","source":"#Coalition for the Protection of Racehorses\n\n31 de outubro de 2016 \n· \n\"On top of the 4 horses that have died in the Melbourne Cup from 2013-2015, there's much more about horse racing that many do not know about.\"\n\n\"Last year’s winner Prince of Penzance’s life hangs in the balance as he recovers from a fractured fetlock sustained at Caulfield Racecourse on 8 October 2016.\"\n\n\"On average, one racehorse is killed on our racetracks less than every 3 days.\"\n\n\"In the last racing calendar year, 132 racehorses have been killed on our racetracks due to catastrophic injury, cardiac failure & massive bleeds.\"\n\n\"Every year, approximately one third of competing racehorses are prematurely retired as a result of injuries sustained in horse racing and training.\"\n\n\"There is no retirement plan for racehorses, and as a result, many thousands will be sent to slaughter killed for pet food or human consumption.\"\n\nMore info: horseracingkills.com\n\n![](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSZXwy3_KQo4kRF1VDoC6-aI9z6zTdWXr1fYA&usqp=CAU)https://m.facebook.com/coalitionfortheprotectionofracehorses/posts/1255339704507950:0","metadata":{}},{"cell_type":"markdown","source":"#The Future of Racing in a Modern Ethical Society\n\n\"If racing hopes to help itself in the greater picture of its future, now is the time it might tackle the question of how it will fare in a modern society, culture, and potentially a justice system that increasingly recognizes animals as entitled to certain fundamental rights.\"\n\n\"The least of those being survival of the for-profit business which created them. After that, all racehorses are entitled to a safe and financially secure future. These things were stolen from Eight Belles, Medina Spirit, Keepthename, Creative Plan, Laoban and thousands of unknown others. Let them not be also taken from the young horses to come.\"\n\nhttps://www.theguardian.com/sport/2022/may/05/horse-racing-deaths-equine-welfare-kentucky-derby","metadata":{}}]}