-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathipl-app.py
1487 lines (1411 loc) · 60.3 KB
/
ipl-app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import warnings
warnings.simplefilter(action="ignore", category=UserWarning)
from dash_core_components.Dropdown import Dropdown
from dash_core_components.Graph import Graph
from dash_core_components.Markdown import Markdown
from dash_html_components.Div import Div
from dash_html_components.H2 import H2
from dash_html_components.I import I
from dash_html_components.Label import Label
from dash_html_components.P import P
from pandas._config.config import options
from pandas.core.indexes import multi
from pandas.io.formats import style
import dash
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_table
import plotly.graph_objects as go
import plotly.express as px
import pandas as pd
import numpy as np
import os
import base64
# function for loading data
file_path = os.path.join(os.getcwd(), "data")
def load_data(filename, file_path=file_path):
csv_path = os.path.join(file_path, filename)
return pd.read_csv(csv_path)
# read the data
points_table = load_data("points_table.csv")
points_table["Net R/R"] = points_table["Net R/R"].round(3)
wins_losses = load_data("wins_losses.csv")
wins_losses.sort_values(by=["Titles", "Win %"], ascending=[False, False], inplace=True)
wins_losses.drop("Span", axis=1, inplace=True)
# read batting data
batting = load_data("batting.csv")
batting.iloc[batting[batting["PLAYER"] == "Rohit Sharma"].index, 16] = "Mumbai Indians"
batting_players_list = list(batting["PLAYER"].unique())
# batting aggregated data
batting_agg = load_data("batting_all_time.csv")
# read bowling data
bowling = load_data("bowling.csv")
bowling = bowling.rename(columns={"Maid": "Maiden"})
bowling_players_list = list(bowling["PLAYER"].unique())
# create a new column
bowling["Runs/Inns"] = (bowling["Runs"] / bowling["Inns"]).round(2)
# read bowling aggregated data
bowling_agg = load_data("bowling_all_time.csv")
# copy the data that is not avialable in aggregated csv
bowling_subset = bowling[["PLAYER", "Dots", "Maiden"]].copy()
# calculate aggregates and join
bs_groupby = bowling_subset.groupby("PLAYER").sum().reset_index()
bowling_agg = pd.merge(
left=bowling_agg, right=bs_groupby, left_on="PLAYER", right_on="PLAYER"
)
# delete un-necessary column
bowling_agg.drop("Player Link", axis=1, inplace=True)
# create a new column
bowling_agg["Runs/Inns"] = (bowling_agg["Runs"] / bowling_agg["Inns"]).round(2)
batting_metrics_list = [
"Runs",
"HS",
"Avg",
"BF",
"SR",
"100",
"50",
"4s",
"6s",
"Mat",
"Inns",
"NO",
]
bowling_metrics_list = [
"Wkts",
"Econ",
"Avg",
"SR",
"Runs/Inns",
"Dots",
"4w",
"5w",
"Maiden",
"Ov",
]
team_list = [
"All Teams",
"Sunrisers Hyderabad",
"Kings Xi Punjab",
"Mumbai Indians",
"Delhi Capitals",
"Kolkata Knight Riders",
"Royal Challengers Bangalore",
"Chennai Super Kings",
"Rajasthan Royals",
]
heading_markdown = """
# IPL Stats (2008-2019)
### by Bhola Prasad
#### Website - [Life With Data](https://www.lifewithdata.com/)
"""
# year list
year_list = [year for year in range(2019, 2007, -1)]
# players runs distribution plot
runs_dist_plot = px.histogram(batting, x="Runs")
runs_dist_plot.update_layout(title="Distribution of Player Runs(2008-2019)")
# players runs kde plot
import plotly.figure_factory as ff
unique_teams = batting["Team"].unique()
hist_data = [
batting[batting["Team"] == team]["Runs"] for team in unique_teams if team != "Nan"
]
group_labels = ["SRH", "KXIP", "MI", "DC", "KKR", "RCB", "CSK", "RR"]
colors = ["Orange", "Silver", "Blue", "Black", "Gold", "Red", "Yellow", "Green"]
runs_kde_plot = ff.create_distplot(
hist_data, group_labels, show_hist=False, show_rug=False, colors=colors
)
runs_kde_plot.update_layout(
title="Kde Plot of Runs", xaxis=dict(title="Runs"), yaxis=dict(title="Density")
)
# function for adding local images
def encode_image(image_file):
encoded = base64.b64encode(open(image_file, "rb").read())
return "data:image/png;base64,{}".format(encoded.decode())
# Batting Feature Importances figures
batting_bar = os.getcwd() + "/images/batting_bar.png"
batting_beeswarm = os.getcwd() + "/images/batting_beeswarm.png"
batting_bf = os.getcwd() + "/images/batting_bf.png"
batting_sr = os.getcwd() + "/images/batting_sr.png"
# Bowling Feature Importances figures
bowling_bar = os.getcwd() + "/images/bowling_bar.png"
bowling_beeswarm = os.getcwd() + "/images/bowling_beeswarm.png"
bowling_sr = os.getcwd() + "/images/bowling_sr.png"
bowling_dots = os.getcwd() + "/images/bowling_dots.png"
###### Bowling plots
# wickets histogram
wickets_histogram = px.histogram(bowling, x="Wkts")
wickets_histogram.update_layout(
title="Number of Wickets In A Season(2008-2019)",
yaxis=dict(title="Player Count"),
xaxis=dict(title="Number Of Wickets"),
)
# wickets taken by teams distribution
team_wickets_dist = px.box(bowling[bowling["Team"] != "Nan"], x="Wkts", y="Team")
team_wickets_dist.update_layout(
title="Wickets Taken Per Season (2008-2019)",
yaxis=dict(title="Players Team"),
xaxis=dict(title="Total Wickets"),
)
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SOLAR])
server = app.server
app.layout = html.Div(
[
html.H1("IPL Stats (2008-2019)"),
html.H4("by Bhola Prasad"),
dcc.Markdown("##### Website - [Life With Data](https://www.lifewithdata.com/)"),
##### Points Table
html.Div([], style={"height": "100px"}),
html.H3("Points Table"),
html.Div(
[
html.Div(
[
html.Label("Select a Season"),
dcc.Dropdown(
id="points-year-selector",
options=[
{"label": str(year), "value": year}
for year in year_list
],
value=2019,
),
],
style={"width": "20%", "display": "inline-block"},
),
]
),
html.Div(
[
html.Div(
[
# points table data
dash_table.DataTable(
id="points-table",
columns=[
{"name": i, "id": i} for i in points_table.columns
],
data=points_table.to_dict("records"),
sort_action="native",
style_cell={"textAlign": "left"},
style_data_conditional=[
{
"if": {"row_index": "odd"},
"backgroundColor": "rgb(248, 248, 248)",
},
{
"if": {"column_id": "Team"},
"backgroundColor": "#3D9970",
"color": "white",
},
{
"if": {
"column_id": "Points",
"row_index": [0, 1, 2, 3],
},
"backgroundColor": "#3D9970",
"color": "white",
},
],
),
],
style={"margin": "15px", "width": "70%"},
)
]
),
####### Team Wins and Losses Table
html.Div([], style={"height": "45px"}),
html.H3("Team Records"),
html.Div(
[
dash_table.DataTable(
id="wins-losses-table",
columns=[{"name": i, "id": i} for i in wins_losses.columns],
data=wins_losses.to_dict("records"),
sort_action="native",
style_cell={"textAlign": "left"},
style_data_conditional=[
{
"if": {"row_index": "odd"},
"backgroundColor": "rgb(248, 248, 248)",
},
{
"if": {"column_id": "Team"},
"backgroundColor": "#3D9970",
"color": "white",
},
{
"if": {"column_id": "Win %", "row_index": [0, 1]},
"backgroundColor": "#3D9970",
"color": "white",
},
{
"if": {"column_id": "Titles", "row_index": [0, 1]},
"backgroundColor": "#3D9970",
"color": "white",
},
],
),
],
style={"margin": "15px", "width": "70%"},
),
###### Batting stats
html.Div([], style={"height": "45px"}),
html.H2("Batting Records"),
html.Div(
[
html.Div([], style={"height": "25px"}),
html.H4("Player Runs Per Season"),
html.B("Select Players"),
html.P("Use dropdown to select multiple players or remove them."),
dcc.Dropdown(
id="select-player-ts",
options=[
{"label": player, "value": player}
for player in batting_players_list
],
value=[
"Virat Kohli",
"Rohit Sharma",
"David Warner",
"KL Rahul",
],
multi=True,
),
# Players Runs Time-Series Chart
dcc.Graph(id="players-runs-time-series"),
],
style={"width": "70%"},
),
###### Runs Distributions
html.Div([], style={"height": "45px"}),
html.H3("Runs Distributions"),
# Histogram of Runs Distributions
html.Div(
[
html.Div(
[
html.P(
"We can see that the distribution is right skewed. Many "
"players makes low or medium runs, while few players makes "
"lots of runs. The median of this distribution is 126 which "
"means that 50% of the players makes less than 126 runs and "
"50% more than this. 406 is the 90th percentile, meaning 90% "
"of the players makes less than 406 runs. So, any players who "
"is making more than 400 runs in a season is really doing well. "
"They are in the top 10%."
)
],
style={
"width": "30%",
"display": "inline-block",
"margin-top": "60px",
},
),
html.Div(
[dcc.Graph(id="runs-dist-plot", figure=runs_dist_plot)],
style={"width": "60%", "float": "right", "display": "inline-block"},
),
],
style={"margin": "40px", "height": 500},
),
# Kernal density estimation of Runs distributions
html.Div(
[
html.Div(
[
html.P(
"After segmenting the runs distribution by team, "
"it is clear that percentage of players making runs "
"within the 300 range is lower for csk compared to other "
"teams and the higher within the range 300 to 600, which is "
"what you want.Less percentage at the lower end and higher at "
"the middle and upper end. On average, csk players make 235 "
"runs,compared to 187 runs by Mumbai Indians which is the second "
"highest."
)
],
style={
"width": "30%",
"display": "inline-block",
"margin-top": "100px",
},
),
html.Div(
[
dcc.Graph(
id="runs-kde-plot",
figure=runs_kde_plot,
)
],
style={"width": "60%", "float": "right", "display": "inline-block"},
),
],
style={"margin": "40px", "height": 500},
),
# Batting Leaderboard - All Time
html.H3("Batting Leaderboard"),
html.Div([], style={"height": "25px"}),
html.H4("All Time Records"),
html.Div([], style={"height": "20px"}),
html.Div(
[
dcc.Tabs(
[
dcc.Tab(
label="Chart",
children=[
html.P(""),
html.Div(
[
html.Div(
[
html.Label("Select a Metric"),
dcc.Dropdown(
id="all-time-metric-selector",
options=[
{
"label": metric,
"value": metric,
}
for metric in batting_metrics_list
],
value="Runs",
),
],
style={
"width": "35%",
"display": "inline-block",
},
),
html.Div(
[
html.Label("Select Team"),
dcc.Dropdown(
id="all-time-team-selector",
options=[
{
"label": team,
"value": team,
}
for team in team_list
],
value="All Teams",
),
],
style={
"width": "35%",
"float": "right",
"display": "inline-block",
},
),
]
),
html.Div([dcc.Graph(id="all-time-graph")]),
],
),
dcc.Tab(
label="Table",
children=[
dash_table.DataTable(
id="all-time-records",
columns=[
{"name": i, "id": i}
for i in batting_agg.columns
],
data=batting_agg.to_dict("records"),
sort_action="native",
style_cell={"textAlign": "left"},
style_data_conditional=[
{
"if": {"row_index": "odd"},
"backgroundColor": "rgb(248, 248, 248)",
},
],
style_table={"overflowX": "auto"},
style_cell_conditional=[
{
"if": {"column_id": "PLAYER"},
"textAlign": "center",
},
],
page_current=0,
page_size=15,
page_action="native",
)
],
),
]
)
],
style={"width": "75%"},
),
# Season Records
html.Div([], style={"height": "45px"}),
html.H4("Season Records"),
html.Div([], style={"height": "20px"}),
html.Div(
[
dcc.Tabs(
[
dcc.Tab(
label="Chart",
children=[
html.P(""),
html.Div(
[
html.Div(
[
html.Label("Select a Metric"),
dcc.Dropdown(
id="season-metric-selector",
options=[
{
"label": metric,
"value": metric,
}
for metric in batting_metrics_list
],
value="Runs",
),
],
style={
"width": "25%",
"float": "left",
"padding-right": "25px",
"display": "inline-block",
},
),
html.Div(
[
html.Label("Season"),
dcc.Dropdown(
id="season-year-selector",
options=[
{
"label": str(year),
"value": year,
}
for year in range(
2019, 2007, -1
)
],
value=2019,
),
],
style={
"width": "25%",
"float": "middle",
"display": "inline-block",
},
),
html.Div(
[
html.Label("Team"),
dcc.Dropdown(
id="season-team-selector",
options=[
{"label": team, "value": team}
for team in team_list
],
value="All Teams",
),
],
style={
"width": "25%",
"float": "right",
"display": "inline-block",
},
),
],
),
html.Div([dcc.Graph(id="season-graph")]),
],
),
dcc.Tab(
label="Table",
children=[
dash_table.DataTable(
id="season-records",
columns=[
{"name": i, "id": i}
for i in batting.columns
if i != "Player Link"
],
data=batting.to_dict("records"),
sort_action="native",
style_cell={"textAlign": "left"},
style_data_conditional=[
{
"if": {"row_index": "odd"},
"backgroundColor": "rgb(248, 248, 248)",
},
],
style_table={"overflowX": "auto"},
style_cell_conditional=[
{
"if": {"column_id": "POS"},
"textAlign": "center",
},
],
page_current=0,
page_size=15,
page_action="native",
)
],
),
]
)
],
style={"width": "75%"},
),
# Features importances
html.Div([], style={"height": "80px"}),
html.H4("Important features for predicting players runs."),
html.Div([], style={"height": "25px"}),
html.Div(
[
html.Div(
[
dcc.Tabs(
id="tabs-with-classes",
value="tab-1",
parent_className="custom-tabs",
className="custom-tabs-container",
children=[
dcc.Tab(
label="Feature Importances",
children=[html.Img(src=encode_image(batting_bar))],
),
dcc.Tab(
label="FI Beeswarm",
children=[
html.Img(src=encode_image(batting_beeswarm))
],
),
dcc.Tab(
label="Ball Faced",
children=[html.Img(src=encode_image(batting_bf))],
),
dcc.Tab(
label="Strike Rate",
children=[html.Img(src=encode_image(batting_sr))],
),
],
)
],
style={"width": "88%"},
),
html.Div([], style={"height": "25px"}),
html.Div(
[
html.H5("Feature Importances: "),
html.P(
"BF - This is the most important feature in predicting how much runs a player will make and"
"as the number of ball faced increases the number of runs also increases, so spending more"
"time on the field is even much more important than having a very higher strike rate. "
),
html.P(
"SR - Second most important feature is strike rate and having a higher strike rate is good."
),
html.P(
"4s and 6s - Hitting 4s is slightly more important than hitting 6s in making runs in the long "
"run. The reason cloud be hitting 4s is much easier than hitting 6s so most of the time players "
"tends to have more 4s than 6s and when added together, in the long run 4s generate more runs."
),
html.P(
"Avg - Batting avg is also important but not as much as the above mentioned metrics."
),
],
style={"width": "85%"},
),
],
style={"width": "75%"},
),
# Bowling Records
html.Div([], style={"height": "45px"}),
html.H2("Bowling Records"),
html.Div([], style={"height": "25px"}),
html.H4("Player Wickets Per Season"),
html.Div(
[
html.B("Select Players"),
html.P(""),
dcc.Dropdown(
id="select-player-wkts-ts",
options=[
{"label": player, "value": player}
for player in bowling_players_list
],
value=[
"Jasprit Bumrah",
"Rashid Khan",
"Kagiso Rabada",
"Sunil Narine",
"Deepak Chahar",
],
multi=True,
),
dcc.Graph(id="players-wickets-time-series"),
],
style={"width": "70%"},
),
html.Div([], style={"height": "45px"}),
html.H4("Wickets Distributions"),
# Histogram of Wickets Distributions
html.Div(
[
html.Div(
[
html.P(
"Just like runs, wickets distribution is also right skewed, means "
"many players takes low or medium number of wickets, while few "
"players takes lots of wickets.The median of this distribution is 5 "
"which means that 50% of the players taks less than 5 wickets and "
"50% more than 5 wickets. 15 is the 90th percentile, meaning 90% "
"of the players takes less than 15 wickets. So, any players who "
"is taking more than or equal to 15 wickets in a season is doing "
"exceptionally well. "
)
],
style={
"width": "30%",
"display": "inline-block",
"margin-top": "60px",
},
),
html.Div(
[dcc.Graph(id="wickets-hist-plot", figure=wickets_histogram)],
style={"width": "60%", "float": "right", "display": "inline-block"},
),
],
style={"margin": "40px", "height": 500},
),
# Team wickets distributions
html.Div(
[
html.Div(
[
html.P(
"On average, Chennai Super Kings bowlers also performs better "
"than any other teams. Rajasthan Royals has some good balance in "
"their team which is why their median wickets is second highest "
"after CSK but overall gets outperformed by other teams. And there "
"is lot of variability in Sunrisers hyderabad team, they have really "
"some high wickets takers but the team is not much balanced which is "
"why they have a very low median value. Out of all Royal Challengers "
"Banglore and Delhi Capitals is performing very poorly. "
)
],
style={
"width": "30%",
"display": "inline-block",
"margin-top": "100px",
},
),
html.Div(
[
dcc.Graph(
id="team-wickets-dist",
figure=team_wickets_dist,
)
],
style={"width": "60%", "float": "right", "display": "inline-block"},
),
],
style={"margin": "40px", "height": 500},
),
# Bowling Leaderboard
html.H3("Bowling Leaderboard"),
html.Div([], style={"height": "25px"}),
html.H4("All Time Records"),
html.Div([], style={"height": "20px"}),
html.Div(
[
dcc.Tabs(
[
dcc.Tab(
label="Chart",
children=[
html.P(""),
html.Div(
[
html.Div(
[
html.Label("Select a Metric"),
dcc.Dropdown(
id="all-time-metric-selector-bowling",
options=[
{
"label": metric,
"value": metric,
}
for metric in bowling_metrics_list
],
value="Wkts",
),
],
style={
"width": "35%",
"display": "inline-block",
},
),
html.Div(
[
html.Label("Select Team"),
dcc.Dropdown(
id="all-time-team-selector-bowling",
options=[
{
"label": team,
"value": team,
}
for team in team_list
],
value="All Teams",
),
],
style={
"width": "35%",
"float": "right",
"display": "inline-block",
},
),
]
),
html.Div([dcc.Graph(id="all-time-graph-bowling")]),
],
),
dcc.Tab(
label="Table",
children=[
dash_table.DataTable(
id="all-time-records-bowling",
columns=[
{"name": i, "id": i}
for i in bowling_agg.columns
],
data=bowling_agg.to_dict("records"),
sort_action="native",
style_cell={
"textAlign": "left",
},
style_data_conditional=[
{
"if": {"row_index": "odd"},
"backgroundColor": "rgb(248, 248, 248)",
},
],
style_table={"overflowX": "auto"},
style_cell_conditional=[
{
"if": {"column_id": "POS"},
"textAlign": "center",
},
],
page_current=0,
page_size=15,
page_action="native",
)
],
),
]
)
],
style={"width": "75%"},
),
# Season Records - Bowling
html.Div([], style={"height": "45px"}),
html.H4("Season Records"),
html.Div([], style={"height": "20px"}),
html.Div(
[
dcc.Tabs(
[
dcc.Tab(
label="Chart",
children=[
html.P(""),
html.Div(
[
html.Div(
[
html.Label("Select a Metric"),
dcc.Dropdown(
id="season-metric-selector-bowling",
options=[
{
"label": metric,
"value": metric,
}
for metric in bowling_metrics_list
],
value="Wkts",
),
],
style={
"width": "25%",
"float": "left",
"padding-right": "25px",
"display": "inline-block",
},
),
html.Div(
[
html.Label("Season"),
dcc.Dropdown(
id="season-year-selector-bowling",
options=[
{
"label": str(year),
"value": year,
}
for year in range(
2019, 2007, -1
)
],
value=2019,
),
],
style={
"width": "25%",
"float": "middle",
"display": "inline-block",
},
),
html.Div(
[
html.Label("Team"),
dcc.Dropdown(
id="season-team-selector-bowling",
options=[
{"label": team, "value": team}
for team in team_list
],
value="All Teams",
),
],
style={
"width": "25%",
"float": "right",
"display": "inline-block",
},
),
],
),
html.Div([dcc.Graph(id="season-graph-bowling")]),
],
),
dcc.Tab(
label="Table",
children=[
dash_table.DataTable(
id="season-records-bowling",
columns=[
{"name": i, "id": i}
for i in bowling.columns
if i != "Player Link"
],
data=bowling.to_dict("records"),
sort_action="native",
style_cell={"textAlign": "left"},
style_data_conditional=[
{
"if": {"row_index": "odd"},
"backgroundColor": "rgb(248, 248, 248)",
},
],
style_table={"overflowX": "auto"},
style_cell_conditional=[
{
"if": {"column_id": "POS"},
"textAlign": "center",
},
],
page_current=0,
page_size=15,
page_action="native",
)
],
),
]
)
],
style={"width": "75%"},
),
# bowler Performance
html.Div([], style={"height": "80px"}),
html.H4("Important features for predicting bowlers wickets."),
html.Div([], style={"height": "25px"}),
html.Div(
[
html.Div(
[
dcc.Tabs(
id="tabs-with-classes-bowling",
parent_className="custom-tabs-bowling",
className="custom-tabs-container-bowling",
children=[
dcc.Tab(
label="Feature Importance",
children=[html.Img(src=encode_image(bowling_bar))],
),
dcc.Tab(
label="FI Beeswarm",
children=[
html.Img(src=encode_image(bowling_beeswarm))
],
),
dcc.Tab(
label="Strike Rate",