{"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":"markdown","source":"## Big Data Derby 2022 - EDA & Clustering\n#### By Nuriel Reuven\n\n-----------------------------","metadata":{}},{"cell_type":"markdown","source":"# Importing","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd \n\n\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.preprocessing import MinMaxScaler\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.cluster import KMeans\nfrom sklearn.cluster import AgglomerativeClustering\nfrom sklearn.metrics import silhouette_score\n\nfrom random import sample\nimport math\n\nfrom plotly.offline import plot, iplot, init_notebook_mode\nimport plotly_express as px\ninit_notebook_mode(connected=True)\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objects as go\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n\nimport os\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-21T20:16:51.482305Z","iopub.execute_input":"2022-08-21T20:16:51.482703Z","iopub.status.idle":"2022-08-21T20:16:51.496181Z","shell.execute_reply.started":"2022-08-21T20:16:51.482671Z","shell.execute_reply":"2022-08-21T20:16:51.495054Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"complete = pd.read_csv(\"../input/big-data-derby-2022/nyra_2019_complete.csv\")\nrace = pd.read_csv(\"../input/big-data-derby-2022/nyra_race_table.csv\")\nstart = pd.read_csv(\"../input/big-data-derby-2022/nyra_start_table.csv\")\ntracking = pd.read_csv(\"../input/big-data-derby-2022/nyra_tracking_table.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:16:51.498242Z","iopub.execute_input":"2022-08-21T20:16:51.498670Z","iopub.status.idle":"2022-08-21T20:17:05.332613Z","shell.execute_reply.started":"2022-08-21T20:16:51.498637Z","shell.execute_reply":"2022-08-21T20:17:05.331266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"I always like to make a copy of my datasets because during preprocessing you might encounter some issues that you'll need to look back. Also in general its a good practice:","metadata":{}},{"cell_type":"code","source":"#complete_copy = complete.copy()\n#race_copy = race.copy()\n#start_copy = start.copy()\n#tracking_copy = tracking.copy()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:05.333863Z","iopub.execute_input":"2022-08-21T20:17:05.334167Z","iopub.status.idle":"2022-08-21T20:17:05.339368Z","shell.execute_reply.started":"2022-08-21T20:17:05.334138Z","shell.execute_reply":"2022-08-21T20:17:05.338008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"-----------------------------------------\n# Data Exploration ","metadata":{}},{"cell_type":"markdown","source":"Some information about our datasets first:","metadata":{}},{"cell_type":"code","source":"complete.sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:05.342628Z","iopub.execute_input":"2022-08-21T20:17:05.343920Z","iopub.status.idle":"2022-08-21T20:17:05.616479Z","shell.execute_reply.started":"2022-08-21T20:17:05.343869Z","shell.execute_reply":"2022-08-21T20:17:05.614845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"complete.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:05.617924Z","iopub.execute_input":"2022-08-21T20:17:05.618513Z","iopub.status.idle":"2022-08-21T20:17:05.632548Z","shell.execute_reply.started":"2022-08-21T20:17:05.618477Z","shell.execute_reply":"2022-08-21T20:17:05.631256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"complete.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:05.635203Z","iopub.execute_input":"2022-08-21T20:17:05.635674Z","iopub.status.idle":"2022-08-21T20:17:07.266021Z","shell.execute_reply.started":"2022-08-21T20:17:05.635625Z","shell.execute_reply":"2022-08-21T20:17:07.264644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"complete.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:07.268904Z","iopub.execute_input":"2022-08-21T20:17:07.269291Z","iopub.status.idle":"2022-08-21T20:17:12.162765Z","shell.execute_reply.started":"2022-08-21T20:17:07.269257Z","shell.execute_reply":"2022-08-21T20:17:12.161593Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"race.sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.164397Z","iopub.execute_input":"2022-08-21T20:17:12.164711Z","iopub.status.idle":"2022-08-21T20:17:12.180038Z","shell.execute_reply.started":"2022-08-21T20:17:12.164683Z","shell.execute_reply":"2022-08-21T20:17:12.178825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"race.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.184934Z","iopub.execute_input":"2022-08-21T20:17:12.185307Z","iopub.status.idle":"2022-08-21T20:17:12.200138Z","shell.execute_reply.started":"2022-08-21T20:17:12.185265Z","shell.execute_reply":"2022-08-21T20:17:12.198987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"race.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.201732Z","iopub.execute_input":"2022-08-21T20:17:12.202221Z","iopub.status.idle":"2022-08-21T20:17:12.219929Z","shell.execute_reply.started":"2022-08-21T20:17:12.202184Z","shell.execute_reply":"2022-08-21T20:17:12.218809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"race.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.221534Z","iopub.execute_input":"2022-08-21T20:17:12.222606Z","iopub.status.idle":"2022-08-21T20:17:12.265259Z","shell.execute_reply.started":"2022-08-21T20:17:12.222556Z","shell.execute_reply":"2022-08-21T20:17:12.264016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start.sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.266695Z","iopub.execute_input":"2022-08-21T20:17:12.267879Z","iopub.status.idle":"2022-08-21T20:17:12.285496Z","shell.execute_reply.started":"2022-08-21T20:17:12.267827Z","shell.execute_reply":"2022-08-21T20:17:12.282909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.288991Z","iopub.execute_input":"2022-08-21T20:17:12.289785Z","iopub.status.idle":"2022-08-21T20:17:12.315987Z","shell.execute_reply.started":"2022-08-21T20:17:12.289721Z","shell.execute_reply":"2022-08-21T20:17:12.314550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.317971Z","iopub.execute_input":"2022-08-21T20:17:12.318857Z","iopub.status.idle":"2022-08-21T20:17:12.333495Z","shell.execute_reply.started":"2022-08-21T20:17:12.318806Z","shell.execute_reply":"2022-08-21T20:17:12.331864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.336573Z","iopub.execute_input":"2022-08-21T20:17:12.337024Z","iopub.status.idle":"2022-08-21T20:17:12.386386Z","shell.execute_reply.started":"2022-08-21T20:17:12.336989Z","shell.execute_reply":"2022-08-21T20:17:12.384920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.388157Z","iopub.execute_input":"2022-08-21T20:17:12.388679Z","iopub.status.idle":"2022-08-21T20:17:12.657035Z","shell.execute_reply.started":"2022-08-21T20:17:12.388647Z","shell.execute_reply":"2022-08-21T20:17:12.655847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.658564Z","iopub.execute_input":"2022-08-21T20:17:12.659057Z","iopub.status.idle":"2022-08-21T20:17:12.671968Z","shell.execute_reply.started":"2022-08-21T20:17:12.659005Z","shell.execute_reply":"2022-08-21T20:17:12.670636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:12.673367Z","iopub.execute_input":"2022-08-21T20:17:12.673731Z","iopub.status.idle":"2022-08-21T20:17:13.373098Z","shell.execute_reply.started":"2022-08-21T20:17:12.673698Z","shell.execute_reply":"2022-08-21T20:17:13.371640Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:13.375376Z","iopub.execute_input":"2022-08-21T20:17:13.375907Z","iopub.status.idle":"2022-08-21T20:17:15.589450Z","shell.execute_reply.started":"2022-08-21T20:17:13.375743Z","shell.execute_reply":"2022-08-21T20:17:15.588276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We do not have missing values anywhere. That is fantastic! I wish it was always like that in real life..\n\n**We will work mostly with the complete table since its combining all 3 other tables. For certain graphs we will return to original data as it might be faster to draw**","metadata":{}},{"cell_type":"code","source":"complete.sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:15.591022Z","iopub.execute_input":"2022-08-21T20:17:15.591349Z","iopub.status.idle":"2022-08-21T20:17:15.837094Z","shell.execute_reply.started":"2022-08-21T20:17:15.591319Z","shell.execute_reply":"2022-08-21T20:17:15.835861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We will do most of the preprocessing later, but for now we need to correct a few things before continuing. We need to correct the odds. I will write them in decimal format (i.e - From the documentation odds of 1280 are 12.8:1 or in decimal format 1/12.8=0.078125):","metadata":{}},{"cell_type":"code","source":"start['odds'] = start['odds'] / 100\ncomplete['odds'] = complete['odds'] / 100","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:15.838838Z","iopub.execute_input":"2022-08-21T20:17:15.839198Z","iopub.status.idle":"2022-08-21T20:17:15.984703Z","shell.execute_reply.started":"2022-08-21T20:17:15.839166Z","shell.execute_reply":"2022-08-21T20:17:15.983532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#complete['post_time'].to_datetime( format='%H%M')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:15.986227Z","iopub.execute_input":"2022-08-21T20:17:15.988196Z","iopub.status.idle":"2022-08-21T20:17:15.993449Z","shell.execute_reply.started":"2022-08-21T20:17:15.988127Z","shell.execute_reply":"2022-08-21T20:17:15.992256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start['track_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:15.995265Z","iopub.execute_input":"2022-08-21T20:17:15.995678Z","iopub.status.idle":"2022-08-21T20:17:16.011776Z","shell.execute_reply.started":"2022-08-21T20:17:15.995642Z","shell.execute_reply":"2022-08-21T20:17:16.010529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(start['track_id'].value_counts() , color=start['track_id'].value_counts() , color_continuous_scale='Sunset')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.020879Z","iopub.execute_input":"2022-08-21T20:17:16.021281Z","iopub.status.idle":"2022-08-21T20:17:16.097731Z","shell.execute_reply.started":"2022-08-21T20:17:16.021247Z","shell.execute_reply":"2022-08-21T20:17:16.096677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.pie(values=start['track_id'].value_counts() , names=start['track_id'].value_counts().index)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.098901Z","iopub.execute_input":"2022-08-21T20:17:16.099210Z","iopub.status.idle":"2022-08-21T20:17:16.167446Z","shell.execute_reply.started":"2022-08-21T20:17:16.099181Z","shell.execute_reply":"2022-08-21T20:17:16.166190Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start['race_number'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.169187Z","iopub.execute_input":"2022-08-21T20:17:16.169616Z","iopub.status.idle":"2022-08-21T20:17:16.178328Z","shell.execute_reply.started":"2022-08-21T20:17:16.169582Z","shell.execute_reply":"2022-08-21T20:17:16.177267Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(start['race_number'].value_counts() , color=start['race_number'].value_counts() , color_continuous_scale='Sunset')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.179282Z","iopub.execute_input":"2022-08-21T20:17:16.179610Z","iopub.status.idle":"2022-08-21T20:17:16.256794Z","shell.execute_reply.started":"2022-08-21T20:17:16.179580Z","shell.execute_reply":"2022-08-21T20:17:16.255629Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start['program_number'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.258589Z","iopub.execute_input":"2022-08-21T20:17:16.259056Z","iopub.status.idle":"2022-08-21T20:17:16.269709Z","shell.execute_reply.started":"2022-08-21T20:17:16.259012Z","shell.execute_reply":"2022-08-21T20:17:16.268845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(start['program_number'].value_counts() , color=start['program_number'].value_counts() , color_continuous_scale='Sunset')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.270894Z","iopub.execute_input":"2022-08-21T20:17:16.272037Z","iopub.status.idle":"2022-08-21T20:17:16.348100Z","shell.execute_reply.started":"2022-08-21T20:17:16.271991Z","shell.execute_reply":"2022-08-21T20:17:16.347106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the chart we can see something is weird. Some values appear twice in the value_counts(). From the description it is passed as 3 chars and can be casted to int, perhaps this will solve our problem:","metadata":{}},{"cell_type":"code","source":"px.bar(race['course_type'].value_counts() , color=race['course_type'].value_counts() , color_continuous_scale='Sunset')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.349321Z","iopub.execute_input":"2022-08-21T20:17:16.349637Z","iopub.status.idle":"2022-08-21T20:17:16.785345Z","shell.execute_reply.started":"2022-08-21T20:17:16.349608Z","shell.execute_reply":"2022-08-21T20:17:16.784515Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"race.groupby('track_id')['course_type'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.786462Z","iopub.execute_input":"2022-08-21T20:17:16.786997Z","iopub.status.idle":"2022-08-21T20:17:16.798829Z","shell.execute_reply.started":"2022-08-21T20:17:16.786963Z","shell.execute_reply":"2022-08-21T20:17:16.797635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(race , x='track_id' , color='course_type' , color_discrete_sequence=px.colors.qualitative.Pastel)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.800303Z","iopub.execute_input":"2022-08-21T20:17:16.803192Z","iopub.status.idle":"2022-08-21T20:17:16.897016Z","shell.execute_reply.started":"2022-08-21T20:17:16.803140Z","shell.execute_reply":"2022-08-21T20:17:16.895614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(start , x='weight_carried')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.898641Z","iopub.execute_input":"2022-08-21T20:17:16.899122Z","iopub.status.idle":"2022-08-21T20:17:16.968142Z","shell.execute_reply.started":"2022-08-21T20:17:16.899076Z","shell.execute_reply":"2022-08-21T20:17:16.966925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(race , x='distance_id')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:16.970537Z","iopub.execute_input":"2022-08-21T20:17:16.971330Z","iopub.status.idle":"2022-08-21T20:17:17.037347Z","shell.execute_reply.started":"2022-08-21T20:17:16.971275Z","shell.execute_reply":"2022-08-21T20:17:17.036112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(race['track_condition'].value_counts() ,color=race['track_condition'].value_counts() , color_continuous_scale='Sunset')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.038855Z","iopub.execute_input":"2022-08-21T20:17:17.040098Z","iopub.status.idle":"2022-08-21T20:17:17.111042Z","shell.execute_reply.started":"2022-08-21T20:17:17.040060Z","shell.execute_reply":"2022-08-21T20:17:17.109828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(race , x='track_id' , color='track_condition' , color_discrete_sequence=px.colors.qualitative.Pastel)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.112534Z","iopub.execute_input":"2022-08-21T20:17:17.113017Z","iopub.status.idle":"2022-08-21T20:17:17.212085Z","shell.execute_reply.started":"2022-08-21T20:17:17.112984Z","shell.execute_reply":"2022-08-21T20:17:17.210853Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(race['race_type'].value_counts() ,color=race['race_type'].value_counts() , color_continuous_scale='Sunset')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.213491Z","iopub.execute_input":"2022-08-21T20:17:17.213871Z","iopub.status.idle":"2022-08-21T20:17:17.289839Z","shell.execute_reply.started":"2022-08-21T20:17:17.213834Z","shell.execute_reply":"2022-08-21T20:17:17.288649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(race , x='track_id' , color='race_type' , color_discrete_sequence=px.colors.qualitative.Pastel, title='track_id distribution')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.291305Z","iopub.execute_input":"2022-08-21T20:17:17.292226Z","iopub.status.idle":"2022-08-21T20:17:17.410937Z","shell.execute_reply.started":"2022-08-21T20:17:17.292186Z","shell.execute_reply":"2022-08-21T20:17:17.409804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(race , x='run_up_distance', title='Run up distance distribution')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.412511Z","iopub.execute_input":"2022-08-21T20:17:17.412965Z","iopub.status.idle":"2022-08-21T20:17:17.473706Z","shell.execute_reply.started":"2022-08-21T20:17:17.412932Z","shell.execute_reply":"2022-08-21T20:17:17.472742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start.sample(3)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.474854Z","iopub.execute_input":"2022-08-21T20:17:17.475484Z","iopub.status.idle":"2022-08-21T20:17:17.490607Z","shell.execute_reply.started":"2022-08-21T20:17:17.475448Z","shell.execute_reply":"2022-08-21T20:17:17.489651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(start , x='jockey' , y='odds' , histfunc='avg', title='Jockey vs Average Odds').update_xaxes(categoryorder='total descending')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.491914Z","iopub.execute_input":"2022-08-21T20:17:17.492697Z","iopub.status.idle":"2022-08-21T20:17:17.647473Z","shell.execute_reply.started":"2022-08-21T20:17:17.492663Z","shell.execute_reply":"2022-08-21T20:17:17.646290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = make_subplots()\nfig.add_trace(go.Scatter(x=start['weight_carried'], y=start['odds'], mode='markers' , marker_color=start['odds'] , name=\"Weight Carried vs Odds\"))\nfig.add_trace(go.Line(x=start.groupby('weight_carried')['odds'].mean().index, y=start.groupby('weight_carried')['odds'].mean(), name=\"Average odd per weight carried\"))\nfig.update_layout(title_text=\"Weight Carried vs Odds\")\nfig.update_xaxes(title_text=\"Weight Carried\" , range=[108,162])\nfig.update_yaxes(title_text=\"Odds\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.648986Z","iopub.execute_input":"2022-08-21T20:17:17.649344Z","iopub.status.idle":"2022-08-21T20:17:17.719772Z","shell.execute_reply.started":"2022-08-21T20:17:17.649312Z","shell.execute_reply":"2022-08-21T20:17:17.718555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.histogram(start , x='program_number' , y='odds' , histfunc='avg', title='Program number vs Average Odds').update_xaxes(categoryorder='total descending' )","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:17.721776Z","iopub.execute_input":"2022-08-21T20:17:17.722227Z","iopub.status.idle":"2022-08-21T20:17:17.878526Z","shell.execute_reply.started":"2022-08-21T20:17:17.722184Z","shell.execute_reply":"2022-08-21T20:17:17.877351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Geo-Visualization","metadata":{}},{"cell_type":"markdown","source":"I decided to split the visualizations of the geographical parameters and the rest of the parameters for comfort reasons.","metadata":{}},{"cell_type":"markdown","source":"First I will set a color pallate to assign a color to each value we will plot to make everything consistent:","metadata":{}},{"cell_type":"code","source":"colors_list = sns.color_palette(\"Paired\") + sns.color_palette(\"Set1\") + sns.color_palette(\"Set3\")\nlen(colors_list)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.128253Z","iopub.status.idle":"2022-08-21T20:17:18.128703Z","shell.execute_reply.started":"2022-08-21T20:17:18.128501Z","shell.execute_reply":"2022-08-21T20:17:18.128521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We have 33 colors to use, most likely be enough.","metadata":{}},{"cell_type":"markdown","source":"### race_number","metadata":{}},{"cell_type":"code","source":"colors_dict = {}\ni = 0\n\nfor item in tracking['race_number'].unique():\n    colors_dict[item] = colors_list[i]\n    i = i+1","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.129851Z","iopub.status.idle":"2022-08-21T20:17:18.130285Z","shell.execute_reply.started":"2022-08-21T20:17:18.130091Z","shell.execute_reply":"2022-08-21T20:17:18.130110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = tracking.query('track_id == \"AQU\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = colors_dict)\nplt.title(\"AQU track visualization by race\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.131677Z","iopub.status.idle":"2022-08-21T20:17:18.132155Z","shell.execute_reply.started":"2022-08-21T20:17:18.131953Z","shell.execute_reply":"2022-08-21T20:17:18.131974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = tracking.query('track_id == \"BEL\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = colors_dict)\nplt.title(\"BEL track visualization by race\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.133394Z","iopub.status.idle":"2022-08-21T20:17:18.133809Z","shell.execute_reply.started":"2022-08-21T20:17:18.133602Z","shell.execute_reply":"2022-08-21T20:17:18.133620Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = tracking.query('track_id == \"SAR\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = colors_dict)\nplt.title(\"SAR track visualization by race\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.135365Z","iopub.status.idle":"2022-08-21T20:17:18.135856Z","shell.execute_reply.started":"2022-08-21T20:17:18.135608Z","shell.execute_reply":"2022-08-21T20:17:18.135628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### program_number","metadata":{}},{"cell_type":"code","source":"colors_dict = {}\ni = 0\n\nfor item in tracking['program_number'].unique():\n    colors_dict[item] = colors_list[i]\n    i = i+1","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.137324Z","iopub.status.idle":"2022-08-21T20:17:18.137815Z","shell.execute_reply.started":"2022-08-21T20:17:18.137572Z","shell.execute_reply":"2022-08-21T20:17:18.137592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = tracking.query('track_id == \"AQU\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"program_number\", palette = colors_dict)\nplt.title(\"AQU track visualization by course type\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.138857Z","iopub.status.idle":"2022-08-21T20:17:18.139236Z","shell.execute_reply.started":"2022-08-21T20:17:18.139053Z","shell.execute_reply":"2022-08-21T20:17:18.139072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = tracking.query('track_id == \"BEL\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"program_number\", palette = colors_dict)\nplt.title(\"BEL track visualization by program_number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.142454Z","iopub.status.idle":"2022-08-21T20:17:18.143627Z","shell.execute_reply.started":"2022-08-21T20:17:18.143295Z","shell.execute_reply":"2022-08-21T20:17:18.143330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = tracking.query('track_id == \"SAR\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"program_number\", palette = colors_dict)\nplt.title(\"SAR track visualization by program_number\")\nplt.legend()\n","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.145505Z","iopub.status.idle":"2022-08-21T20:17:18.146140Z","shell.execute_reply.started":"2022-08-21T20:17:18.145825Z","shell.execute_reply":"2022-08-21T20:17:18.145855Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### course_type","metadata":{}},{"cell_type":"code","source":"colors_dict = {}\ni = 0\n\nfor item in complete['course_type'].unique():\n    colors_dict[item] = colors_list[i]\n    i = i+1","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.150885Z","iopub.status.idle":"2022-08-21T20:17:18.151907Z","shell.execute_reply.started":"2022-08-21T20:17:18.151541Z","shell.execute_reply":"2022-08-21T20:17:18.151576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = complete.query('track_id == \"AQU\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"course_type\", palette = colors_dict)\nplt.title(\"AQU track visualization by course type\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.153237Z","iopub.status.idle":"2022-08-21T20:17:18.153859Z","shell.execute_reply.started":"2022-08-21T20:17:18.153540Z","shell.execute_reply":"2022-08-21T20:17:18.153569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = complete.query('track_id == \"BEL\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"course_type\", palette = colors_dict)\nplt.title(\"BEL track visualization by course type\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.156336Z","iopub.status.idle":"2022-08-21T20:17:18.156980Z","shell.execute_reply.started":"2022-08-21T20:17:18.156651Z","shell.execute_reply":"2022-08-21T20:17:18.156679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_data = complete.query('track_id == \"SAR\"')\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = plot_data, x = \"longitude\", y = \"latitude\", hue = \"course_type\", palette = colors_dict)\nplt.title(\"SAR track visualization by course type\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.159580Z","iopub.status.idle":"2022-08-21T20:17:18.160467Z","shell.execute_reply.started":"2022-08-21T20:17:18.160161Z","shell.execute_reply":"2022-08-21T20:17:18.160191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Preprocessing","metadata":{}},{"cell_type":"markdown","source":"First we will drop all our irrelevant colums:","metadata":{}},{"cell_type":"code","source":"modeling_data = complete.drop(columns=['race_date','trakus_index','latitude','longitude','distance_id'])","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.161913Z","iopub.status.idle":"2022-08-21T20:17:18.163288Z","shell.execute_reply.started":"2022-08-21T20:17:18.162958Z","shell.execute_reply":"2022-08-21T20:17:18.162990Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"'race_date' just doesnt give us any information other than a timestamp, the 'trakus_index','latitude','longitude' and 'distance_id' only gives us information about geographical location of the horse so its also not so helpful.","metadata":{}},{"cell_type":"code","source":"modeling_data.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.165069Z","iopub.status.idle":"2022-08-21T20:17:18.165506Z","shell.execute_reply.started":"2022-08-21T20:17:18.165305Z","shell.execute_reply":"2022-08-21T20:17:18.165326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We have to remove all the duplicates:","metadata":{}},{"cell_type":"code","source":"modeling_data.drop_duplicates(inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.166887Z","iopub.status.idle":"2022-08-21T20:17:18.167309Z","shell.execute_reply.started":"2022-08-21T20:17:18.167110Z","shell.execute_reply":"2022-08-21T20:17:18.167131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modeling_data.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.168407Z","iopub.status.idle":"2022-08-21T20:17:18.168847Z","shell.execute_reply.started":"2022-08-21T20:17:18.168620Z","shell.execute_reply":"2022-08-21T20:17:18.168640Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"\nNow after cleaning our data , we have to encode our data categorical string data to numeric representation so we can model it. Before encoding we will make a copy once again, for the same reasons explained before. This will be very handy when we analyse our modeling results later","metadata":{}},{"cell_type":"code","source":"modeling_data_analysis = modeling_data.copy()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.171500Z","iopub.status.idle":"2022-08-21T20:17:18.171957Z","shell.execute_reply.started":"2022-08-21T20:17:18.171723Z","shell.execute_reply":"2022-08-21T20:17:18.171743Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From above we can see our string columns are: *'track_id','program_number', 'course_type', 'track_condition', 'race_type'* and *'jockey'* . We will use LabelEncoder to encode our data:","metadata":{}},{"cell_type":"code","source":"encoded_columns=['track_id','program_number', 'course_type', 'track_condition', 'race_type','jockey']\n\nencodes_dict = {}\nfor col in encoded_columns:\n    le = LabelEncoder()\n    modeling_data[col] = modeling_data[col].astype('str') # This is because some columns are both string and integer and it raises an error\n    modeling_data[col] = le.fit_transform(modeling_data[col])\n    encodes_dict[col] = le.classes_","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.173031Z","iopub.status.idle":"2022-08-21T20:17:18.173448Z","shell.execute_reply.started":"2022-08-21T20:17:18.173239Z","shell.execute_reply":"2022-08-21T20:17:18.173258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"As you noticed, I also like to keep an array of all encodes in case needed.\n\nNow we need to scale and standarize our data. I usually use MinMaxScaler for the categorical data and StandardScaler for the continuous data:","metadata":{}},{"cell_type":"code","source":"categorical_columns = ['track_id','race_number','program_number', 'course_type', 'track_condition','race_type','jockey']\ncontinuous_columns = [col for col in modeling_data.columns if col not in categorical_columns]\n\nfor col in modeling_data.columns:\n    if col in categorical_columns:\n        scaler = MinMaxScaler()\n        \n    elif col in continuous_columns:\n        scaler = StandardScaler(with_mean=True , with_std=True)\n        \n    scaler.fit(modeling_data[col].to_numpy().reshape(-1, 1))\n    modeling_data[col] = scaler.transform(modeling_data[col].to_numpy().reshape(-1, 1))","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.174553Z","iopub.status.idle":"2022-08-21T20:17:18.174986Z","shell.execute_reply.started":"2022-08-21T20:17:18.174781Z","shell.execute_reply":"2022-08-21T20:17:18.174805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modeling_data.sample(10)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.176484Z","iopub.status.idle":"2022-08-21T20:17:18.176937Z","shell.execute_reply.started":"2022-08-21T20:17:18.176692Z","shell.execute_reply":"2022-08-21T20:17:18.176712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.imshow(modeling_data.corr() , color_continuous_scale='RdBu' , height=800 , width=800, range_color = (-1, 1))","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.178078Z","iopub.status.idle":"2022-08-21T20:17:18.178476Z","shell.execute_reply.started":"2022-08-21T20:17:18.178283Z","shell.execute_reply":"2022-08-21T20:17:18.178302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.pairplot(modeling_data , corner=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.180862Z","iopub.status.idle":"2022-08-21T20:17:18.181274Z","shell.execute_reply.started":"2022-08-21T20:17:18.181081Z","shell.execute_reply":"2022-08-21T20:17:18.181101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"No correlation so its good.","metadata":{}},{"cell_type":"markdown","source":"# Modeling","metadata":{}},{"cell_type":"markdown","source":"The exploration did not give us any new information or insight about our data. We will try to cluster our data as it might give us any insights about the groups clustered.","metadata":{}},{"cell_type":"code","source":"clustering_res = pd.DataFrame(modeling_data.index)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.182889Z","iopub.status.idle":"2022-08-21T20:17:18.183289Z","shell.execute_reply.started":"2022-08-21T20:17:18.183096Z","shell.execute_reply":"2022-08-21T20:17:18.183115Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### K Means","metadata":{}},{"cell_type":"code","source":"K = range(2,10)\nscorelist = []\nfor k in K:\n    kmodel = KMeans(n_clusters=k, random_state=42)\n    clust = kmodel.fit_predict(modeling_data)\n    clustering_res[f'KMean_{k}'] = clust\n    score = silhouette_score(modeling_data,clust,metric='euclidean')\n    scorelist.append((k, score)) \nkmeans_res = pd.DataFrame(scorelist, columns=['k','score']) ","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.185853Z","iopub.status.idle":"2022-08-21T20:17:18.186404Z","shell.execute_reply.started":"2022-08-21T20:17:18.186172Z","shell.execute_reply":"2022-08-21T20:17:18.186194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.line(kmeans_res, x='k',y='score')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.187942Z","iopub.status.idle":"2022-08-21T20:17:18.188351Z","shell.execute_reply.started":"2022-08-21T20:17:18.188154Z","shell.execute_reply":"2022-08-21T20:17:18.188174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Agglomerative Clustering","metadata":{}},{"cell_type":"code","source":"N = range(2,10)\nscorelist = []\nfor n in N:\n    kmodel = AgglomerativeClustering(n_clusters=n, affinity='euclidean', linkage='ward')\n    clust = kmodel.fit_predict(modeling_data)\n    clustering_res[f'Agglomerative_{n}'] = clust\n    score = silhouette_score(modeling_data,clust,metric='euclidean')\n    scorelist.append((n, score)) \naffinity_res = pd.DataFrame(scorelist, columns=['n','score']) ","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.189829Z","iopub.status.idle":"2022-08-21T20:17:18.190749Z","shell.execute_reply.started":"2022-08-21T20:17:18.190536Z","shell.execute_reply":"2022-08-21T20:17:18.190559Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.line(affinity_res, x='n',y='score')","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.192370Z","iopub.status.idle":"2022-08-21T20:17:18.192815Z","shell.execute_reply.started":"2022-08-21T20:17:18.192584Z","shell.execute_reply":"2022-08-21T20:17:18.192604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"As we can see from the graphs, we got different results for each clustering method. The K means graph is a bit oscilating until 5 while in the Agglomerative graph we got a nice knee shape, therefore we will proceed with this algorithm with N=6 as number of clusters.","metadata":{}},{"cell_type":"code","source":"clustering_res['Agglomerative_6'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.194147Z","iopub.status.idle":"2022-08-21T20:17:18.194564Z","shell.execute_reply.started":"2022-08-21T20:17:18.194366Z","shell.execute_reply":"2022-08-21T20:17:18.194386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modeling_data_analysis['Cluster'] = clustering_res.set_index(modeling_data_analysis.index)['Agglomerative_6'] + 1","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.195882Z","iopub.status.idle":"2022-08-21T20:17:18.196311Z","shell.execute_reply.started":"2022-08-21T20:17:18.196109Z","shell.execute_reply":"2022-08-21T20:17:18.196131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modeling_data_analysis.sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.197397Z","iopub.status.idle":"2022-08-21T20:17:18.197831Z","shell.execute_reply.started":"2022-08-21T20:17:18.197604Z","shell.execute_reply":"2022-08-21T20:17:18.197623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def categorical_columns_plotter(data,col):\n    specs = [[{'type':'domain'}, {'type':'domain'} ,{'type':'domain'}] , [{'type':'domain'}, {'type':'domain'}, {'type':'domain'}]]\n    fig = make_subplots(rows=2, cols=3, specs=specs , subplot_titles=['Cluster 1', 'Cluster 2','Cluster 3','Cluster 4','Cluster 5','Cluster 6'])\n\n\n    for i in range(1,7):\n        pos = [(1,1),(1,2),(1,3),(2,1),(2,2),(2,3)]\n        fig_data = data.query(f'Cluster == {i}')[col].value_counts(normalize=True)\n        fig.add_trace(go.Pie(labels = fig_data.index , values = fig_data, name= f'Cluster {i}'), pos[i-1][0] , pos[i-1][1])\n\n    fig.update_traces(hoverinfo='label+percent+name', textinfo='none')\n    fig.update(layout_title_text=f'Clusters {col} distribution',\n               layout_showlegend=False)\n\n    fig = go.Figure(fig)\n    return fig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.199464Z","iopub.status.idle":"2022-08-21T20:17:18.199927Z","shell.execute_reply.started":"2022-08-21T20:17:18.199673Z","shell.execute_reply":"2022-08-21T20:17:18.199693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in categorical_columns:\n    categorical_columns_plotter(modeling_data_analysis,col)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.201150Z","iopub.status.idle":"2022-08-21T20:17:18.201561Z","shell.execute_reply.started":"2022-08-21T20:17:18.201357Z","shell.execute_reply":"2022-08-21T20:17:18.201377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def continuous_columns_plotter(data,col):\n    fig = make_subplots(rows=2, cols=3, subplot_titles=['Cluster 1', 'Cluster 2','Cluster 3','Cluster 4','Cluster 5','Cluster 6'])\n\n\n    for i in range(1,7):\n        pos = [(1,1),(1,2),(1,3),(2,1),(2,2),(2,3)]\n        fig_data = data.query(f'Cluster == {i}')[col]\n        fig.add_trace(go.Histogram(x = fig_data , name= f'Cluster {i}'), pos[i-1][0] , pos[i-1][1])\n\n    fig.update(layout_title_text=f'Clusters {col} distribution',\n               layout_showlegend=False)\n\n    fig = go.Figure(fig)\n    return fig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.202679Z","iopub.status.idle":"2022-08-21T20:17:18.203114Z","shell.execute_reply.started":"2022-08-21T20:17:18.202917Z","shell.execute_reply":"2022-08-21T20:17:18.202937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in continuous_columns:\n    continuous_columns_plotter(modeling_data_analysis,col)","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.205508Z","iopub.status.idle":"2022-08-21T20:17:18.205964Z","shell.execute_reply.started":"2022-08-21T20:17:18.205718Z","shell.execute_reply":"2022-08-21T20:17:18.205738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modeling_data_analysis.groupby('Cluster')[continuous_columns].mean()","metadata":{"execution":{"iopub.status.busy":"2022-08-21T20:17:18.208907Z","iopub.status.idle":"2022-08-21T20:17:18.209498Z","shell.execute_reply.started":"2022-08-21T20:17:18.209191Z","shell.execute_reply":"2022-08-21T20:17:18.209220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### More soon...","metadata":{}}]}