├── ipl20 ├── .DS_Store ├── teams │ ├── .ipynb_checkpoints │ │ └── 1216496_RR_today_squad-checkpoint.csv │ ├── 1216519_squad.csv │ ├── 1216532_squad.csv │ ├── 1216538_squad.csv │ ├── 1216547_squad.csv │ ├── 1216542_squad.csv │ ├── 1216496_squad.csv │ ├── 1216514_squad.csv │ ├── 1216510_squad.csv │ ├── 1216527_squad.csv │ ├── 1216511_squad.csv │ └── 1216504_squad.csv ├── 1216514.csv ├── name_mapping_clean.csv ├── matchdatascorecardpathipl20.csv ├── .ipynb_checkpoints │ └── match_summary_ipl20-checkpoint.csv ├── match_summary_ipl20.csv └── 1216501.csv ├── Data ├── rf_model.pkl ├── xgb_model.pkl ├── OnHotEncoder_rf.pkl ├── catboost_model.pkl ├── ensemble_model.pkl ├── OnHotEncoder_xgb.pkl ├── OnHotEncoder_catboost.pkl ├── rewards_yearly_summary.csv ├── pred_team11.csv ├── pred_team11_details.csv ├── model_prediction.csv └── pred_data_features.csv ├── Dream11 Approach Doc.docx ├── requirement.txt ├── .gitignore ├── pred_team11_details.csv ├── send_email.py ├── parse_teams.py ├── README.md ├── optimized_selection.py ├── MatchDataParsing.py ├── point_prediction.py ├── controller.py ├── main.py ├── data_prep.py └── download_ipl20.py /ipl20/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/ipl20/.DS_Store -------------------------------------------------------------------------------- /Data/rf_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Data/rf_model.pkl -------------------------------------------------------------------------------- /Data/xgb_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Data/xgb_model.pkl -------------------------------------------------------------------------------- /Data/OnHotEncoder_rf.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Data/OnHotEncoder_rf.pkl -------------------------------------------------------------------------------- /Data/catboost_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Data/catboost_model.pkl -------------------------------------------------------------------------------- /Data/ensemble_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Data/ensemble_model.pkl -------------------------------------------------------------------------------- /Data/OnHotEncoder_xgb.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Data/OnHotEncoder_xgb.pkl -------------------------------------------------------------------------------- /Dream11 Approach Doc.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Dream11 Approach Doc.docx -------------------------------------------------------------------------------- /Data/OnHotEncoder_catboost.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishek374/dream11/HEAD/Data/OnHotEncoder_catboost.pkl -------------------------------------------------------------------------------- /requirement.txt: -------------------------------------------------------------------------------- 1 | catboost==0.24 2 | category-encoders==2.1.0 3 | scikit-learn==0.22.1 4 | scipy==1.4.1 5 | statsmodels==0.11.1 6 | tqdm==4.46.1 7 | xgboost==1.1.1 8 | xlrd==1.2.0 9 | pulp==2.5.1 10 | pmdarima==1.8.3 11 | requests==2.26.0 12 | -------------------------------------------------------------------------------- /Data/rewards_yearly_summary.csv: -------------------------------------------------------------------------------- 1 | year,error,rewards_earned 2 | 2008,0.27729776600613026,2050.0 3 | 2009,0.28937203849918974,1125.0 4 | 2010,0.24571738455754707,6100.0 5 | 2011,0.22137914072787124,195475.0 6 | 2012,0.2560346536254049,14125.0 7 | 2013,0.28211288375433563,2200.0 8 | 2014,0.2918387212730295,-350.0 9 | 2015,0.2912882317747623,7825.0 10 | 2016,0.28328705855642505,26850.0 11 | 2017,0.32050177390090506,3550.0 12 | 2018,0.2744800493229555,6825.0 13 | 2019,0.3328595675827711,14500.0 14 | -------------------------------------------------------------------------------- /Data/pred_team11.csv: -------------------------------------------------------------------------------- 1 | playername,teamname,playingrole,playercost,model1_points,model1_team,model2_points,model2_team 2 | DJ Bravo,Chennai Super Kings,AllRounder,10.0,38.0,1.0,43.0,1.0 3 | AR Patel,Delhi Capitals,AllRounder,8.5,38.0,1.0,40.0,1.0 4 | SS Iyer,Delhi Capitals,Batsmen,9.0,37.0,1.0,35.0,1.0 5 | F du Plessis,Chennai Super Kings,Batsmen,9.0,37.0,1.0,35.0,1.0 6 | RA Jadeja,Chennai Super Kings,AllRounder,8.5,36.0,1.0,41.0,1.0 7 | S Dhawan,Delhi Capitals,Batsmen,10.0,35.0,1.0,36.0,1.0 8 | AT Rayudu,Chennai Super Kings,Batsmen,9.0,34.0,1.0,28.0, 9 | RR Pant,Delhi Capitals,Batsmen,9.5,33.0,1.0,27.0, 10 | SN Thakur,Chennai Super Kings,Bowler,8.5,31.0,1.0,31.0,1.0 11 | K Rabada,Delhi Capitals,Bowler,9.5,30.0,1.0,29.0, 12 | DL Chahar,Chennai Super Kings,Bowler,8.5,29.0,1.0,28.0, 13 | PP Shaw,Delhi Capitals,Batsmen,8.5,33.0,,30.0,1.0 14 | MP Stoinis,Delhi Capitals,AllRounder,8.5,32.0,,19.0, 15 | MS Dhoni,Chennai Super Kings,Batsmen,9.5,31.0,,36.0,1.0 16 | SO Hetmyer,Delhi Capitals,Batsmen,8.5,29.0,,30.0, 17 | A Nortje,Delhi Capitals,Bowler,8.0,27.0,,30.0,1.0 18 | R Ashwin,Delhi Capitals,Bowler,9.0,27.0,,30.0,1.0 19 | -------------------------------------------------------------------------------- /ipl20/teams/.ipynb_checkpoints/1216496_RR_today_squad-checkpoint.csv: -------------------------------------------------------------------------------- 1 | playername,iscaptain,position,profilelink,teamname 2 | Robin Uthappa,False,Batsman,https://www.espncricinfo.com/ci/content/player/35582.html,RR 3 | Yashasvi Jaiswal,False,Batsman,https://www.espncricinfo.com/ci/content/player/1151278.html,RR 4 | Sanju Samson,False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/425943.html,RR 5 | Steven Smith,True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR 6 | David Miller,False,Batsman,https://www.espncricinfo.com/ci/content/player/321777.html,RR 7 | Riyan Parag,False,Batsman,https://www.espncricinfo.com/ci/content/player/1079434.html,RR 8 | Shreyas Gopal,False,Allrounder,https://www.espncricinfo.com/ci/content/player/344580.html,RR 9 | Tom Curran,False,Allrounder,https://www.espncricinfo.com/ci/content/player/550235.html,RR 10 | Jofra Archer,False,Bowler,https://www.espncricinfo.com/ci/content/player/669855.html,RR 11 | Rahul Tewatia,False,Bowler,https://www.espncricinfo.com/ci/content/player/423838.html,RR 12 | Jaydev Unadkat,False,Bowler,https://www.espncricinfo.com/ci/content/player/390484.html,RR 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /test_solver.py 2 | /.idea/ 3 | **/.ipynb_checkpoints/ 4 | **/catboost_info/ 5 | **/__pycache__ 6 | **/.ipynb_checkpoints/ 7 | Data/feature_importance_catboost.csv 8 | ipl20/1216494.csv 9 | ipl20/1216495.csv 10 | ipl20/1216497.csv 11 | ipl20/1216498.csv 12 | ipl20/1216499.csv 13 | ipl20/1216500.csv 14 | ipl20/1216502.csv 15 | ipl20/1216505.csv 16 | ipl20/1216506.csv 17 | ipl20/1216507.csv 18 | ipl20/1216509.csv 19 | ipl20/1216512.csv 20 | ipl20/1216517.csv 21 | ipl20/1216518.csv 22 | ipl20/1216520.csv 23 | ipl20/1216521.csv 24 | ipl20/1216522.csv 25 | ipl20/1216523.csv 26 | ipl20/1216524.csv 27 | ipl20/1216525.csv 28 | ipl20/1216526.csv 29 | ipl20/1216528.csv 30 | ipl20/1216529.csv 31 | ipl20/1216530.csv 32 | ipl20/1216531.csv 33 | ipl20/1216533.csv 34 | ipl20/1216535.csv 35 | ipl20/1216536.csv 36 | ipl20/1216537.csv 37 | ipl20/1216540.csv 38 | ipl20/1216541.csv 39 | ipl20/1216543.csv 40 | ipl20/1216544.csv 41 | ipl20/1216546.csv 42 | ipl20/1237177.csv 43 | ipl20/1237178.csv 44 | ipl20/1237180.csv 45 | ipl20/1237181.csv 46 | ipl20/teams/1216495_squad.csv 47 | ipl20/teams/1216497_squad.csv 48 | ipl20/teams/1216498_squad.csv 49 | ipl20/teams/1216499_squad.csv 50 | ipl20/teams/1216502_squad.csv 51 | ipl20/teams/1216505_squad.csv 52 | ipl20/teams/1216506_squad.csv 53 | ipl20/teams/1216507_squad.csv 54 | ipl20/teams/1216512_squad.csv 55 | ipl20/teams/1216518_squad.csv 56 | ipl20/teams/1216520_squad.csv 57 | ipl20/teams/1216521_squad.csv 58 | ipl20/teams/1216522_squad.csv 59 | ipl20/teams/1216528_squad.csv 60 | ipl20/teams/1216529_squad.csv 61 | ipl20/teams/1216530_squad.csv 62 | ipl20/teams/1216531_squad.csv 63 | ipl20/teams/1216533_squad.csv 64 | ipl20/teams/1216535_squad.csv 65 | ipl20/teams/1216536_squad.csv 66 | ipl20/teams/1216537_squad.csv 67 | ipl20/teams/1216540_squad.csv 68 | ipl20/teams/1216541_squad.csv 69 | ipl20/teams/1216543_squad.csv 70 | ipl20/teams/1216544_squad.csv 71 | test.py 72 | ~/ 73 | .vscode -------------------------------------------------------------------------------- /ipl20/teams/1216519_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,playername 2 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1119026.html,RCB,Devdutt Padikkal 3 | False,Batsman,https://www.espncricinfo.com/ci/content/player/5334.html,RCB,AJ Finch 4 | True,Batsman,https://www.espncricinfo.com/ci/content/player/253802.html,RCB,V Kohli 5 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/44936.html,RCB,AB de Villiers 6 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/8917.html,RCB,MM Ali 7 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/714451.html,RCB,S Dube 8 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/719715.html,RCB,Washington Sundar 9 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/328026.html,RCB,I Udana 10 | False,Bowler,https://www.espncricinfo.com/ci/content/player/700167.html,RCB,NA Saini 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/430246.html,RCB,YS Chahal 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/940973.html,RCB,M Siraj 13 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1070168.html,DC,PP Shaw 14 | False,Batsman,https://www.espncricinfo.com/ci/content/player/28235.html,DC,S Dhawan 15 | True,Batsman,https://www.espncricinfo.com/ci/content/player/642519.html,DC,SS Iyer 16 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/931581.html,DC,RR Pant 17 | False,Batsman,https://www.espncricinfo.com/ci/content/player/325012.html,DC,MP Stoinis 18 | False,Batsman,https://www.espncricinfo.com/ci/content/player/670025.html,DC,SO Hetmyer 19 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/554691.html,DC,AR Patel 20 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/26421.html,DC,R Ashwin 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/550215.html,DC,K Rabada 22 | False,Bowler,https://www.espncricinfo.com/ci/content/player/481979.html,DC,A Nortje 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/390481.html,DC,HV Patel 24 | -------------------------------------------------------------------------------- /ipl20/teams/1216532_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,new_playername 2 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1070168.html,DC,PP Shaw 3 | False,Batsman,https://www.espncricinfo.com/ci/content/player/28235.html,DC,S Dhawan 4 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/931581.html,DC,RR Pant 5 | True,Batsman,https://www.espncricinfo.com/ci/content/player/642519.html,DC,SS Iyer 6 | False,Batsman,https://www.espncricinfo.com/ci/content/player/325012.html,DC,MP Stoinis 7 | False,Batsman,https://www.espncricinfo.com/ci/content/player/670025.html,DC,SO Hetmyer 8 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/554691.html,DC,AR Patel 9 | False,Bowler,https://www.espncricinfo.com/ci/content/player/31107.html,DC,A Mishra 10 | False,Bowler,https://www.espncricinfo.com/ci/content/player/550215.html,DC,K Rabada 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/481979.html,DC,Anrich Nortje 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/236779.html,DC,I Sharma 13 | True,Batsman,https://www.espncricinfo.com/ci/content/player/219889.html,SRH,DA Warner 14 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/297433.html,SRH,JM Bairstow 15 | False,Batsman,https://www.espncricinfo.com/ci/content/player/277906.html,SRH,KS Williamson 16 | False,Batsman,https://www.espncricinfo.com/ci/content/player/290630.html,SRH,MK Pandey 17 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1175485.html,SRH,Abdul Samad 18 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1070180.html,SRH,Priyam Garg 19 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1070183.html,SRH,Abhishek Sharma 20 | False,Bowler,https://www.espncricinfo.com/ci/content/player/793463.html,SRH,Rashid Khan 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/326016.html,SRH,P Kumar 22 | False,Bowler,https://www.espncricinfo.com/ci/content/player/802575.html,SRH,T Natarajan 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/942645.html,SRH,KK Ahmed 24 | -------------------------------------------------------------------------------- /ipl20/teams/1216538_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,playername 2 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/379143.html,MI,Q de Kock 3 | True,Batsman,https://www.espncricinfo.com/ci/content/player/34102.html,MI,RG Sharma 4 | False,Batsman,https://www.espncricinfo.com/ci/content/player/446507.html,MI,SA Yadav 5 | False,Batsman,https://www.espncricinfo.com/ci/content/player/720471.html,MI,Ishan Kishan 6 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/230559.html,MI,KA Pollard 7 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/625371.html,MI,HH Pandya 8 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/471342.html,MI,KH Pandya 9 | False,Bowler,https://www.espncricinfo.com/ci/content/player/272465.html,MI,James Pattinson 10 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1064812.html,MI,RD Chahar 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/277912.html,MI,TA Boult 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/625383.html,MI,JJ Bumrah 13 | True,Batsman,https://www.espncricinfo.com/ci/content/player/219889.html,SRH,DA Warner 14 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/297433.html,SRH,JM Bairstow 15 | False,Batsman,https://www.espncricinfo.com/ci/content/player/290630.html,SRH,MK Pandey 16 | False,Batsman,https://www.espncricinfo.com/ci/content/player/277906.html,SRH,KS Williamson 17 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1070180.html,SRH,P Garg 18 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1070183.html,SRH,Abhishek Sharma 19 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1175485.html,SRH,A Samad 20 | False,Bowler,https://www.espncricinfo.com/ci/content/player/793463.html,SRH,Rashid Khan 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/326017.html,SRH,S Kaul 22 | False,Bowler,https://www.espncricinfo.com/ci/content/player/802575.html,SRH,T Natarajan 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/438362.html,SRH,Sandeep Sharma 24 | -------------------------------------------------------------------------------- /ipl20/teams/1216547_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,new_playername 2 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1119026.html,RCB,Devdutt Padikkal 3 | False,Batsman,https://www.espncricinfo.com/ci/content/player/5334.html,RCB,AJ Finch 4 | True,Batsman,https://www.espncricinfo.com/ci/content/player/253802.html,RCB,V Kohli 5 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/44936.html,RCB,AB de Villiers 6 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/714451.html,RCB,S Dube 7 | False,Batsman,https://www.espncricinfo.com/ci/content/player/537124.html,RCB,Gurkeerat Singh 8 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/719715.html,RCB,Washington Sundar 9 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/328026.html,RCB,Isuru Udana 10 | False,Bowler,https://www.espncricinfo.com/ci/content/player/700167.html,RCB,NA Saini 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/430246.html,RCB,YS Chahal 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/379504.html,RCB,A Zampa 13 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/379143.html,MI,Q de Kock 14 | True,Batsman,https://www.espncricinfo.com/ci/content/player/34102.html,MI,RG Sharma 15 | False,Batsman,https://www.espncricinfo.com/ci/content/player/446507.html,MI,SA Yadav 16 | False,Batsman,https://www.espncricinfo.com/ci/content/player/720471.html,MI,Ishan Kishan 17 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/625371.html,MI,HH Pandya 18 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/230559.html,MI,KA Pollard 19 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/471342.html,MI,KH Pandya 20 | False,Bowler,https://www.espncricinfo.com/ci/content/player/272465.html,MI,James Pattinson 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1064812.html,MI,RD Chahar 22 | False,Bowler,https://www.espncricinfo.com/ci/content/player/277912.html,MI,TA Boult 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/625383.html,MI,JJ Bumrah 24 | -------------------------------------------------------------------------------- /ipl20/teams/1216542_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,playername 2 | True,Batsman,https://www.espncricinfo.com/ci/content/player/219889.html,SRH,DA Warner 3 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/297433.html,SRH,JM Bairstow 4 | False,Batsman,https://www.espncricinfo.com/ci/content/player/290630.html,SRH,MK Pandey 5 | False,Batsman,https://www.espncricinfo.com/ci/content/player/277906.html,SRH,KS Williamson 6 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1070180.html,SRH,P Garg 7 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1070183.html,SRH,Abhishek Sharma 8 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1175485.html,SRH,A Samad 9 | False,Bowler,https://www.espncricinfo.com/ci/content/player/793463.html,SRH,Rashid Khan 10 | False,Bowler,https://www.espncricinfo.com/ci/content/player/438362.html,SRH,Sandeep Sharma 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/942645.html,SRH,KK Ahmed 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/802575.html,SRH,T Natarajan 13 | True,Batsman,https://www.espncricinfo.com/ci/content/player/422108.html,KXIP,KL Rahul 14 | False,Batsman,https://www.espncricinfo.com/ci/content/player/398438.html,KXIP,MA Agarwal 15 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/398506.html,KXIP,Mandeep Singh 16 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/604302.html,KXIP,N Pooran 17 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/325026.html,KXIP,GJ Maxwell 18 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1161024.html,KXIP,P Simran Singh 19 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1175441.html,KXIP,R Bishnoi 20 | False,Bowler,https://www.espncricinfo.com/ci/content/player/481896.html,KXIP,Mohammed Shami 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/495551.html,KXIP,Sheldon Cottrell 22 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1125976.html,KXIP,Arshdeep Singh 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/974109.html,KXIP,Mujeeb Ur Rahman 24 | -------------------------------------------------------------------------------- /ipl20/teams/1216496_squad.csv: -------------------------------------------------------------------------------- 1 | playername,iscaptain,position,profilelink,teamname 2 | Yashasvi Jaiswal,False,Batsman,https://www.espncricinfo.com/ci/content/player/1151278.html,RR 3 | Steven Smith,True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR 4 | Sanju Samson,False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/425943.html,RR 5 | David Miller,False,Batsman,https://www.espncricinfo.com/ci/content/player/321777.html,RR 6 | Robin Uthappa,False,Batsman,https://www.espncricinfo.com/ci/content/player/35582.html,RR 7 | Rahul Tewatia,False,Bowler,https://www.espncricinfo.com/ci/content/player/423838.html,RR 8 | Riyan Parag,False,Batsman,https://www.espncricinfo.com/ci/content/player/1079434.html,RR 9 | Tom Curran,False,Allrounder,https://www.espncricinfo.com/ci/content/player/550235.html,RR 10 | Jofra Archer,False,Bowler,https://www.espncricinfo.com/ci/content/player/669855.html,RR 11 | Shreyas Gopal,False,Allrounder,https://www.espncricinfo.com/ci/content/player/344580.html,RR 12 | Jaydev Unadkat,False,Bowler,https://www.espncricinfo.com/ci/content/player/390484.html,RR 13 | Murali Vijay,False,Batsman,https://www.espncricinfo.com/ci/content/player/237095.html,CSK 14 | Shane Watson,False,Allrounder,https://www.espncricinfo.com/ci/content/player/8180.html,CSK 15 | Faf du Plessis,False,Batsman,https://www.espncricinfo.com/ci/content/player/44828.html,CSK 16 | Sam Curran,False,Allrounder,https://www.espncricinfo.com/ci/content/player/662973.html,CSK 17 | Ruturaj Gaikwad,False,Batsman,https://www.espncricinfo.com/ci/content/player/1060380.html,CSK 18 | Kedar Jadhav,False,Allrounder,https://www.espncricinfo.com/ci/content/player/290716.html,CSK 19 | MS Dhoni,True,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/28081.html,CSK 20 | Ravindra Jadeja,False,Allrounder,https://www.espncricinfo.com/ci/content/player/234675.html,CSK 21 | Piyush Chawla,False,Allrounder,https://www.espncricinfo.com/ci/content/player/32966.html,CSK 22 | Deepak Chahar,False,Bowler,https://www.espncricinfo.com/ci/content/player/447261.html,CSK 23 | Lungi Ngidi,False,Bowler,https://www.espncricinfo.com/ci/content/player/542023.html,CSK 24 | -------------------------------------------------------------------------------- /ipl20/teams/1216514_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,playername 2 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1119026.html,RCB,Devdutt Padikkal 3 | False,Batsman,https://www.espncricinfo.com/ci/content/player/5334.html,RCB,AJ Finch 4 | True,Batsman,https://www.espncricinfo.com/ci/content/player/253802.html,RCB,V Kohli 5 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/44936.html,RCB,AB de Villiers 6 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/714451.html,RCB,S Dube 7 | False,Batsman,https://www.espncricinfo.com/ci/content/player/537124.html,RCB,G Singh 8 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/719715.html,RCB,Washington Sundar 9 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/328026.html,RCB,I Udana 10 | False,Bowler,https://www.espncricinfo.com/ci/content/player/700167.html,RCB,NA Saini 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/430246.html,RCB,YS Chahal 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/379504.html,RCB,A Zampa 13 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/308967.html,RR,JC Buttler 14 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 15 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 16 | False,Batsman,https://www.espncricinfo.com/ci/content/player/425943.html,RR,SV Samson 17 | False,Batsman,https://www.espncricinfo.com/ci/content/player/35582.html,RR,RV Uthappa 18 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1079434.html,RR,R Parag 19 | False,Bowler,https://www.espncricinfo.com/ci/content/player/423838.html,RR,KL Rahul 20 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/853265.html,RR,MK Lomror 21 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/550235.html,RR,TK Curran 22 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/344580.html,RR,S Gopal 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/669855.html,RR,JC Archer 24 | False,Bowler,https://www.espncricinfo.com/ci/content/player/390484.html,RR,JD Unadkat 25 | -------------------------------------------------------------------------------- /ipl20/teams/1216510_squad.csv: -------------------------------------------------------------------------------- 1 | playername,iscaptain,position,profilelink,teamname 2 | KL Rahul,True,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/422108.html,KXIP 3 | Mayank Agarwal,False,Batsman,https://www.espncricinfo.com/ci/content/player/398438.html,KXIP 4 | Nicholas Pooran,False,Batsman,https://www.espncricinfo.com/ci/content/player/604302.html,KXIP 5 | Glenn Maxwell,False,Allrounder,https://www.espncricinfo.com/ci/content/player/325026.html,KXIP 6 | Karun Nair,False,Batsman,https://www.espncricinfo.com/ci/content/player/398439.html,KXIP 7 | James Neesham,False,Allrounder,https://www.espncricinfo.com/ci/content/player/355269.html,KXIP 8 | Sarfaraz Khan,False,Batsman,https://www.espncricinfo.com/ci/content/player/642525.html,KXIP 9 | Mohammed Shami,False,Bowler,https://www.espncricinfo.com/ci/content/player/481896.html,KXIP 10 | Sheldon Cottrell,False,Bowler,https://www.espncricinfo.com/ci/content/player/495551.html,KXIP 11 | Ravi Bishnoi,False,Bowler,https://www.espncricinfo.com/ci/content/player/1175441.html,KXIP 12 | Murugan Ashwin,False,Bowler,https://www.espncricinfo.com/ci/content/player/528067.html,KXIP 13 | Devdutt Padikkal,False,Batsman,https://www.espncricinfo.com/ci/content/player/1119026.html,RCB 14 | Aaron Finch,False,Batsman,https://www.espncricinfo.com/ci/content/player/5334.html,RCB 15 | Josh Philippe,False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/1124282.html,RCB 16 | Virat Kohli,True,Batsman,https://www.espncricinfo.com/ci/content/player/253802.html,RCB 17 | AB de Villiers,False,Batsman,https://www.espncricinfo.com/ci/content/player/44936.html,RCB 18 | Washington Sundar,False,Allrounder,https://www.espncricinfo.com/ci/content/player/719715.html,RCB 19 | Shivam Dube,False,Allrounder,https://www.espncricinfo.com/ci/content/player/714451.html,RCB 20 | Umesh Yadav,False,Bowler,https://www.espncricinfo.com/ci/content/player/376116.html,RCB 21 | Navdeep Saini,False,Bowler,https://www.espncricinfo.com/ci/content/player/700167.html,RCB 22 | Dale Steyn,False,Bowler,https://www.espncricinfo.com/ci/content/player/47492.html,RCB 23 | Yuzvendra Chahal,False,Bowler,https://www.espncricinfo.com/ci/content/player/430246.html,RCB 24 | -------------------------------------------------------------------------------- /ipl20/teams/1216527_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,new_playername 2 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 3 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 4 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/308967.html,RR,JC Buttler 5 | False,Batsman,https://www.espncricinfo.com/ci/content/player/425943.html,RR,SV Samson 6 | False,Batsman,https://www.espncricinfo.com/ci/content/player/35582.html,RR,RV Uthappa 7 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1079434.html,RR,R Parag 8 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/550235.html,RR,TK Curran 9 | False,Bowler,https://www.espncricinfo.com/ci/content/player/423838.html,RR,KL Rahul 10 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/344580.html,RR,S Gopal 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/669855.html,RR,JC Archer 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/591650.html,RR,AS Rajpoot 13 | False,Bowler,https://www.espncricinfo.com/ci/content/player/390484.html,RR,JD Unadkat 14 | True,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/422108.html,KXIP,KL Rahul 15 | False,Batsman,https://www.espncricinfo.com/ci/content/player/398438.html,KXIP,MA Agarwal 16 | False,Batsman,https://www.espncricinfo.com/ci/content/player/604302.html,KXIP,N Pooran 17 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/325026.html,KXIP,GJ Maxwell 18 | False,Batsman,https://www.espncricinfo.com/ci/content/player/398439.html,KXIP,KK Nair 19 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/355269.html,KXIP,JDS Neesham 20 | False,Batsman,https://www.espncricinfo.com/ci/content/player/642525.html,KXIP,SN Khan 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/481896.html,KXIP,Mohammed Shami 22 | False,Bowler,https://www.espncricinfo.com/ci/content/player/495551.html,KXIP,Sheldon Cottrell 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1175441.html,KXIP,R Bishnoi 24 | False,Bowler,https://www.espncricinfo.com/ci/content/player/528067.html,KXIP,M Ashwin 25 | -------------------------------------------------------------------------------- /ipl20/teams/1216511_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,playername 2 | True,Batsman,https://www.espncricinfo.com/ci/content/player/34102.html,MI,RG Sharma 3 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/379143.html,MI,Q de Kock 4 | False,Batsman,https://www.espncricinfo.com/ci/content/player/446507.html,MI,SA Yadav 5 | False,Batsman,https://www.espncricinfo.com/ci/content/player/720471.html,MI,Ishan Kishan 6 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/625371.html,MI,HH Pandya 7 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/230559.html,MI,KA Pollard 8 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/471342.html,MI,KH Pandya 9 | False,Bowler,https://www.espncricinfo.com/ci/content/player/272465.html,MI,James Pattinson 10 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1064812.html,MI,RD Chahar 11 | False,Bowler,https://www.espncricinfo.com/ci/content/player/277912.html,MI,TA Boult 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/625383.html,MI,JJ Bumrah 13 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/308967.html,RR,JC Buttler 14 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 15 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 16 | False,Batsman,https://www.espncricinfo.com/ci/content/player/425943.html,RR,SV Samson 17 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1151278.html,RR,Yashasvi Jaiswal 18 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1151278.html,RR,Y Jaiswal 19 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/853265.html,RR,MK Lomror 20 | False,Bowler,https://www.espncricinfo.com/ci/content/player/423838.html,RR,KL Rahul 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/669855.html,RR,JC Archer 22 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/550235.html,RR,TK Curran 23 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/344580.html,RR,S Gopal 24 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1122918.html,RR,K Tyagi 25 | False,Bowler,https://www.espncricinfo.com/ci/content/player/591650.html,RR,AS Rajpoot 26 | -------------------------------------------------------------------------------- /ipl20/teams/1216504_squad.csv: -------------------------------------------------------------------------------- 1 | iscaptain,position,profilelink,teamname,new_playername 2 | False,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/308967.html,RR,JC Buttler 3 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 4 | True,Batsman,https://www.espncricinfo.com/ci/content/player/267192.html,RR,SPD Smith 5 | False,Batsman,https://www.espncricinfo.com/ci/content/player/425943.html,RR,SV Samson 6 | False,Bowler,https://www.espncricinfo.com/ci/content/player/423838.html,RR,KL Rahul 7 | False,Batsman,https://www.espncricinfo.com/ci/content/player/35582.html,RR,RV Uthappa 8 | False,Bowler,https://www.espncricinfo.com/ci/content/player/669855.html,RR,JC Archer 9 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1079434.html,RR,R Parag 10 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/550235.html,RR,TK Curran 11 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/344580.html,RR,S Gopal 12 | False,Bowler,https://www.espncricinfo.com/ci/content/player/591650.html,RR,AS Rajpoot 13 | False,Bowler,https://www.espncricinfo.com/ci/content/player/390484.html,RR,JD Unadkat 14 | False,Batsman,https://www.espncricinfo.com/ci/content/player/1070173.html,KKR,Shubman Gill 15 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/230558.html,KKR,SP Narine 16 | False,Batsman,https://www.espncricinfo.com/ci/content/player/604527.html,KKR,N Rana 17 | True,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/30045.html,KKR,KD Karthik 18 | True,Wicketkeeper,https://www.espncricinfo.com/ci/content/player/30045.html,KKR,KD Kartik 19 | False,Batsman,https://www.espncricinfo.com/ci/content/player/24598.html,KKR,EJG Morgan 20 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/276298.html,KKR,AD Russell 21 | False,Bowler,https://www.espncricinfo.com/ci/content/player/489889.html,KKR,PJ Cummins 22 | False,Allrounder,https://www.espncricinfo.com/ci/content/player/1079848.html,KKR,Shivam Mavi 23 | False,Bowler,https://www.espncricinfo.com/ci/content/player/559235.html,KKR,Kuldeep Yadav 24 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1070188.html,KKR,Kamlesh Nagarkoti 25 | False,Bowler,https://www.espncricinfo.com/ci/content/player/1108375.html,KKR,Varun Chakravarthy 26 | -------------------------------------------------------------------------------- /pred_team11_details.csv: -------------------------------------------------------------------------------- 1 | matchid,playername,playing_role,playing_team,playercost,pred_points_catboost,pred_selection_true_catboost,pred_points_xgb,pred_selection_true_xgb,pred_points_rf,pred_selection_true_rf,pred_points_movingaverage,pred_selection_true_movingaverage,pred_points_ensemble,pred_selection_true_ensemble 2 | 1254114,DJ Bravo,AllRounder,Chennai Super Kings,10.0,38.22570960333232,1.0,41.17308,1.0,38.8306600452633,1.0,78.66666666666667,1.0,42.6837602395923,1.0 3 | 1254114,AR Patel,AllRounder,Delhi Capitals,8.5,38.155758062273264,1.0,39.44792,1.0,39.39918896874193,1.0,60.66666666666666,1.0,40.36677963608344,1.0 4 | 1254114,SS Iyer,Batsmen,Delhi Capitals,9.0,37.43565126940934,1.0,37.40035,1.0,35.74786705954869,1.0,48.0,1.0,34.69888358574043,1.0 5 | 1254114,F du Plessis,Batsmen,Chennai Super Kings,9.0,37.07216863175287,1.0,36.958405,1.0,35.28396263243718,1.0,29.0,1.0,34.723470824808615,1.0 6 | 1254114,RA Jadeja,AllRounder,Chennai Super Kings,8.5,35.73880147964806,1.0,37.993675,1.0,36.54055404403872,1.0,28.0,1.0,40.626923660987046,1.0 7 | 1254114,S Dhawan,Batsmen,Delhi Capitals,10.0,35.491344605693044,1.0,36.461975,1.0,34.396058808315615,1.0,23.0,,36.19117891567467,1.0 8 | 1254114,AT Rayudu,Batsmen,Chennai Super Kings,9.0,33.548205520397865,1.0,31.203854,,32.45889048600799,1.0,17.0,,27.56755415416614, 9 | 1254114,RR Pant,Batsmen,Delhi Capitals,9.5,33.20388486655509,1.0,31.358278,,31.599914898726706,1.0,34.0,1.0,27.214743665728008, 10 | 1254114,SN Thakur,Bowler,Chennai Super Kings,8.5,30.88664478629701,1.0,31.73775,1.0,29.92436506913642,1.0,47.0,1.0,30.584916797478343,1.0 11 | 1254114,K Rabada,Bowler,Delhi Capitals,9.5,29.668216557304287,1.0,29.445211,1.0,30.071079876692657,1.0,32.666666666666664,1.0,28.833253934634865, 12 | 1254114,DL Chahar,Bowler,Chennai Super Kings,8.5,29.28993550060994,1.0,28.613977,1.0,29.551294189697355,1.0,26.666666666666668,1.0,27.589371653344315, 13 | 1254114,PP Shaw,Batsmen,Delhi Capitals,8.5,32.559824427241885,,31.917479,1.0,31.339040079359723,,10.0,,30.21138509061868,1.0 14 | 1254114,MP Stoinis,AllRounder,Delhi Capitals,8.5,31.87814036065698,,26.399502,,30.169517026523057,,11.333333333333334,,19.02453228128526, 15 | 1254114,MS Dhoni,Batsmen,Chennai Super Kings,9.5,30.826473083635392,,33.0713,1.0,30.769898656263457,,6.0,,35.61124774708015,1.0 16 | 1254114,SO Hetmyer,Batsmen,Delhi Capitals,8.5,28.70647089088797,,28.927618,,29.414702631851952,,18.33333333333333,,29.53852424462034, 17 | 1254114,A Nortje,Bowler,Delhi Capitals,8.0,27.21395022870934,,28.406898,,28.864829642158774,,48.333333333333336,1.0,29.86374719427861,1.0 18 | 1254114,R Ashwin,Bowler,Delhi Capitals,9.0,26.615883518573888,,27.533657,,28.47718189116138,,26.666666666666668,1.0,29.611726545156223,1.0 19 | -------------------------------------------------------------------------------- /Data/pred_team11_details.csv: -------------------------------------------------------------------------------- 1 | matchid,playername,playing_role,playing_team,playercost,pred_points_catboost,pred_selection_true_catboost,pred_points_xgb,pred_selection_true_xgb,pred_points_rf,pred_selection_true_rf,pred_points_movingaverage,pred_selection_true_movingaverage,pred_points_ensemble,pred_selection_true_ensemble 2 | 1216548,DA Warner,Batsmen,Sunrisers Hyderabad,10.5,48.21437889416642,1.0,63.809419999999996,1.0,44.59477083962648,1.0,45.33333333333334,1.0,76.34642643629067,1.0 3 | 1216548,KL Rahul,Batsmen,Kings XI Punjab,10.5,46.01671574664236,1.0,61.44791,1.0,44.466081448221566,1.0,84.33333333333333,1.0,74.30692069247574,1.0 4 | 1216548,MA Agarwal,Batsmen,Kings XI Punjab,8.5,45.48176251929056,1.0,54.91636999999999,1.0,41.65846877162033,1.0,88.0,1.0,59.191562001828295,1.0 5 | 1216548,MK Pandey,Batsmen,Sunrisers Hyderabad,9.0,43.2492687997729,1.0,57.77381,1.0,42.124830315103964,1.0,63.66666666666666,1.0,70.70924589418672,1.0 6 | 1216548,JM Bairstow,Batsmen,Sunrisers Hyderabad,9.5,41.352511965227706,1.0,57.858757,1.0,40.87159037860011,1.0,74.0,1.0,73.11668610619981,1.0 7 | 1216548,A Samad,AllRounder,Sunrisers Hyderabad,8.0,32.871026942481826,1.0,30.414505,1.0,33.4893918476049,1.0,14.0,1.0,28.27748503581613,1.0 8 | 1216548,N Pooran,Batsmen,Kings XI Punjab,9.0,31.82799956894195,1.0,35.15055,1.0,32.97110504268834,1.0,36.66666666666666,1.0,38.88852414565372,1.0 9 | 1216548,KS Williamson,Batsmen,Sunrisers Hyderabad,9.5,31.671530422220243,1.0,34.69106,1.0,34.701478358999005,1.0,18.0,,40.42241000316694,1.0 10 | 1216548,Sandeep Sharma,Bowler,Sunrisers Hyderabad,8.0,30.033641331463727,1.0,29.956144000000002,1.0,34.584369520578704,1.0,19.33333333333333,1.0,33.664122801198644,1.0 11 | 1216548,KK Ahmed,Bowler,Sunrisers Hyderabad,8.0,30.03196526087504,1.0,33.318775,1.0,33.790194052275,1.0,-2.0,,40.645295137732454,1.0 12 | 1216548,Rashid Khan,Bowler,Sunrisers Hyderabad,9.5,29.558583581708163,1.0,26.560548999999998,,34.103818515734126,1.0,7.666666666666668,1.0,27.52610024899651, 13 | 1216548,GJ Maxwell,AllRounder,Kings XI Punjab,9.0,30.076172446045703,,24.522947,,29.429388515029736,,10.0,,18.039509150675322, 14 | 1216548,Mandeep Singh,Batsmen,Kings XI Punjab,8.0,27.33719421207601,,22.493813,,29.737933996931233,,23.33333333333333,1.0,19.006840330732814, 15 | 1216548,Mohammed Shami,Bowler,Kings XI Punjab,8.5,27.325549857635426,,27.509271999999996,1.0,32.1080668825389,,-4.0,,32.46183172566697,1.0 16 | 1216548,T Natarajan,Bowler,Sunrisers Hyderabad,8.0,26.429848558382744,,21.963836999999998,,31.08192445204936,,-0.6666666666666666,,21.696111215336465, 17 | 1216548,Arshdeep Singh,Bowler,Kings XI Punjab,7.5,26.068131710102957,,25.962729,,29.972509478137376,,22.33333333333333,1.0,28.91115523256098, 18 | 1216548,Abhishek Sharma,Batsmen,Sunrisers Hyderabad,8.0,25.413850898249002,,27.44179,,30.052768651737786,,7.0,,33.84335399341741, 19 | -------------------------------------------------------------------------------- /Data/model_prediction.csv: -------------------------------------------------------------------------------- 1 | matchid,playername,playing_role,playing_team,playercost,pred_points_catboost,pred_selection_true_catboost,pred_points_xgb,pred_selection_true_xgb,pred_points_rf,pred_selection_true_rf,pred_points_movingaverage,pred_selection_true_movingaverage,pred_points 2 | 1254085,JM Bairstow,Batsmen,Sunrisers Hyderabad,10.0,44.59029249077157,1.0,44.10883,1.0,38.60200788690406,1.0,46.333333333333336,1.0,37.2333963513779 3 | 1254085,CH Morris,AllRounder,Rajasthan Royals,9.5,42.46771963152697,1.0,42.68778,1.0,44.48376551222367,1.0,55.0,1.0,43.395975515550084 4 | 1254085,SV Samson,Batsmen,Rajasthan Royals,9.5,36.56872998325678,1.0,35.48869,1.0,34.94107617057948,1.0,45.333333333333336,1.0,31.801726754957535 5 | 1254085,R Parag,AllRounder,Rajasthan Royals,8.5,36.14987273059528,1.0,32.088078,,32.342660417193684,,10.0,,24.45419150595282 6 | 1254085,R Tewatia,AllRounder,Rajasthan Royals,9.0,36.066068299368,1.0,34.212685,1.0,35.07084618654594,1.0,15.333333333333334,,31.274681700070005 7 | 1254085,V Shankar,AllRounder,Sunrisers Hyderabad,8.5,35.60468323419973,1.0,34.305264,1.0,34.53284372612644,1.0,31.33333333333333,1.0,31.343090939497685 8 | 1254085,JC Buttler,Batsmen,Rajasthan Royals,9.5,34.52153869212547,1.0,32.354656,,32.5243320682484,,23.33333333333333,1.0,27.894377366469215 9 | 1254085,MK Pandey,Batsmen,Sunrisers Hyderabad,9.0,34.2080294112007,1.0,33.94242,1.0,35.048366086759735,1.0,42.333333333333336,1.0,33.40517267517825 10 | 1254085,Rashid Khan,Bowler,Sunrisers Hyderabad,9.5,31.22739672279092,1.0,30.744541,1.0,31.858849185819945,1.0,41.66666666666666,1.0,29.77286754092382 11 | 1254085,K Tyagi,Bowler,Rajasthan Royals,8.0,29.58940378293705,1.0,26.853962,1.0,29.30608873779428,1.0,12.666666666666666,1.0,23.616141438759133 12 | 1254085,C Sakariya,Bowler,Rajasthan Royals,8.5,27.9860807581096,1.0,26.405876,,27.852558380833653,1.0,,, 13 | 1254085,A Samad,AllRounder,Sunrisers Hyderabad,8.0,34.7380180898257,,30.544098,,30.47438585270304,,9.666666666666666,,22.354263221509143 14 | 1254085,KM Jadhav,AllRounder,Sunrisers Hyderabad,8.0,34.47185413872308,,33.692673,1.0,32.53396746828265,1.0,31.33333333333333,1.0,30.499280388737454 15 | 1254085,KS Williamson,Batsmen,Sunrisers Hyderabad,9.0,34.09210482996714,,33.831585,1.0,34.69030393151542,1.0,45.0,1.0,32.991410478644326 16 | 1254085,DA Miller,Batsmen,Rajasthan Royals,9.0,33.55457223608963,,31.953878,,32.300226247979964,,11.666666666666666,,29.147552269556854 17 | 1254085,M Rahman,Bowler,Rajasthan Royals,8.5,27.9860807581096,,26.405876,,27.852558380833653,,,, 18 | 1254085,KK Ahmed,Bowler,Sunrisers Hyderabad,8.0,27.876752599269352,,27.491467,1.0,27.689420488113736,,23.666666666666668,1.0,26.461075983280807 19 | 1254085,Yashasvi Jaiswal,Batsmen,Rajasthan Royals,8.0,27.871003651020327,,27.077662,,28.474111149327683,,21.0,,26.407150563409356 20 | 1254085,Sandeep Sharma,Bowler,Sunrisers Hyderabad,8.5,25.769085504663074,,23.17734,,27.23048212593263,,7.0,,21.796613777757724 21 | -------------------------------------------------------------------------------- /send_email.py: -------------------------------------------------------------------------------- 1 | import smtplib, ssl 2 | from email.mime.text import MIMEText 3 | from email.mime.base import MIMEBase 4 | from email.mime.multipart import MIMEMultipart 5 | from email import encoders 6 | import pandas as pd 7 | import csv 8 | from datetime import date 9 | def send_email_team(team1, team2, filepath,sender_email,receiver_email): 10 | smtp_server = "smtp.gmail.com" 11 | port = 587 # For starttls 12 | password = input("Type your password and press enter: ") 13 | # Read the attachment as pandas 14 | tabledf = pd.read_csv(filepath) 15 | tablehtml = tabledf.to_html() 16 | # Create the plain-text and HTML version of your message 17 | text =f"""\ 18 | Hi, 19 | 20 | Please find attached the expected best team for Dream11 IPL match between {team1} and {team2} 21 | 22 | {tabledf} 23 | 24 | Cheers!!! 25 | """ 26 | 27 | html = """ 28 |
Hi!
29 |Please find below the expected best team for Dream11 IPL match between {team1} and {team2}:
30 | 31 | {table} 32 | 33 |Cheers!,
34 |Abhishek
35 | 36 | """ 37 | 38 | with open(filepath) as input_file: 39 | reader = csv.reader(input_file) 40 | data = list(reader) 41 | 42 | html = html.format(table=tablehtml, team1=team1, team2=team2) 43 | message = MIMEMultipart( 44 | "alternative", None, [ MIMEText(html, 'html')]) 45 | #MIMEText(text), 46 | todays_date = date.today().strftime("%b-%d-%Y") 47 | message["Subject"] = f"Dream11 Team of the Day: {todays_date}" 48 | message["From"] = sender_email 49 | message["To"] = sender_email 50 | message["BCC"] = receiver_email 51 | 52 | filename = filepath # In same directory as script 53 | 54 | # Open PDF file in binary mode 55 | with open(filename, "rb") as attachment: 56 | # Add file as application/octet-stream 57 | # Email client can usually download this automatically as attachment 58 | part = MIMEBase("application", "octet-stream") 59 | part.set_payload((attachment).read()) 60 | 61 | # Encode file in ASCII characters to send by email 62 | encoders.encode_base64(part) 63 | 64 | # Add header as key/value pair to attachment part 65 | part.add_header('Content-Disposition', "attachment; filename= %s" % filename) 66 | 67 | # attach the instance 'p' to instance 'msg' 68 | message.attach(part) 69 | 70 | # Create a secure SSL context 71 | context = ssl.create_default_context() 72 | 73 | # Try to log in to server and send email 74 | try: 75 | server = smtplib.SMTP(smtp_server, port) 76 | server.ehlo() # Can be omitted 77 | server.starttls(context=context) # Secure the connection 78 | server.ehlo() # Can be omitted 79 | server.login(sender_email, password) 80 | server.sendmail( 81 | sender_email, receiver_email, message.as_string() 82 | ) 83 | except Exception as e: 84 | # Print any error messages to stdout 85 | print(e) 86 | finally: 87 | server.quit() 88 | 89 | -------------------------------------------------------------------------------- /parse_teams.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from lxml import html 3 | import json 4 | import pandas as pd 5 | import os 6 | from bs4 import BeautifulSoup 7 | import re 8 | 9 | 10 | headers = { 11 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36', 12 | "Upgrade-Insecure-Requests": "1", "DNT": "1", 13 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", 14 | "Accept-Encoding": "gzip, deflate"} 15 | 16 | 17 | eventid_int=range(1216492,1216530) 18 | 19 | MI_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 20 | CSK_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 21 | RR_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 22 | DC_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 23 | SRH_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 24 | RCB_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 25 | KXIP_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 26 | KKR_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 27 | 28 | 29 | for eventid in eventid_int : 30 | 31 | URL= "https://hsapi.espncricinfo.com/v1/pages/match/home?lang=en&leagueId=8048&eventId="+str(eventid)+"&liveTest=false&qaTest=false" 32 | response = requests.get(URL, headers=headers) 33 | data = json.loads(response.text) 34 | 35 | for team in data['content']['squads']: 36 | for playerlist in team['players']: 37 | dict ={} 38 | playername = playerlist['name'] 39 | iscaptain = playerlist['isCaptain'] 40 | position = playerlist['position'] 41 | profilelink = playerlist['link']['href'] 42 | teamname = team['teamName'] 43 | dict = {'playername':playername, 'iscaptain': iscaptain, 'position': position, 'profilelink': profilelink,'teamname':teamname} 44 | if team['teamName'] == 'MI': 45 | MI_squad = MI_squad.append(dict,ignore_index= True) 46 | elif team['teamName'] == 'CSK': 47 | CSK_squad = CSK_squad.append(dict,ignore_index = True) 48 | elif team['teamName'] == 'RR': 49 | RR_squad = RR_squad.append(dict,ignore_index = True) 50 | elif team['teamName'] == 'DC': 51 | DC_squad = DC_squad.append(dict,ignore_index = True) 52 | elif team['teamName'] == 'SRH': 53 | SRH_squad = SRH_squad.append(dict,ignore_index = True) 54 | elif team['teamName'] == 'RCB': 55 | RCB_squad = RCB_squad.append(dict,ignore_index = True) 56 | elif team['teamName'] == 'KXIP': 57 | KXIP_squad = KXIP_squad.append(dict,ignore_index = True) 58 | elif team['teamName'] == 'KKR': 59 | KKR_squad = KKR_squad.append(dict,ignore_index = True) 60 | 61 | 62 | 63 | MI_squad.drop_duplicates(subset=None, keep='first', inplace=True) 64 | CSK_squad.drop_duplicates(subset=None, keep='first', inplace=True) 65 | RR_squad.drop_duplicates(subset=None, keep='first', inplace=True) 66 | DC_squad.drop_duplicates(subset=None, keep='first', inplace=True) 67 | SRH_squad.drop_duplicates(subset=None, keep='first', inplace=True) 68 | RCB_squad.drop_duplicates(subset=None, keep='first', inplace=True) 69 | KXIP_squad.drop_duplicates(subset=None, keep='first', inplace=True) 70 | KKR_squad.drop_duplicates(subset=None, keep='first', inplace=True) 71 | 72 | directory='~/Documents/GitHub/dream11/ipl20/' 73 | MI_squad.to_csv(directory+'teams/MI_squad.csv',index = False) 74 | CSK_squad.to_csv(directory+'teams/CSK_squad.csv', index=False) 75 | RR_squad.to_csv(directory+'teams/RR_squad.csv', index=False) 76 | DC_squad.to_csv(directory+'teams/DC_squad.csv', index=False) 77 | SRH_squad.to_csv(directory+'teams/SRH_squad.csv', index=False) 78 | RCB_squad.to_csv(directory+'teams/RCB_squad.csv', index=False) 79 | KXIP_squad.to_csv(directory+'teams/KXIP_squad.csv', index=False) 80 | KKR_squad.to_csv(directory+'teams/KKR_squad.csv', index=False) 81 | -------------------------------------------------------------------------------- /ipl20/1216514.csv: -------------------------------------------------------------------------------- 1 | ipl_season,sequence,eventid,innings,target,remainingballs,homescore,awayscore,fallofwickets,ball,over,scorevalue,validball,extras,dismissal,dismissaltype,batsmanid,batsman,batsmanteam,bowlerid,bowler,bowlerteam,otherathleteinvolvedid,otherathleteinvolved,nonstrikerid,nonstriker,runs,runrate 2 | ipl20,100001,1216514,1st innings,0,119,0/0,0,0,1,0.1,0,0,0,False,,308967,Jos Buttler,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,267192,Steven Smith,0,0.0 3 | ipl20,100002,1216514,1st innings,0,118,4/0,0,0,2,0.2,4,0,0,False,,308967,Jos Buttler,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,267192,Steven Smith,4,12.0 4 | ipl20,100003,1216514,1st innings,0,117,5/0,0,0,3,0.3,1,0,0,False,,308967,Jos Buttler,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,267192,Steven Smith,1,10.0 5 | ipl20,100004,1216514,1st innings,0,116,5/0,0,0,4,0.4,0,0,0,False,,267192,Steven Smith,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,308967,Jos Buttler,0,7.5 6 | ipl20,100005,1216514,1st innings,0,115,5/0,0,0,5,0.5,0,0,0,False,,267192,Steven Smith,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,308967,Jos Buttler,0,6.0 7 | ipl20,100006,1216514,1st innings,0,114,9/0,0,0,6,0.6,4,0,0,False,,267192,Steven Smith,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,308967,Jos Buttler,4,9.0 8 | ipl20,100101,1216514,1st innings,0,113,9/0,0,0,7,1.1,0,0,0,False,,308967,Jos Buttler,Rajasthan Royals,719715,Washington Sundar,Royal Challengers Bangalore,,,267192,Steven Smith,0,7.71 9 | ipl20,100102,1216514,1st innings,0,112,13/0,0,0,8,1.2,4,0,0,False,,308967,Jos Buttler,Rajasthan Royals,719715,Washington Sundar,Royal Challengers Bangalore,,,267192,Steven Smith,4,9.75 10 | ipl20,100103,1216514,1st innings,0,111,14/0,0,0,9,1.3,1,0,0,False,,308967,Jos Buttler,Rajasthan Royals,719715,Washington Sundar,Royal Challengers Bangalore,,,267192,Steven Smith,1,9.33 11 | ipl20,100104,1216514,1st innings,0,110,15/0,0,0,10,1.4,1,0,0,False,,267192,Steven Smith,Rajasthan Royals,719715,Washington Sundar,Royal Challengers Bangalore,,,308967,Jos Buttler,1,9.0 12 | ipl20,100105,1216514,1st innings,0,109,15/0,0,0,11,1.5,0,0,0,False,,308967,Jos Buttler,Rajasthan Royals,719715,Washington Sundar,Royal Challengers Bangalore,,,267192,Steven Smith,0,8.18 13 | ipl20,100106,1216514,1st innings,0,108,16/0,0,0,12,1.6,1,0,0,False,,308967,Jos Buttler,Rajasthan Royals,719715,Washington Sundar,Royal Challengers Bangalore,,,267192,Steven Smith,1,8.0 14 | ipl20,100201,1216514,1st innings,0,107,22/0,0,0,13,2.1,6,0,0,False,,308967,Jos Buttler,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,267192,Steven Smith,6,10.15 15 | ipl20,100202,1216514,1st innings,0,106,26/0,0,0,14,2.2,4,0,0,False,,308967,Jos Buttler,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,267192,Steven Smith,4,11.14 16 | ipl20,100203,1216514,1st innings,0,105,27/0,0,0,15,2.3,1,0,0,False,,308967,Jos Buttler,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,267192,Steven Smith,1,10.8 17 | ipl20,100204,1216514,1st innings,0,104,27/1,0,1,16,2.4,0,0,0,True,bowled,267192,Steven Smith,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,267192,Steven Smith,308967,Jos Buttler,0,10.12 18 | ipl20,100205,1216514,1st innings,0,103,31/1,0,0,17,2.5,4,0,0,False,,425943,Sanju Samson,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,308967,Jos Buttler,4,10.94 19 | ipl20,100206,1216514,1st innings,0,102,31/1,0,0,18,2.6,0,0,0,False,,425943,Sanju Samson,Rajasthan Royals,328026,Isuru Udana,Royal Challengers Bangalore,,,308967,Jos Buttler,0,10.33 20 | ipl20,100301,1216514,1st innings,0,101,31/2,0,2,19,3.1,0,0,0,True,caught,308967,Jos Buttler,Rajasthan Royals,700167,Navdeep Saini,Royal Challengers Bangalore,308967,Jos Buttler,425943,Sanju Samson,0,9.78 21 | ipl20,100302,1216514,1st innings,0,100,31/2,0,0,20,3.2,0,0,0,False,,35582,Robin Uthappa,Rajasthan Royals,700167,Navdeep Saini,Royal Challengers Bangalore,,,425943,Sanju Samson,0,9.3 22 | ipl20,100303,1216514,1st innings,0,99,31/2,0,0,21,3.3,0,0,0,False,,35582,Robin Uthappa,Rajasthan Royals,700167,Navdeep Saini,Royal Challengers Bangalore,,,425943,Sanju Samson,0,8.85 23 | ipl20,100304,1216514,1st innings,0,98,31/2,0,0,22,3.4,0,0,0,False,,35582,Robin Uthappa,Rajasthan Royals,700167,Navdeep Saini,Royal Challengers Bangalore,,,425943,Sanju Samson,0,8.45 24 | ipl20,100305,1216514,1st innings,0,97,31/2,0,0,23,3.5,0,0,0,False,,35582,Robin Uthappa,Rajasthan Royals,700167,Navdeep Saini,Royal Challengers Bangalore,,,425943,Sanju Samson,0,8.08 25 | ipl20,100306,1216514,1st innings,0,96,31/2,0,0,24,3.6,0,0,0,False,,35582,Robin Uthappa,Rajasthan Royals,700167,Navdeep Saini,Royal Challengers Bangalore,,,425943,Sanju Samson,0,7.75 26 | ipl20,100401,1216514,1st innings,0,95,31/3,0,3,25,4.1,0,0,0,True,caught,425943,Sanju Samson,Rajasthan Royals,430246,Yuzvendra Chahal,Royal Challengers Bangalore,430246,Yuzvendra Chahal,35582,Robin Uthappa,0,7.44 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://gist.github.com/cheerfulstoic/d107229326a01ff0f333a1d3476e068d) 2 | # Dream11 3 | ## Repo OverView 4 | Aim is to select the team that would get the maximum total points in an IPL match under dream 11 constraints. To do so we have followed a 2 stage approach, where we first try to predict points achieved by individual players and then selecting the top 11 out of the total squad as per the cost of each player and other relevant constraints. We are using a mix integer linear optimization method to get the team out of the squad. To get the points of each player we are exploring various methods to leverage the past performance of players to predict their points in the following matches. Below is the description of how the modules are structured and the results thus obtained. 5 | 6 | ## How to Run ? 7 | Clone the repo to your local and run the controller.py file. It will automatically generate the best 11 based on multiple models into a file pred_team11.csv within Data/ folder. If run after the squad is announced for the match and before the match starts, it will slect the best XI from the current playing squad otherwise will refer to older matches to get the playing XI. The dataset Data/ipl_squad_points.csv has the details for ipl 2020 regarding players role and cost as per dream11. 8 | For any clarification please drop a note at abhishek.anand374@gmail.com. Will try to respond as soon as possible. 9 | 10 | ## Dataset Descriptions 11 | Data/pred_team11.csv - result file with the best XI from the playing for the match to be played next 12 | ###TODO - Rest descriptions to be added 13 | 14 | ## Code Descriptions 15 | controller.py - controller code used to define configs and execute the whole code 16 | 17 | main.py - Temp filw with helpfer functions to call other modules, will be merged with other classes within an execute function 18 | 19 | data_prep.py - ScoreCard- Used to summarize tha ball by ball data into match level scorecard and also define the playing role for each player 20 | Dream11Points - Points calculated as per dream 11 rules: ipl_scorecard_points.csv 21 | FeatEngg - Feature enginnering module used to add additional features like, opposition team, venue, city, rolling average of batting order, bowls bowled, player's batting points earned, player's bowling points earned, venue's batting point earned and venue's baowling point earned 22 | 23 | download_ipl20.py - Has two methods update_ipl20_master: to updated the masterdata needed for prediction by appending the scorecard for the all the matches played till date in ipl20 24 | get_current_squad: gets the playing XI declared for the most recent match to be played, it attempts to get the match by looking through the website 3 times, if the squad is not out then returns null 25 | 26 | 27 | point_prediction.py - Module with methods to predict players point in a match based on model specified -"xgb","catboost","rf","svm","arima" 28 | get_points_moving_avg() - Gives a moing average points per player as a predicted column added to the df: output: ipl_scorecard_points_avg.csv 29 | train_model() - builds the model based on the input modelname and dataset 30 | 31 | optimized_selection.py - SelectPlayingTeam: Module to select 11 players out of the full squad based on the dream11 contraints and to get maximum total points from the game based on actual match results and the one we predicted 32 | RewardEstimate: compare_pred_vs_actual_points(): Module to estimate percentile of the predicted from the actual maximum points scored in an match 33 | get_estimated_rewards(): Convert the percentile into monetary rewards to get an estimate : outut: rewards_df.csv 34 | parse_teams.py - independent script to get the squad for all ipl teams for the year 2020 35 | 36 | ## Current Results: 37 | 38 | ### Overall Results 39 | 2019 (Test Data) 40 | 41 | | method | Error | Rewards | 42 | |:-----|:-------:|------:| 43 | | Moving Average | 34% | 9,125 | 44 | | XGBoost | 32% | 550 | 45 | | Catboost | 33% | 14400 | 46 | | randomforest | | | 47 | | ensemble | | | 48 | 49 | ### Tournament Wise Results (Expected Rewards in INR): 50 | 51 | | year | rewards_xgboost | rewards_moving_avg | rewards_catboost | 52 | |:------|:----------:|----------------:|------------------------:| 53 | | 2008 | 35575 | -75 | 2100 | 54 | | 2009 | 1550 | -925 | 1000 | 55 | | 2010 | 6700 | 675 | 6100 | 56 | | 2011 | 17875 | 2300 | 195400 | 57 | | 2012 | 9475 | -675 | 14025 | 58 | | 2013 | 11475 | 3875 | 2200 | 59 | | 2014 | 1550 | -1775 | -350 | 60 | | 2015 | 6435 | 6300 | 7875 | 61 | | 2016 | 3950 | -275 | 26825 | 62 | | 2017 | 15650 | -1600 | 3550 | 63 | | 2018 | 5550 | -850 | 2875 | 64 | | 2019 | 550 | 9125 | 14400 | 65 | 66 | 67 | 68 | Link to Medium article explaining the approach - https://madhavgoswami.medium.com/dream11-team-predictor-with-python-and-machine-learning-f0dfce1489eb 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /ipl20/name_mapping_clean.csv: -------------------------------------------------------------------------------- 1 | ipl20_name,old_name 2 | Rohit Sharma,RG Sharma 3 | Quinton de Kock,Q de Kock 4 | Suryakumar Yadav,SA Yadav 5 | Saurabh Tiwary,SS Tiwary 6 | Hardik Pandya,HH Pandya 7 | Kieron Pollard,KA Pollard 8 | Krunal Pandya,KH Pandya 9 | James Pattinson,James Pattinson 10 | Rahul Chahar,RD Chahar 11 | Trent Boult,TA Boult 12 | Jasprit Bumrah,JJ Bumrah 13 | Murali Vijay,M Vijay 14 | Shane Watson,SR Watson 15 | Faf du Plessis,F du Plessis 16 | Ambati Rayudu,AT Rayudu 17 | Ravindra Jadeja,RA Jadeja 18 | Sam Curran,SM Curran 19 | MS Dhoni,MS Dhoni 20 | Kedar Jadhav,KM Jadhav 21 | Piyush Chawla,PP Chawla 22 | Deepak Chahar,DL Chahar 23 | Lungi Ngidi,L Ngidi 24 | Prithvi Shaw,PP Shaw 25 | Shikhar Dhawan,S Dhawan 26 | Shimron Hetmyer,SO Hetmyer 27 | Shreyas Iyer,SS Iyer 28 | Rishabh Pant,RR Pant 29 | Marcus Stoinis,MP Stoinis 30 | Axar Patel,AR Patel 31 | Ravichandran Ashwin,R Ashwin 32 | Kagiso Rabada,K Rabada 33 | Anrich Nortje,A Nortje 34 | Mohit Sharma,MM Sharma 35 | KL Rahul,KL Rahul 36 | Mayank Agarwal,MA Agarwal 37 | Karun Nair,KK Nair 38 | Nicholas Pooran,N Pooran 39 | Glenn Maxwell,GJ Maxwell 40 | Sarfaraz Khan,SN Khan 41 | Krishnappa Gowtham,K Gowtham 42 | Chris Jordan,CJ Jordan 43 | Mohammed Shami,Mohammed Shami 44 | Sheldon Cottrell,Sheldon Cottrell 45 | Ravi Bishnoi,R Bishnoi 46 | Dinesh Karthik,KD Karthik 47 | Ali Khan,Ali Khan 48 | Tom Banton,T Banton 49 | Pat Cummins,PJ Cummins 50 | Lockie Ferguson,LH Ferguson 51 | Chris Green,RJ Harris 52 | Kuldeep Yadav,Kuldeep Yadav 53 | Siddhesh Lad,SD Lad 54 | Eoin Morgan,EJG Morgan 55 | Kamlesh Nagarkoti,Kamlesh Nagarkoti 56 | Nikhil Naik,NS Naik 57 | Sunil Narine,SP Narine 58 | Prasidh Krishna,M Prasidh Krishna 59 | Nitish Rana,N Rana 60 | Andre Russell,AD Russell 61 | Sandeep Warrier,Sandeep Warrier 62 | Shivam Mavi,Shivam Mavi 63 | Shubman Gill,Shubman Gill 64 | Manimaran Siddharth,M Siddharth 65 | Rinku Singh,Rinku Singh 66 | Rahul Tripathi,RA Tripathi 67 | Varun Chakravarthy,Varun Chakravarthy 68 | Virat Kohli,V Kohli 69 | Moeen Ali,MM Ali 70 | Yuzvendra Chahal,YS Chahal 71 | Pavan Deshpande,P Deshpande 72 | AB de Villiers,AB de Villiers 73 | Shivam Dube,S Dube 74 | Aaron Finch,AJ Finch 75 | Gurkeerat Singh Mann,G Singh 76 | Mohammed Siraj,M Siraj 77 | Chris Morris,CH Morris 78 | Pawan Negi,P Negi 79 | Devdutt Padikkal,Devdutt Padikkal 80 | Parthiv Patel,PA Patel 81 | Josh Philippe,Josh Philippe 82 | Shahbaz Ahmed,S Ahmed 83 | Navdeep Saini,NA Saini 84 | Dale Steyn,DW Steyn 85 | Isuru Udana,I Udana 86 | Washington Sundar,Washington Sundar 87 | Umesh Yadav,UT Yadav 88 | Adam Zampa,A Zampa 89 | David Warner,DA Warner 90 | Abdul Samad,A Samad 91 | Abhishek Sharma,Abhishek Sharma 92 | Khaleel Ahmed,KK Ahmed 93 | Fabian Allen,F Allen 94 | Jonny Bairstow,JM Bairstow 95 | Basil Thampi,Basil Thampi 96 | Priyam Garg,P Garg 97 | Shreevats Goswami,SP Goswami 98 | Jason Holder,JO Holder 99 | Siddarth Kaul,S Kaul 100 | Bhuvneshwar Kumar,P Kumar 101 | Mohammad Nabi,M Nabi 102 | Shahbaz Nadeem,S Nadeem 103 | T Natarajan,T Natarajan 104 | Manish Pandey,MK Pandey 105 | Rashid Khan,Rashid Khan 106 | Wriddhiman Saha,WP Saha 107 | Bavanaka Sandeep,B Sandeep 108 | Sandeep Sharma,Sandeep Sharma 109 | Sanjay Yadav,SA Yadav 110 | Vijay Shankar,V Shankar 111 | Billy Stanlake,B Stanlake 112 | Virat Singh,V Pratap Singh 113 | Kane Williamson,KS Williamson 114 | Anmolpreet Singh,A Singh 115 | Nathan Coulter-Nile,NM Coulter-Nile 116 | Digvijay Deshmukh,D Deshmukh 117 | Ishan Kishan,Ishan Kishan 118 | Dhawal Kulkarni,DS Kulkarni 119 | Chris Lynn,CA Lynn 120 | Mitchell McClenaghan,MJ McClenaghan 121 | Mohsin Khan,M Khan 122 | Prince Balwant Rai,PB Rai 123 | Anukul Roy,A Roy 124 | Sherfane Rutherford,SE Rutherford 125 | Aditya Tare,AP Tare 126 | Jayant Yadav,AS Yadav 127 | Yashasvi Jaiswal,Yashasvi Jaiswal 128 | Steven Smith,SPD Smith 129 | Sanju Samson,SV Samson 130 | David Miller,DA Miller 131 | Robin Uthappa,RV Uthappa 132 | Rahul Tewatia,R Tewatia 133 | Riyan Parag,R Parag 134 | Tom Curran,TK Curran 135 | Jofra Archer,JC Archer 136 | Shreyas Gopal,S Gopal 137 | Jaydev Unadkat,JD Unadkat 138 | Ruturaj Gaikwad,AS Raut 139 | Avesh Khan,Avesh Khan 140 | Alex Carey,A Carey 141 | Tushar Deshpande,T Deshpande 142 | Sandeep Lamichhane,S Lamichhane 143 | Amit Mishra,A Mishra 144 | Harshal Patel,HV Patel 145 | Keemo Paul,KMA Paul 146 | Ajinkya Rahane,AM Rahane 147 | Daniel Sams,D Sams 148 | Ishant Sharma,I Sharma 149 | Lalit Yadav,L Yadav 150 | Arshdeep Singh,Arshdeep Singh 151 | Murugan Ashwin,M Ashwin 152 | Chris Gayle,CH Gayle 153 | Harpreet Brar,H Brar 154 | Deepak Hooda,DJ Hooda 155 | Mandeep Singh,Mandeep Singh 156 | Mujeeb Ur Rahman,Mujeeb Ur Rahman 157 | Darshan Nalkande,D Nalkande 158 | James Neesham,JDS Neesham 159 | Ishan Porel,I Porel 160 | Simran Singh,P Simran Singh 161 | Jagadeesha Suchith,J Suchith 162 | Tajinder Singh,T Singh 163 | Hardus Viljoen,GC Viljoen 164 | Steven Smith,SPD Smith 165 | Varun Aaron,VR Aaron 166 | Akash Singh,A Singh 167 | Anuj Rawat,A Rawat 168 | Jos Buttler,JC Buttler 169 | Yashasvi Jaiswal,Y Jaiswal 170 | Aniruddha Joshi,A Joshi 171 | Kartik Tyagi,K Tyagi 172 | Mahipal Lomror,MK Lomror 173 | Mayank Markande,M Markande 174 | Ankit Rajpoot,AS Rajpoot 175 | Shashank Singh,S Singh 176 | Ben Stokes,BA Stokes 177 | Oshane Thomas,O Thomas 178 | Andrew Tye,AJ Tye 179 | Manan Vohra,M Vohra 180 | KM Asif,M Asif 181 | Dwayne Bravo,DJ Bravo 182 | Josh Hazlewood,Josh Hazlewood 183 | Imran Tahir,Imran Tahir 184 | Narayan Jagadeesan,N Jagadeesan 185 | Monu Kumar,M Kumar 186 | Ravisrinivasan Sai Kishore,RS Kishore 187 | Mitchell Santner,MJ Santner 188 | Karn Sharma,KV Sharma 189 | Shardul Thakur,SN Thakur 190 | Dinesh Karthik,KD Kartik 191 | Mitchell Marsh,MR Marsh 192 | -------------------------------------------------------------------------------- /Data/pred_data_features.csv: -------------------------------------------------------------------------------- 1 | matchid,playername,total_runs,total_balls_faced,total_legal_balls_faced,run_6,run_4,fallofwickets,batsmen_innings,batsmen_battingteam,batsmen_bowlingteam,total_wickets,total_balls_bowled,total_legal_balls_bowled,total_runs_given,maiden_overs,bowlers_innings,bowler_battingteam,bowler_bowlingteam,economy_rate,playing_role,total_runs_points,run_6_points,run_4_points,run_bonus_points,total_bat_points,total_wickets_points,economy_rate_points,maiden_overs_points,wicket_bonus_points,total_bowl_points,total_points,playing_team,opposition_team,playercost,year,city,venue,home_team,away_team,toss_winner,home_game,toss_flag,player_match_count,total_bat_points_venue_avg2,total_bowl_points_venue_avg2,total_points_playername_avg2,fallofwickets_playername_avg2,total_balls_bowled_playername_avg2,total_bat_points_venue_avg3,total_bowl_points_venue_avg3,total_points_playername_avg3,fallofwickets_playername_avg3,total_balls_bowled_playername_avg3,total_bat_points_venue_avg5,total_bowl_points_venue_avg5,total_points_playername_avg5,fallofwickets_playername_avg5,total_balls_bowled_playername_avg5,total_bat_points_venue_avg10,total_bowl_points_venue_avg10,total_points_playername_avg10,fallofwickets_playername_avg10,total_balls_bowled_playername_avg10 2 | 1254114,A Nortje,,,,,,,,,,,,,,,,,,,Bowler,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,8.0,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,7,337.5,225.5,45.5,0.0,24.0,333.6666666666667,291.0,48.333333333333336,0.0,24.0,315.8,280.4,33.8,0.0,22.2,422.4,190.6,,, 3 | 1254114,AR Patel,,,,,,,,,,,,,,,,,,,AllRounder,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,8.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,95,337.5,225.5,70.0,0.0,24.5,333.6666666666667,291.0,60.66666666666666,0.0,24.666666666666668,315.8,280.4,43.0,0.0,23.2,422.4,190.6,34.4,0.0,24.9 4 | 1254114,AT Rayudu,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Chennai Super Kings,Delhi Capitals,9.0,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,0,0,152,337.5,225.5,19.5,0.0,0.0,333.6666666666667,291.0,17.0,0.0,0.0,315.8,280.4,14.6,0.0,0.0,422.4,190.6,25.3,0.4,0.0 5 | 1254114,DJ Bravo,,,,,,,,,,,,,,,,,,,AllRounder,,,,,,,,,,,,Chennai Super Kings,Delhi Capitals,10.0,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,0,0,143,337.5,225.5,91.0,0.0,25.5,333.6666666666667,291.0,78.66666666666667,0.0,26.0,315.8,280.4,56.6,0.0,22.6,422.4,190.6,35.2,0.4,22.1 6 | 1254114,DL Chahar,,,,,,,,,,,,,,,,,,,Bowler,,,,,,,,,,,,Chennai Super Kings,Delhi Capitals,8.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,0,0,51,337.5,225.5,39.5,0.0,24.0,333.6666666666667,291.0,26.666666666666668,0.0,24.33333333333333,315.8,280.4,15.6,0.0,24.6,422.4,190.6,29.8,0.0,22.4 7 | 1254114,F du Plessis,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Chennai Super Kings,Delhi Capitals,9.0,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,0,0,83,337.5,225.5,18.0,0.0,0.0,333.6666666666667,291.0,29.0,0.0,0.0,315.8,280.4,32.8,0.0,0.0,422.4,190.6,53.5,0.0,0.0 8 | 1254114,K Rabada,,,,,,,,,,,,,,,,,,,Bowler,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,9.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,35,337.5,225.5,36.5,0.0,25.5,333.6666666666667,291.0,32.666666666666664,0.0,25.666666666666668,315.8,280.4,40.0,1.8,24.0,422.4,190.6,26.7,0.9,23.0 9 | 1254114,MP Stoinis,,,,,,,,,,,,,,,,,,,AllRounder,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,8.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,44,337.5,225.5,1.0,0.0,6.5,333.6666666666667,291.0,11.333333333333334,0.0,6.333333333333333,315.8,280.4,9.8,0.0,6.4,422.4,190.6,13.3,0.0,6.9 10 | 1254114,MS Dhoni,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Chennai Super Kings,Delhi Capitals,9.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,0,0,184,337.5,225.5,8.0,0.0,0.0,333.6666666666667,291.0,6.0,0.0,0.0,315.8,280.4,7.6,0.0,0.0,422.4,190.6,17.9,0.0,0.0 11 | 1254114,PP Shaw,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,8.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,42,337.5,225.5,10.0,0.0,0.0,333.6666666666667,291.0,10.0,0.0,0.0,315.8,280.4,37.8,0.0,0.0,422.4,190.6,33.8,0.0,0.0 12 | 1254114,R Ashwin,,,,,,,,,,,,,,,,,,,Bowler,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,9.0,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,149,337.5,225.5,22.5,0.0,22.5,333.6666666666667,291.0,26.666666666666668,0.0,23.33333333333333,315.8,280.4,23.6,0.0,24.0,422.4,190.6,15.0,0.0,23.5 13 | 1254114,RA Jadeja,,,,,,,,,,,,,,,,,,,AllRounder,,,,,,,,,,,,Chennai Super Kings,Delhi Capitals,8.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,0,0,181,337.5,225.5,14.5,0.0,15.0,333.6666666666667,291.0,28.0,0.0,18.0,315.8,280.4,30.2,0.0,15.6,422.4,190.6,45.4,0.0,18.9 14 | 1254114,RR Pant,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,9.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,72,337.5,225.5,38.0,0.0,0.0,333.6666666666667,291.0,34.0,0.0,0.0,315.8,280.4,32.6,0.0,0.0,422.4,190.6,32.9,0.0,0.0 15 | 1254114,S Dhawan,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,10.0,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,176,337.5,225.5,30.0,0.0,0.0,333.6666666666667,291.0,23.0,0.0,0.0,315.8,280.4,37.4,0.0,0.0,422.4,190.6,45.7,0.0,0.0 16 | 1254114,SN Thakur,,,,,,,,,,,,,,,,,,,Bowler,,,,,,,,,,,,Chennai Super Kings,Delhi Capitals,8.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,0,0,50,337.5,225.5,38.0,0.0,25.0,333.6666666666667,291.0,47.0,0.0,24.666666666666668,315.8,280.4,42.8,0.0,25.2,422.4,190.6,27.9,0.0,24.8 17 | 1254114,SO Hetmyer,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,8.5,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,18,337.5,225.5,25.5,0.0,0.0,333.6666666666667,291.0,18.33333333333333,0.0,0.0,315.8,280.4,15.2,0.0,0.0,422.4,190.6,20.4,0.0,0.0 18 | 1254114,SS Iyer,,,,,,,,,,,,,,,,,,,Batsmen,,,,,,,,,,,,Delhi Capitals,Chennai Super Kings,9.0,2020.0,neutral venue,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Delhi Capitals,1,1,71,337.5,225.5,47.0,0.0,0.0,333.6666666666667,291.0,48.0,0.0,0.0,315.8,280.4,42.0,0.0,0.0,422.4,190.6,47.3,0.2,0.0 19 | -------------------------------------------------------------------------------- /ipl20/matchdatascorecardpathipl20.csv: -------------------------------------------------------------------------------- 1 | matchid,playername,total_runs,total_balls_faced,total_legal_balls_faced,run_6,run_4,fallofwickets,batsmen_innings,batsmen_battingteam,batsmen_bowlingteam,total_wickets,total_balls_bowled,total_legal_balls_bowled,total_runs_given,maiden_overs,bowlers_innings,bowler_battingteam,bowler_bowlingteam,economy_rate,playing_role,total_runs_points,run_6_points,run_4_points,run_bonus_points,total_bat_points,total_wickets_points,economy_rate_points,maiden_overs_points,wicket_bonus_points,total_bowl_points,total_points 2 | 1254090,AB de Villiers,24.0,18.0,18.0,2.0,1.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,,,,,,,,,,Batsmen,24.0,4.0,1.0,0,29.0,,0,,0,,29.0 3 | 1254090,Aiden Markram,20.0,14.0,14.0,1.0,2.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,,6.0,6.0,5.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,5.0,AllRounder,20.0,2.0,2.0,0,24.0,,4,0.0,0,4.0,28.0 4 | 1254090,Dan Christian,0.0,1.0,1.0,,,2.0,1st innings,Royal Challengers Bangalore,Punjab Kings,,6.0,6.0,11.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,11.0,Bowler,0.0,,,-2,-2.0,,-6,0.0,0,-6.0,-8.0 5 | 1254090,Devdutt Padikkal,43.0,40.0,38.0,2.0,4.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,,,,,,,,,,Batsmen,43.0,4.0,4.0,0,51.0,,0,,0,,51.0 6 | 1254090,GJ Maxwell,61.0,35.0,33.0,4.0,3.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,,,,,,,,,,Batsmen,61.0,8.0,3.0,8,80.0,,0,,0,,80.0 7 | 1254090,George Garton,0.0,1.0,1.0,,,7.0,1st innings,Royal Challengers Bangalore,Punjab Kings,1.0,27.0,24.0,27.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,6.75,Bowler,0.0,,,-2,-2.0,25.0,0,0.0,0,25.0,23.0 8 | 1254090,H Brar,3.0,2.0,2.0,,,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,,24.0,24.0,27.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,6.75,Bowler,3.0,,,0,3.0,,0,0.0,0,0.0,3.0 9 | 1254090,HV Patel,1.0,1.0,1.0,,,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,,24.0,24.0,27.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,6.75,Bowler,1.0,,,0,1.0,,0,0.0,0,0.0,1.0 10 | 1254090,KL Rahul,40.0,35.0,35.0,2.0,1.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,,,,,,,,,,Batsmen,40.0,4.0,1.0,0,45.0,,0,,0,,45.0 11 | 1254090,MA Agarwal,63.0,46.0,44.0,2.0,6.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,,,,,,,,,,Batsmen,63.0,4.0,6.0,8,81.0,,0,,0,,81.0 12 | 1254090,Moises Henriques,12.0,9.0,9.0,1.0,,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,3.0,24.0,24.0,14.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,3.5,AllRounder,12.0,2.0,,0,14.0,75.0,6,0.0,0,81.0,95.0 13 | 1254090,N Pooran,3.0,7.0,7.0,,,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,,,,,,,,,,Batsmen,3.0,,,0,3.0,,0,,0,,3.0 14 | 1254090,S Ahmed,8.0,4.0,4.0,1.0,,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,1.0,18.0,18.0,29.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,9.666666666666666,Bowler,8.0,2.0,,0,10.0,25.0,-2,0.0,0,23.0,33.0 15 | 1254090,SN Khan,0.0,1.0,1.0,,,4.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,,,,,,,,,,Batsmen,0.0,,,-2,-2.0,,0,,0,,-2.0 16 | 1254090,Shahrukh Khan,17.0,12.0,11.0,1.0,1.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,,,,,,,,,,Batsmen,17.0,2.0,1.0,0,20.0,,0,,0,,20.0 17 | 1254090,V Kohli,27.0,25.0,25.0,1.0,2.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,,,,,,,,,,Batsmen,27.0,2.0,2.0,0,31.0,,0,,0,,31.0 18 | 1254109,A Samad,25.0,18.0,18.0,3.0,,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,,,,,,,,,,Batsmen,25.0,6.0,,0,31.0,,0,,0,,31.0 19 | 1254109,Abhishek Sharma,6.0,10.0,10.0,,,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,,,,,,,,,,Batsmen,6.0,,,0,6.0,,0,,0,,6.0 20 | 1254109,EJG Morgan,2.0,2.0,2.0,,,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,,,,,,,,,,Batsmen,2.0,,,0,2.0,,0,,0,,2.0 21 | 1254109,JO Holder,4.0,9.0,9.0,,,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,2.0,24.0,24.0,32.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,8.0,AllRounder,4.0,,,0,4.0,50.0,0,0.0,0,50.0,54.0 22 | 1254109,Jason Roy,11.0,13.0,12.0,,2.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,,,,,,,,,,Batsmen,11.0,,2.0,0,13.0,,0,,0,,13.0 23 | 1254109,KD Karthik,18.0,12.0,12.0,,3.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,,,,,,,,,,Batsmen,18.0,,3.0,0,21.0,,0,,0,,21.0 24 | 1254109,KS Williamson,26.0,21.0,21.0,,4.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,,,,,,,,,,Batsmen,26.0,,4.0,0,30.0,,0,,0,,30.0 25 | 1254109,N Rana,27.0,35.0,33.0,,3.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,,,,,,,,,,Batsmen,27.0,,3.0,0,30.0,,0,,0,,30.0 26 | 1254109,P Garg,21.0,31.0,31.0,1.0,,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,,,,,,,,,,Batsmen,21.0,2.0,,0,23.0,,0,,0,,23.0 27 | 1254109,P Kumar,7.0,7.0,7.0,,,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,,24.0,24.0,20.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,5.0,Bowler,7.0,,,0,7.0,,4,0.0,0,4.0,11.0 28 | 1254109,RA Tripathi,7.0,6.0,6.0,,1.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,,,,,,,,,,Batsmen,7.0,,1.0,0,8.0,,0,,0,,8.0 29 | 1254109,Rashid Khan,8.0,6.0,6.0,,1.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,1.0,24.0,24.0,23.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,5.75,Bowler,8.0,,1.0,0,9.0,25.0,2,0.0,0,27.0,36.0 30 | 1254109,S Kaul,7.0,5.0,5.0,,1.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,1.0,22.0,22.0,17.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,4.636363636363637,Bowler,7.0,,1.0,0,8.0,25.0,4,0.0,0,29.0,37.0 31 | 1254109,Shubman Gill,57.0,51.0,51.0,,10.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,,,,,,,,,,Batsmen,57.0,,10.0,8,75.0,,0,,0,,75.0 32 | 1254109,Venkatesh Iyer,8.0,14.0,14.0,,,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,,,,,,,,,,Batsmen,8.0,,,0,8.0,,0,,0,,8.0 33 | 1254109,WP Saha,0.0,1.0,1.0,,,1.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,,,,,,,,,,Batsmen,0.0,,,-2,-2.0,,0,,0,,-2.0 34 | 1254090,Arshdeep Singh,,,,,,,,,,,22.0,18.0,42.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,14.0,Bowler,,,,0,,,-6,0.0,0,-6.0,-6.0 35 | 1254090,M Siraj,,,,,,,,,,,25.0,24.0,34.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,8.5,Bowler,,,,0,,,0,0.0,0,0.0,0.0 36 | 1254090,Mohammed Shami,,,,,,,,,,3.0,24.0,24.0,39.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,9.75,Bowler,,,,0,,75.0,-2,0.0,0,73.0,73.0 37 | 1254090,R Bishnoi,,,,,,,,,,,25.0,25.0,37.0,0.0,1st innings,Royal Challengers Bangalore,Punjab Kings,8.88,Bowler,,,,0,,,0,0.0,0,0.0,0.0 38 | 1254090,YS Chahal,,,,,,,,,,3.0,26.0,25.0,30.0,0.0,2nd innings,Punjab Kings,Royal Challengers Bangalore,7.2,Bowler,,,,0,,75.0,0,0.0,0,75.0,75.0 39 | 1254109,SP Narine,,,,,,,,,,,24.0,24.0,12.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,3.0,Bowler,,,,0,,,6,0.0,0,6.0,6.0 40 | 1254109,Shakib Al Hasan,,,,,,,,,,1.0,24.0,24.0,20.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,5.0,Bowler,,,,0,,25.0,4,0.0,0,29.0,29.0 41 | 1254109,Shivam Mavi,,,,,,,,,,2.0,25.0,24.0,29.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,7.25,Bowler,,,,0,,50.0,0,0.0,0,50.0,50.0 42 | 1254109,Tim Southee,,,,,,,,,,2.0,24.0,24.0,26.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,6.5,Bowler,,,,0,,50.0,0,0.0,0,50.0,50.0 43 | 1254109,Umran Malik,,,,,,,,,,,26.0,24.0,27.0,0.0,2nd innings,Kolkata Knight Riders,Sunrisers Hyderabad,6.75,Bowler,,,,0,,,0,0.0,0,0.0,0.0 44 | 1254109,Varun Chakravarthy,,,,,,,,,,2.0,24.0,24.0,28.0,0.0,1st innings,Sunrisers Hyderabad,Kolkata Knight Riders,7.0,Bowler,,,,0,,50.0,0,0.0,0,50.0,50.0 45 | -------------------------------------------------------------------------------- /ipl20/.ipynb_checkpoints/match_summary_ipl20-checkpoint.csv: -------------------------------------------------------------------------------- 1 | matchid,date,year,city,venue,team1,team2,result,tossdecision,winner,by_what,by_how_many,mom 2 | 1216492,2020-09-19T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Mumbai Indians,Chennai Super Kings,Super Kings won by 5 wickets,,Chennai Super Kings,wickets,[5], 3 | 1216493,2020-09-20T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Delhi Capitals,Kings XI Punjab,Match tied (Delhi Capitals won the one-over eliminator),,Match Tied/Cancelled/Not yet ended,,[], 4 | 1216534,2020-09-21T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Royal Challengers Bangalore,Sunrisers Hyderabad,RCB won by 10 runs,,Royal Challengers Bangalore,runs,[10], 5 | 1216496,2020-09-22T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Rajasthan Royals,Chennai Super Kings,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 6 | 1216508,2020-09-23T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kolkata Knight Riders,Mumbai Indians,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 7 | 1216510,2020-09-24T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Kings XI Punjab,Royal Challengers Bangalore,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 8 | 1216539,2020-09-25T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Chennai Super Kings,Delhi Capitals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 9 | 1216545,2020-09-26T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kolkata Knight Riders,Sunrisers Hyderabad,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 10 | 1216527,2020-09-27T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Rajasthan Royals,Kings XI Punjab,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 11 | 1216547,2020-09-28T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Royal Challengers Bangalore,Mumbai Indians,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 12 | 1216532,2020-09-29T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Delhi Capitals,Sunrisers Hyderabad,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 13 | 1216504,2020-09-30T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Rajasthan Royals,Kolkata Knight Riders,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 14 | 1216503,2020-10-01T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kings XI Punjab,Mumbai Indians,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 15 | 1216516,2020-10-02T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Chennai Super Kings,Sunrisers Hyderabad,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 16 | 1216514,2020-10-03T10:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Royal Challengers Bangalore,Rajasthan Royals,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 17 | 1216515,2020-10-03T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Delhi Capitals,Kolkata Knight Riders,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 18 | 1216538,2020-10-04T10:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Mumbai Indians,Sunrisers Hyderabad,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 19 | 1216513,2020-10-04T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Kings XI Punjab,Chennai Super Kings,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 20 | 1216519,2020-10-05T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Royal Challengers Bangalore,Delhi Capitals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 21 | 1216511,2020-10-06T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Mumbai Indians,Rajasthan Royals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 22 | 1216501,2020-10-07T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kolkata Knight Riders,Chennai Super Kings,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 23 | 1216542,2020-10-08T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Sunrisers Hyderabad,Kings XI Punjab,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 24 | 1216500,2020-10-09T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Rajasthan Royals,Delhi Capitals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 25 | 1216523,2020-10-10T10:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kings XI Punjab,Kolkata Knight Riders,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 26 | 1216525,2020-10-10T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Chennai Super Kings,Royal Challengers Bangalore,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 27 | 1216507,2020-10-11T10:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Sunrisers Hyderabad,Rajasthan Royals,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 28 | 1216529,2020-10-11T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Mumbai Indians,Delhi Capitals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 29 | 1216540,2020-10-12T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Royal Challengers Bangalore,Kolkata Knight Riders,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 30 | 1216528,2020-10-13T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Sunrisers Hyderabad,Chennai Super Kings,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 31 | 1216543,2020-10-14T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Delhi Capitals,Rajasthan Royals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 32 | 1216531,2020-10-15T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Royal Challengers Bangalore,Kings XI Punjab,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 33 | 1216526,2020-10-16T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Mumbai Indians,Kolkata Knight Riders,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 34 | 1216522,2020-10-17T10:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Rajasthan Royals,Royal Challengers Bangalore,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 35 | 1216509,2020-10-17T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Delhi Capitals,Chennai Super Kings,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 36 | 1216512,2020-10-18T10:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Sunrisers Hyderabad,Kolkata Knight Riders,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 37 | 1216517,2020-10-18T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Mumbai Indians,Kings XI Punjab,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 38 | 1216533,2020-10-19T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Chennai Super Kings,Rajasthan Royals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 39 | 1216546,2020-10-20T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Kings XI Punjab,Delhi Capitals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 40 | 1216494,2020-10-21T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kolkata Knight Riders,Royal Challengers Bangalore,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 41 | 1216518,2020-10-22T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Rajasthan Royals,Sunrisers Hyderabad,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 42 | 1216521,2020-10-23T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Chennai Super Kings,Mumbai Indians,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 43 | 1216497,2020-10-24T10:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kolkata Knight Riders,Delhi Capitals,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 44 | 1216498,2020-10-24T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Kings XI Punjab,Sunrisers Hyderabad,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 45 | 1216544,2020-10-25T10:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Royal Challengers Bangalore,Chennai Super Kings,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 46 | 1216541,2020-10-25T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Rajasthan Royals,Mumbai Indians,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 47 | 1216520,2020-10-26T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Kolkata Knight Riders,Kings XI Punjab,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 48 | 1216524,2020-10-27T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Sunrisers Hyderabad,Delhi Capitals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 49 | 1216499,2020-10-28T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Mumbai Indians,Royal Challengers Bangalore,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 50 | 1216536,2020-10-29T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Chennai Super Kings,Kolkata Knight Riders,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 51 | 1216537,2020-10-30T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kings XI Punjab,Rajasthan Royals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 52 | 1216535,2020-10-31T10:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Delhi Capitals,Mumbai Indians,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 53 | 1216502,2020-10-31T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Royal Challengers Bangalore,Sunrisers Hyderabad,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 54 | 1216506,2020-11-01T10:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Chennai Super Kings,Kings XI Punjab,Starts at 2:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 55 | 1216530,2020-11-01T14:00Z,2020,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Kolkata Knight Riders,Rajasthan Royals,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 56 | 1216505,2020-11-02T14:00Z,2020,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Delhi Capitals,Royal Challengers Bangalore,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 57 | 1216495,2020-11-03T14:00Z,2020,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Sunrisers Hyderabad,Mumbai Indians,Starts at 6:00 PM local time,,Match Tied/Cancelled/Not yet ended,,[], 58 | -------------------------------------------------------------------------------- /optimized_selection.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | from pulp import * 4 | from scipy.stats import rankdata 5 | 6 | class SelectPlayingTeam: 7 | 8 | def __init__(self, team_points, constconfig, colconfig): 9 | self.team_points = team_points 10 | # self.team_points['playing_team'] = np.where(pd.isnull(self.team_points['batsmen_innings']),self.team_points['bowler_bowlingteam'],self.team_points['batsmen_battingteam']) 11 | self.constconfig = constconfig 12 | self.playernamecol = colconfig['PLAYERNAME'] 13 | self.pointscol = colconfig['ACTUALPOINTS'] 14 | self.predpointscol = colconfig['PREDPOINTS'] 15 | self.playingrole = colconfig['PLAYINGROLE'] 16 | self.playercost = colconfig['PLAYERCOST'] 17 | self.predselection = colconfig['PREDSELECTION'] 18 | self.actualselection = colconfig['ACTUALSELECTION'] 19 | self.predselectionrank = colconfig['PREDSELECTIONRANK'] 20 | self.actualselectionrank = colconfig['ACTUALSELECTIONRANK'] 21 | self.playing_team = colconfig['PLAYERTEAM'] 22 | 23 | return 24 | 25 | def select_top11_players(self, pointscol,selectioncol,rankcol,adjustcappoints): 26 | """ 27 | function to select top 11 players out of the 22 players based on a given score 28 | :param input_df: dataset with the players name and match id 29 | :param predpointscol: column used to prioritize and pick top 11 players 30 | :param pointscol: actual points obtained by the players in the match 31 | :return: output_df: input_df wuth additional column with pred_selection_true 32 | """ 33 | selected_team = self.team_points.fillna(0).groupby('matchid').apply(self.get_optimized_team, pointscol, selectioncol, rankcol) 34 | self.team_points = pd.merge(self.team_points, selected_team, on=['matchid', 'playername'], how='left') 35 | if adjustcappoints: 36 | self.adjust_points_for_captaincy(pointscol, rankcol) 37 | return 38 | 39 | def get_optimized_team(self, team_df, pointscol, selectioncol, rankcol): 40 | """ 41 | function to select the 11 people from the squad of the two teams playing a particular match 42 | :param team_df: dataframe with the actual and predicted points per player in a particular match 43 | :param pointscol: column name which has the points value 44 | :param selectioncol: column name which has the cost of each player 45 | :param rankcol: column name which has the cost of each player 46 | :return 47 | """ 48 | player_list = list(team_df[self.playernamecol]) 49 | points = dict(zip(player_list, team_df[pointscol])) 50 | costs = dict(zip(player_list, team_df[self.playercost])) 51 | batsmen = dict(zip(player_list, np.where(team_df[self.playingrole] == 'Batsmen', 1, 0))) 52 | bowler = dict(zip(player_list, np.where(team_df[self.playingrole] == 'Bowler', 1, 0))) 53 | allrounder = dict(zip(player_list, np.where(team_df[self.playingrole] == 'AllRounder', 1, 0))) 54 | team1 = team_df[self.playing_team].unique()[0] 55 | team2 = team_df[self.playing_team].unique()[1] 56 | team1 = dict(zip(player_list, np.where(team_df[self.playing_team] == team1, 1, 0))) 57 | team2 = dict(zip(player_list, np.where(team_df[self.playing_team] == team2, 1, 0))) 58 | 59 | prob = LpProblem("Maximize Dream 11 Points", LpMaximize) 60 | 61 | player_vars = LpVariable.dicts("player", player_list, 0, 1, cat='Integer') 62 | prob += lpSum([1 * player_vars[i] for i in player_list]) <= self.constconfig['MAXPLAYERCOUNT'] , "Total players selected" 63 | 64 | prob += lpSum([points[i] * player_vars[i] for i in player_list]), "Total points earned by the team" 65 | 66 | prob += lpSum([costs[i] * player_vars[i] for i in player_list]) <= self.constconfig['MAXCOSTPOINT'], "MaximumCost" 67 | 68 | prob += lpSum([batsmen[i] * player_vars[i] for i in player_list]) >= self.constconfig['MINBATSMEN'], "MinimumBatsmen" 69 | prob += lpSum([batsmen[i] * player_vars[i] for i in player_list]) <= self.constconfig['MAXBATSMEN'], "MaximumBatsmen" 70 | 71 | prob += lpSum([bowler[i] * player_vars[i] for i in player_list]) >= self.constconfig['MINBOWLER'], "MinimumBowler" 72 | prob += lpSum([bowler[i] * player_vars[i] for i in player_list]) <= self.constconfig['MAXBOWLER'], "MaximumBowler" 73 | 74 | prob += lpSum([allrounder[i] * player_vars[i] for i in player_list]) >= self.constconfig['MINALLROUNDER'], "MinimumAllRounder" 75 | prob += lpSum([allrounder[i] * player_vars[i] for i in player_list]) <= self.constconfig['MAXALLROUNDER'], "MaximumAllRounder" 76 | 77 | prob += lpSum([team1[i] * player_vars[i] for i in player_list]) <= self.constconfig['MAXTEAMCOUNT'], "MaximumTeamCount1" 78 | prob += lpSum([team2[i] * player_vars[i] for i in player_list]) <= self.constconfig['MAXTEAMCOUNT'], "MaximumTeamCount2" 79 | 80 | # The problem is solved using PuLP's choice of Solver 81 | prob.solve() 82 | 83 | # The status of the solution is printed to the screen 84 | # print("Status:", LpStatus[prob.status]) 85 | # print("The total points scored by the team is : ${}".format(value(prob.objective))) 86 | if value(prob.objective) != None: 87 | playernamelist = [] 88 | playerscorelist = [] 89 | 90 | for v in prob.variables(): 91 | if v.varValue > 0: 92 | a = v.name.replace("player_", "").replace("_", " ") 93 | playernamelist.append(a) 94 | playerscorelist.append(points[a]) 95 | playerranklist = len(playerscorelist) - rankdata(playerscorelist, method='ordinal').astype(int) 96 | playername = pd.Series(playernamelist, name='playername') 97 | playerrank = pd.Series(playerranklist, name=rankcol) 98 | selection_series = pd.Series(np.repeat(1, len(playername)), name=selectioncol) 99 | playerselec_df = pd.concat([playername, playerrank, selection_series], axis=1) 100 | return playerselec_df 101 | return 102 | 103 | def adjust_points_for_captaincy(self, pointscol, rankcol): 104 | """ 105 | function to adjust player's points if it is highest and 2nd highest 106 | :param input_df: 107 | :return: 108 | """ 109 | CAP_BUMP = 2.0 110 | VICE_CAP_BUMP = 1.5 111 | self.team_points[pointscol] = np.where(self.team_points[rankcol] == 0, self.team_points[pointscol] * CAP_BUMP, 112 | np.where(self.team_points[rankcol] == 1, self.team_points[pointscol] * VICE_CAP_BUMP, self.team_points[pointscol])) 113 | 114 | return 115 | 116 | class RewardEstimate: 117 | 118 | def __init__(self, input_df, matchdata): 119 | self.input_df = input_df 120 | self.matchdata =matchdata 121 | return 122 | 123 | def compare_pred_vs_actual_points(self, minplayercount): 124 | """ 125 | function to calculate the selected team's points achieved as a percentage of maximum possible 126 | :param input_df: input dataframe with predicted points per player and actual points scored 127 | :return: total_match_points 128 | """ 129 | output_df = self.input_df 130 | output_df['pred_points_player'] = np.where(np.isnan(self.input_df['pred_selection_true']), np.nan, self.input_df['pred_selection_true']*self.input_df['total_points']) 131 | output_df['actual_points_player'] = np.where(np.isnan(self.input_df['actual_selection_true']), np.nan, self.input_df['actual_selection_true']*self.input_df['total_points']) 132 | total_match_points_pred = pd.DataFrame(output_df.groupby('matchid')['pred_points_player'].sum()) 133 | total_match_points_actual = pd.DataFrame(output_df.groupby('matchid')['actual_points_player'].sum()) 134 | count_player_selected = pd.DataFrame(output_df.groupby('matchid')['pred_selection_true'].sum()).rename(columns={'pred_selection_true':'pred_selection_cnt'}) 135 | total_match_points = total_match_points_pred.merge(total_match_points_actual, left_index=True, right_index=True, how='left') 136 | total_match_points = total_match_points.merge(count_player_selected, left_index=True, right_index=True, how='left') 137 | total_match_points = total_match_points.reset_index() 138 | total_match_points['error'] = np.where(total_match_points['pred_selection_cnt'] >= minplayercount, 139 | (total_match_points['actual_points_player'] - total_match_points['pred_points_player'])/total_match_points['actual_points_player'], np.nan) 140 | self.total_match_points = total_match_points 141 | 142 | return 143 | 144 | 145 | def get_estimated_rewards(self, config, fixed_multipler) -> np.array: 146 | """ 147 | function to calculate the expected rewards based on the estimated points 148 | :param input_df: input_df with the accuracy columns to estimate the rewards 149 | :return: output_df: input_df with the rewards earned column added 150 | """ 151 | accuracy_series = self.total_match_points['error'] 152 | conditions = [(np.isnan(accuracy_series)), 153 | (accuracy_series < .01), 154 | (accuracy_series < 0.02), 155 | (accuracy_series < 0.03), 156 | (accuracy_series < 0.04), 157 | (accuracy_series < 0.05), 158 | (accuracy_series < 0.06), 159 | (accuracy_series < 0.08), 160 | (accuracy_series < 0.10), 161 | (accuracy_series < 0.15), 162 | (accuracy_series < 0.20), 163 | (accuracy_series < 0.25)] 164 | 165 | choices = [0, 166 | (config['1per'] - 1) * fixed_multipler, 167 | (config['2per'] - 1) * fixed_multipler, 168 | (config['3per'] - 1) * fixed_multipler, 169 | (config['4per'] - 1) * fixed_multipler, 170 | (config['5per'] - 1) * fixed_multipler, 171 | (config['6per'] - 1) * fixed_multipler, 172 | (config['8per'] - 1) * fixed_multipler, 173 | (config['10per'] - 1) * fixed_multipler, 174 | (config['15per'] - 1) * fixed_multipler, 175 | (config['20per'] - 1) * fixed_multipler, 176 | (config['25per'] - 1) * fixed_multipler] 177 | 178 | self.total_match_points['rewards_earned'] = np.select(conditions, choices, default=-1*fixed_multipler) 179 | 180 | return 181 | 182 | def get_rewards_summary(self): 183 | match_date = self.matchdata[['matchid', 'date']].drop_duplicates() 184 | yearly_summary = pd.merge(self.total_match_points, match_date, on='matchid', how='left') 185 | yearly_summary['year'] = yearly_summary['date'].str.split('-').str[0] 186 | print(yearly_summary['rewards_earned']) 187 | yearly_summary = pd.DataFrame(yearly_summary.groupby(['year'])[['error', 'rewards_earned']].agg({'error':'mean', 'rewards_earned':'sum'})).reset_index() 188 | return yearly_summary 189 | -------------------------------------------------------------------------------- /ipl20/match_summary_ipl20.csv: -------------------------------------------------------------------------------- 1 | matchid,date,year,city,venue,team1,team2,result,tossdecision,winner,by_what,by_how_many,mom 2 | 1254110,2021-10-04T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Delhi Capitals,Chennai Super Kings,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 3 | 1254093,2021-10-05T14:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Rajasthan Royals,Mumbai Indians,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 4 | 1254095,2021-10-06T14:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Royal Challengers Bangalore,Sunrisers Hyderabad,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 5 | 1254094,2021-10-07T10:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Chennai Super Kings,Punjab Kings,Starts at 14:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 6 | 1254106,2021-10-07T14:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Kolkata Knight Riders,Rajasthan Royals,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 7 | 1254088,2021-10-08T14:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Sunrisers Hyderabad,Mumbai Indians,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 8 | 1254101,2021-10-08T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Royal Challengers Bangalore,Delhi Capitals,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 9 | 1254114,2021-10-10T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,TBA,TBA,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 10 | 1254115,2021-10-11T14:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,TBA,TBA,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 11 | 1254116,2021-10-13T14:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,TBA,TBA,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 12 | 1254117,2021-10-15T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,TBA,TBA,Starts at 18:00 local time,,Match Tied/Cancelled/Not yet ended,,[], 13 | 1254109,2021-10-03T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Sunrisers Hyderabad,Kolkata Knight Riders,KKR won by 6 wkts (2b rem),,Kolkata Knight Riders,,[6], 14 | 1254090,2021-10-03T10:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Royal Challengers Bangalore,Punjab Kings,RCB won by 6 runs,,Royal Challengers Bangalore,runs,[6], 15 | 1254089,2021-10-02T14:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Chennai Super Kings,Rajasthan Royals,Royals won by 7 wkts (15b rem),,Rajasthan Royals,,[7], 16 | 1254112,2021-10-02T10:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Mumbai Indians,Delhi Capitals,Capitals won by 4 wkts (5b rem),,Delhi Capitals,,[4], 17 | 1254102,2021-10-01T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Kolkata Knight Riders,Punjab Kings,Punjab Kings won by 5 wkts (3b rem),,Punjab Kings,,[5], 18 | 1254091,2021-09-30T14:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Sunrisers Hyderabad,Chennai Super Kings,Super Kings won by 6 wkts (2b rem),,Chennai Super Kings,,[6], 19 | 1254103,2021-09-29T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Rajasthan Royals,Royal Challengers Bangalore,RCB won by 7 wkts (17b rem),,Royal Challengers Bangalore,,[7], 20 | 1254099,2021-09-28T14:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Punjab Kings,Mumbai Indians,Mumbai won by 6 wkts (6b rem),,Mumbai Indians,,[6], 21 | 1254092,2021-09-28T10:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Delhi Capitals,Kolkata Knight Riders,KKR won by 3 wkts (10b rem),,Kolkata Knight Riders,,[3], 22 | 1254100,2021-09-27T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Rajasthan Royals,Sunrisers Hyderabad,Sunrisers won by 7 wkts (9b rem),,Sunrisers Hyderabad,,[7], 23 | 1254108,2021-09-26T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Royal Challengers Bangalore,Mumbai Indians,RCB won by 54 runs,,Royal Challengers Bangalore,runs,[54], 24 | 1254098,2021-09-26T10:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Kolkata Knight Riders,Chennai Super Kings,Super Kings won by 2 wkts (0b rem),,Chennai Super Kings,,[2], 25 | 1254107,2021-09-25T14:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Punjab Kings,Sunrisers Hyderabad,Punjab Kings won by 5 runs,,Punjab Kings,runs,[5], 26 | 1254097,2021-09-25T10:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Delhi Capitals,Rajasthan Royals,Capitals won by 33 runs,,Delhi Capitals,runs,[33], 27 | 1254113,2021-09-24T14:00Z,2021,Sharjah Cricket Stadium,Sharjah Cricket Stadium,Royal Challengers Bangalore,Chennai Super Kings,Super Kings won by 6 wkts (11b rem),,Chennai Super Kings,,[6], 28 | 1254096,2021-09-23T14:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Mumbai Indians,Kolkata Knight Riders,KKR won by 7 wkts (29b rem),,Kolkata Knight Riders,,[7], 29 | 1254105,2021-09-22T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Sunrisers Hyderabad,Delhi Capitals,Capitals won by 8 wkts (13b rem),,Delhi Capitals,,[8], 30 | 1254111,2021-09-21T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Rajasthan Royals,Punjab Kings,Royals won by 2 runs,,Rajasthan Royals,runs,[2], 31 | 1254087,2021-09-20T14:00Z,2021,"Sheikh Zayed Stadium, Abu Dhabi","Sheikh Zayed Stadium, Abu Dhabi",Royal Challengers Bangalore,Kolkata Knight Riders,KKR won by 9 wkts (60b rem),,Kolkata Knight Riders,,[9], 32 | 1254104,2021-09-19T14:00Z,2021,Dubai International Cricket Stadium,Dubai International Cricket Stadium,Chennai Super Kings,Mumbai Indians,Super Kings won by 20 runs,,Chennai Super Kings,runs,[20], 33 | 1254086,2021-05-02T14:00Z,2021,"Narendra Modi Stadium, Motera, Ahmedabad","Narendra Modi Stadium, Motera, Ahmedabad",Punjab Kings,Delhi Capitals,Capitals won by 7 wkts (14b rem),,Delhi Capitals,,[7], 34 | 1254085,2021-05-02T10:00Z,2021,"Arun Jaitley Stadium, Delhi","Arun Jaitley Stadium, Delhi",Rajasthan Royals,Sunrisers Hyderabad,Royals won by 55 runs,,Rajasthan Royals,runs,[55], 35 | 1254084,2021-05-01T14:00Z,2021,"Arun Jaitley Stadium, Delhi","Arun Jaitley Stadium, Delhi",Chennai Super Kings,Mumbai Indians,Mum Indians won by 4 wkts (0b rem),,Mumbai Indians,,[4], 36 | 1254083,2021-04-30T14:00Z,2021,"Narendra Modi Stadium, Motera, Ahmedabad","Narendra Modi Stadium, Motera, Ahmedabad",Punjab Kings,Royal Challengers Bangalore,Punjab Kings won by 34 runs,,Punjab Kings,runs,[34], 37 | 1254082,2021-04-29T14:00Z,2021,"Narendra Modi Stadium, Motera, Ahmedabad","Narendra Modi Stadium, Motera, Ahmedabad",Kolkata Knight Riders,Delhi Capitals,Capitals won by 7 wkts (21b rem),,Delhi Capitals,,[7], 38 | 1254081,2021-04-29T10:00Z,2021,"Arun Jaitley Stadium, Delhi","Arun Jaitley Stadium, Delhi",Rajasthan Royals,Mumbai Indians,Mum Indians won by 7 wkts (9b rem),,Mumbai Indians,,[7], 39 | 1254080,2021-04-28T14:00Z,2021,"Arun Jaitley Stadium, Delhi","Arun Jaitley Stadium, Delhi",Sunrisers Hyderabad,Chennai Super Kings,Super Kings won by 7 wkts (9b rem),,Chennai Super Kings,,[7], 40 | 1254079,2021-04-27T14:00Z,2021,"Narendra Modi Stadium, Motera, Ahmedabad","Narendra Modi Stadium, Motera, Ahmedabad",Royal Challengers Bangalore,Delhi Capitals,RCB won by 1 run,,Royal Challengers Bangalore,,[1], 41 | 1254078,2021-04-26T14:00Z,2021,"Narendra Modi Stadium, Motera, Ahmedabad","Narendra Modi Stadium, Motera, Ahmedabad",Punjab Kings,Kolkata Knight Riders,KKR won by 5 wkts (20b rem),,Kolkata Knight Riders,,[5], 42 | 1254077,2021-04-25T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Delhi Capitals,Sunrisers Hyderabad,Match tied (Capitals won the one-over eliminator),,Match Tied/Cancelled/Not yet ended,,[], 43 | 1254076,2021-04-25T10:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Chennai Super Kings,Royal Challengers Bangalore,Super Kings won by 69 runs,,Chennai Super Kings,runs,[69], 44 | 1254075,2021-04-24T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Kolkata Knight Riders,Rajasthan Royals,Royals won by 6 wkts (7b rem),,Rajasthan Royals,,[6], 45 | 1254074,2021-04-23T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Mumbai Indians,Punjab Kings,Punjab Kings won by 9 wkts (14b rem),,Punjab Kings,,[9], 46 | 1254073,2021-04-22T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Rajasthan Royals,Royal Challengers Bangalore,RCB won by 10 wkts (21b rem),,Royal Challengers Bangalore,,[10], 47 | 1254072,2021-04-21T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Chennai Super Kings,Kolkata Knight Riders,Super Kings won by 18 runs,,Chennai Super Kings,runs,[18], 48 | 1254071,2021-04-21T10:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Punjab Kings,Sunrisers Hyderabad,Sunrisers won by 9 wkts (8b rem),,Sunrisers Hyderabad,,[9], 49 | 1254070,2021-04-20T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Mumbai Indians,Delhi Capitals,Capitals won by 6 wkts (5b rem),,Delhi Capitals,,[6], 50 | 1254069,2021-04-19T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Chennai Super Kings,Rajasthan Royals,Super Kings won by 45 runs,,Chennai Super Kings,runs,[45], 51 | 1254068,2021-04-18T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Punjab Kings,Delhi Capitals,Capitals won by 6 wkts (10b rem),,Delhi Capitals,,[6], 52 | 1254067,2021-04-18T10:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Royal Challengers Bangalore,Kolkata Knight Riders,RCB won by 38 runs,,Royal Challengers Bangalore,runs,[38], 53 | 1254066,2021-04-17T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Mumbai Indians,Sunrisers Hyderabad,Mum Indians won by 13 runs,,Mumbai Indians,runs,[13], 54 | 1254065,2021-04-16T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Punjab Kings,Chennai Super Kings,Super Kings won by 6 wkts (26b rem),,Chennai Super Kings,,[6], 55 | 1254064,2021-04-15T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Delhi Capitals,Rajasthan Royals,Royals won by 3 wkts (2b rem),,Rajasthan Royals,,[3], 56 | 1254063,2021-04-14T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Royal Challengers Bangalore,Sunrisers Hyderabad,RCB won by 6 runs,,Royal Challengers Bangalore,runs,[6], 57 | 1254062,2021-04-13T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Mumbai Indians,Kolkata Knight Riders,Mum Indians won by 10 runs,,Mumbai Indians,runs,[10], 58 | 1254061,2021-04-12T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Punjab Kings,Rajasthan Royals,Punjab Kings won by 4 runs,,Punjab Kings,runs,[4], 59 | 1254060,2021-04-11T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Kolkata Knight Riders,Sunrisers Hyderabad,KKR won by 10 runs,,Kolkata Knight Riders,runs,[10], 60 | 1254059,2021-04-10T14:00Z,2021,"Wankhede Stadium, Mumbai","Wankhede Stadium, Mumbai",Chennai Super Kings,Delhi Capitals,Capitals won by 7 wkts (8b rem),,Delhi Capitals,,[7], 61 | 1254058,2021-04-09T14:00Z,2021,"MA Chidambaram Stadium, Chepauk, Chennai","MA Chidambaram Stadium, Chepauk, Chennai",Mumbai Indians,Royal Challengers Bangalore,RCB won by 2 wkts (0b rem),,Royal Challengers Bangalore,,[2], 62 | -------------------------------------------------------------------------------- /MatchDataParsing.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from lxml import html 3 | import json 4 | import pandas as pd 5 | import os 6 | from bs4 import BeautifulSoup 7 | import re 8 | 9 | 10 | 11 | # matchids = {"ipl14":range(729279,734050), "ipl15": range(829705,829824), "ipl16" : range(980901,981020), 12 | # "ipl17":range(1082591,1082650), "ipl18" : range(1136561,1136621), "ipl19": range(1175356,1175368) } 13 | 14 | headers = { 15 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36', 16 | "Upgrade-Insecure-Requests": "1", "DNT": "1", 17 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", 18 | "Accept-Encoding": "gzip, deflate"} 19 | 20 | 21 | def parse_commentary_to_data( data, page, eventid, inning, ipl): 22 | 23 | print ("Parsing the data now to fetch relevant information") 24 | five_ball_summary = pd.DataFrame(columns=['ipl_season','sequence', 'eventid', 'innings', 'target', 'remainingballs', 'homescore', 'awayscore', 'fallofwickets', 'ball', 'over', 'scorevalue', 'validball', 'extras', 'dismissal', 'dismissaltype', 'batsmanid', 'batsman', 'batsmanteam', 'bowlerid', 'bowler', 'bowlerteam', 'otherathleteinvolvedid', 'otherathleteinvolved', 'nonstrikerid', 'nonstriker', 'runs', 'runrate']) 25 | 26 | for x in data['commentary']['items']: 27 | 28 | print (x) 29 | if not x: 30 | print ("there is no data in this "+ str(page)+ " and inning "+str(inning)) 31 | break 32 | else: 33 | print ("entered to add rows") 34 | dict = {} 35 | ipl_season = ipl 36 | sequence = x['sequence'] 37 | eventid = eventid 38 | innings = x['periodText'] 39 | ball = x['innings']['balls'] 40 | over = x['over']['overs'] 41 | scorevalue = x['scoreValue'] 42 | validball = x['over']['noBall'] + x['over']['wide'] 43 | extras = x['over']['noBall'] + x['over']['wide'] + x['over']['byes'] + x['innings']['legByes'] 44 | dismissal = x['dismissal']['dismissal'] 45 | dismissaltype = x['dismissal']['type'] 46 | batsmanid = x['batsman']['athlete']['id'] 47 | batsman = x['batsman']['athlete']['name'] 48 | batsmanteam = x['batsman']['team']['name'] 49 | bowlerid = x['bowler']['athlete']['id'] 50 | bowler = x['bowler']['athlete']['name'] 51 | bowlerteam = x['bowler']['team']['name'] 52 | if dismissal == 1: 53 | otherathleteinvolvedid = x['athletesInvolved'][0]['id'] 54 | otherathleteinvolved = x['athletesInvolved'][0]['name'] 55 | else: 56 | otherathleteinvolvedid = '' 57 | otherathleteinvolved = '' 58 | nonstrikerid = x['otherBatsman']['athlete']['id'] 59 | nonstriker = x['otherBatsman']['athlete']['name'] 60 | runs = x['innings']['totalRuns'] 61 | fallofwickets = x['innings']['fallOfWickets'] 62 | runrate = x['innings']['runRate'] 63 | target = x['innings']['target'] 64 | remainingballs = x['innings']['remainingBalls'] 65 | homescore = x['homeScore'] 66 | awayscore = x['awayScore'] 67 | dict = {'ipl_season':ipl_season, 'sequence': sequence, 'eventid': eventid, 'innings': innings, 68 | 'target': target, 'remainingballs': remainingballs, 'homescore': homescore, 69 | 'awayscore': awayscore, 70 | 'fallofwickets': fallofwickets, 'ball': ball, 'over': over, 'scorevalue': scorevalue, 71 | 'validball': validball, 72 | 'extras': extras, 'dismissal': dismissal, 'dismissaltype': dismissaltype, 73 | 'batsmanid': batsmanid, 'batsman': batsman, 'batsmanteam': batsmanteam, 74 | 'bowlerid': bowlerid, 'bowler': bowler, 'bowlerteam': bowlerteam, 75 | 'otherathleteinvolvedid': otherathleteinvolvedid, 76 | 'otherathleteinvolved': otherathleteinvolved, 77 | 'nonstrikerid': nonstrikerid, 'nonstriker': nonstriker, 78 | 'runs': runs, 'runrate': runrate 79 | } 80 | print("Dictionary from this page is :" + str(dict)) 81 | five_ball_summary = five_ball_summary.append( dict , ignore_index=True) 82 | # print (df.head()) 83 | # Hypothesis 1 = runrate and balls completed should be somewhat related with the required run rate, 84 | # so cant use these 2 data simultaneously 85 | return five_ball_summary 86 | 87 | 88 | def hit_api(tournamentid, eventid,ipl): 89 | print('Downloading data for eventid : ' + str(eventid)) 90 | matchdata = pd.DataFrame() 91 | 92 | for inning in range(1, 3): 93 | print('Downloading data for inning : ' + str(inning)) 94 | # This loop should be increased to range(1,5) for test matches 95 | try: 96 | for j in range(1, 8): 97 | # Will need a better mechanism to see how many pages of data needs to be present for ODIs and 98 | # test matches 99 | page = j 100 | URL = 'https://site.web.api.espn.com/apis/site/v2/sports/cricket/' + str( 101 | tournamentid) + '/playbyplay?contentorigin=espn&event=' + str(eventid) + '&page=' + str( 102 | page) + '&period=' + str(inning) + '§ion=cricinfo' 103 | # print (URL) 104 | response = requests.get(URL, headers=headers) 105 | data = json.loads(response.text) 106 | print (len(data['commentary']['items'])) 107 | five_ball_summary = parse_commentary_to_data(data, page, eventid, inning,ipl) 108 | # print (parse_commentary_to_data(data, page, eventid, inning,ipl)) 109 | # print (five_ball_summary.head()) 110 | matchdata = matchdata.append(five_ball_summary) 111 | 112 | except: 113 | print ("caught an exception while downloading data for below :") 114 | print(URL) 115 | return matchdata 116 | 117 | 118 | def get_data_for_event(tournamentid, eventid,ipl): 119 | fullpath = os.path.join(directory, str(eventid) + '.csv') 120 | if not os.path.isfile(fullpath): 121 | matchdata = hit_api(tournamentid, eventid,ipl) 122 | matchdata.to_csv(fullpath, index=False, header=True) 123 | else: 124 | 125 | print (fullpath) 126 | 127 | print (os.stat(fullpath).st_size == 0) 128 | 129 | try : 130 | old_data = pd.read_csv(fullpath) 131 | 132 | print(old_data.empty) 133 | if old_data.empty: 134 | # if file is present but is empty 135 | matchdata = hit_api(tournamentid, eventid, ipl) 136 | with open(fullpath, 'w') as f: 137 | matchdata.to_csv(f, header=True, index=False) 138 | else: 139 | 140 | print('Old Data is present till {} , and innings : {}'.format(str(old_data.iloc[-1].iloc[9]), 141 | str(old_data.iloc[-1].iloc[2]))) 142 | if str(old_data.iloc[-1].iloc[9]) == '19.6' and str(old_data.iloc[-1].iloc[2]) == '2nd innings' and str( 143 | old_data.iloc[-1].iloc[9]) == '0.1': 144 | print('data for {} eventid is already present'.format(str(eventid))) 145 | pass 146 | else: 147 | matchdata = hit_api(tournamentid, eventid, ipl) 148 | with open(fullpath, 'w') as f: 149 | matchdata.to_csv(f, header=True, index=False) 150 | except: 151 | print(" old data is null file, fetching it again") 152 | matchdata = hit_api(tournamentid, eventid , ipl) 153 | print(matchdata.head()) 154 | with open(fullpath, 'w') as f: 155 | matchdata.to_csv(f, header=True, index=False) 156 | 157 | print ("Added data for " +str(eventid)) 158 | 159 | 160 | def get_match_summary(IPL_Series): 161 | summarycolnames = ('ipl', 'date', 'matchid', 'inningsinfo1', 'inningsinfo2', 'matchstatus','commentary_link') 162 | # summarycolnames = ('ipl','date','matchid','typeofmatch', 163 | # 'firstteam','firstteamscore','secondteam','secondteamscore','matchstatus') 164 | 165 | matchlist = pd.DataFrame(columns=summarycolnames) 166 | 167 | for key in IPL_Series.keys(): 168 | # print(IPL_Series[key]) 169 | response = requests.get(IPL_Series[key], headers=headers) 170 | # print(response.text) 171 | soup = BeautifulSoup(response.text, 'html.parser') 172 | ipl = key 173 | 174 | matchinformation = soup.find_all(class_='default-match-block') 175 | print (ipl) 176 | 177 | for matchblock in matchinformation: 178 | # print(matchblock) 179 | soup2 = BeautifulSoup(str(matchblock), 'html.parser') 180 | innings_info_1 = soup2.find(class_='innings-info-1').text.strip() 181 | innings_info_2 = soup2.find(class_='innings-info-2').text.strip() 182 | date = soup2.find('span', attrs={'class': 'bold'}).text.strip() 183 | matchstatus = soup2.find(class_='match-status').text.strip() 184 | link = soup2.find_all(href=True)[0]['href'] 185 | matchid = link.split('/')[6] 186 | commentary_link = link.replace("scorecard", "commentary") 187 | matchlist = matchlist.append( 188 | {'ipl': str(ipl), 'date': str(date), 'eventid': str(matchid), 'inningsinfo1': str(innings_info_1), 189 | 'inningsinfo2': str(innings_info_2), 'matchstatus': str(matchstatus) ,'commentary_link' : str(commentary_link)}, ignore_index=True) 190 | # print (matchlist.head()) 191 | 192 | return matchlist 193 | 194 | 195 | # To find IPL 14 Matches 196 | ipl14 = 'http://www.espncricinfo.com/indian-premier-league-2014/engine/match/index/series.html?series=8827' 197 | ipl15 = 'http://www.espncricinfo.com/indian-premier-league-2015/engine/match/index/series.html?series=9657' 198 | ipl16 = 'http://www.espncricinfo.com/indian-premier-league-2016/engine/match/index/series.html?series=11001' 199 | ipl17 = 'http://www.espncricinfo.com/indian-premier-league-2017/engine/match/index/series.html?series=11701' 200 | ipl18 = 'http://www.espncricinfo.com/ci/engine/match/index/series.html?series=12210' 201 | ipl19 = 'http://www.espncricinfo.com/ci/engine/match/index/series.html?series=12741' 202 | 203 | 204 | 205 | IPL_Series = { 206 | # 'ipl14': ipl14, 207 | # 'ipl15': ipl15, 208 | # 'ipl16': ipl16, 209 | # 'ipl17': ipl17, 210 | # 'ipl18': ipl18, 211 | 'ipl19': ipl19 212 | } 213 | 214 | 215 | 216 | 217 | if __name__ == '__main__': 218 | 219 | tournamentid = 8048 220 | path_to_dir = os.getcwd() 221 | folderloc = os.path.join(os.getcwd(), 'IPL') 222 | directory = os.path.join(folderloc, str(tournamentid)) 223 | 224 | 225 | if not os.path.exists(directory): 226 | os.makedirs(directory) 227 | else: 228 | os.chdir(directory) 229 | 230 | # 231 | # matchlist = get_match_summary(IPL_Series) 232 | # print(matchlist.info()) 233 | 234 | # matchlist.to_csv('IPLMatchSummary.csv', index=False, header=True) 235 | 236 | matchsummary = pd.read_csv(directory+'/IPLMatchSummary.csv') 237 | # print (matchsummary.head()) 238 | 239 | 240 | def download_event(eventid) : 241 | 242 | print (matchsummary.loc[matchsummary['eventid']==eventid,'ipl'].values[0]) 243 | get_data_for_event(tournamentid, eventid,matchsummary.loc[matchsummary['eventid']==eventid,'ipl'].values[0]) 244 | 245 | # download_event (1178409) 246 | 247 | # pd.read_csv("/Users/madhavg/Documents/GitHub/Laptop/game_simulation/IPL/8048/729281.csv").head() 248 | 249 | for row, data in matchsummary.iterrows(): 250 | if data['ipl']=='ipl19': 251 | print (row) 252 | eventid = data['eventid'] 253 | print ("downloading data for " +str(eventid)) 254 | get_data_for_event(tournamentid, eventid,matchsummary.loc[matchsummary['eventid']==eventid,'ipl'].values[0]) 255 | 256 | 257 | 258 | # 259 | # Next Steps : 260 | # Create Features for Understanding Situations 261 | # Learn matplotlib doing these things 262 | # Create heatmaps 263 | # 264 | # Find Features and PCA -------------------------------------------------------------------------------- /point_prediction.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | from scipy import stats 4 | from xgboost.sklearn import XGBRegressor 5 | from catboost import CatBoostRegressor 6 | from sklearn.model_selection import GridSearchCV, RandomizedSearchCV 7 | from sklearn.ensemble import RandomForestRegressor 8 | from sklearn.preprocessing import StandardScaler 9 | from pmdarima.arima import auto_arima, ADFTest 10 | import category_encoders as ce 11 | import time 12 | from sklearn.linear_model import LinearRegression 13 | import pickle 14 | import statsmodels.api as sm 15 | 16 | 17 | # TODO Add hyperopt method to optimize 18 | class ModelTrain: 19 | 20 | def __init__(self, masterdf, target_col, predictors, cat_cols, modelname): 21 | self.target_col = target_col 22 | self.masterdf = masterdf 23 | self.num_round = 300 24 | self.cv_folds = 5 25 | self.cat_cols = cat_cols 26 | self.predictors = predictors 27 | self.modelname = modelname 28 | return 29 | def get_test_train(self, split_col=None, split_value=None): 30 | """ 31 | 32 | :return: 33 | """ 34 | 35 | if (split_col is None) or (split_value is None): 36 | self.train_data = self.masterdf 37 | return 38 | self.train_data = self.masterdf[~self.masterdf[split_col].isin(split_value)] 39 | self.test_data = self.masterdf[self.masterdf[split_col].isin(split_value)] 40 | return 41 | 42 | def get_normalized_data(self): 43 | """ 44 | 45 | :return: 46 | """ 47 | master_target_df = self.masterdf[[self.target_col, 'year']] 48 | num_cols = [x for x in self.predictors if x not in self.cat_cols] 49 | master_numcols_df = self.masterdf[num_cols] 50 | # Standardize numerical values 51 | # Create scale object 52 | self.scaler = StandardScaler() 53 | master_numcols = self.scaler.fit_transform(master_numcols_df.values) 54 | master_numcols = pd.DataFrame(master_numcols, index=master_numcols_df.index, columns=master_numcols_df.columns) 55 | # Convert categorical columns using OneHotEncoding 56 | master_catcols = self.masterdf[self.cat_cols] 57 | if self.modelname == 'catboost': 58 | self.enc = "" 59 | self.masterdf = master_catcols.join(master_numcols) 60 | else: 61 | self.enc = ce.OneHotEncoder(cols=self.cat_cols, return_df=True).fit(master_catcols) 62 | train_catcols = self.enc.transform(master_catcols) 63 | self.masterdf = train_catcols.join(master_numcols) 64 | 65 | self.masterdf = self.masterdf.join(master_target_df) 66 | self.predictors = [x for x in self.predictors if x not in self.cat_cols] 67 | self.predictors.extend(master_catcols.columns.tolist()) 68 | return 69 | 70 | def define_xgb_model_params(self): 71 | self.xgb1 = XGBRegressor() 72 | parameters = {'nthread': [4], # when use hyperthread, xgboost may become slower 73 | 'objective': ['reg:squarederror'], 74 | 'learning_rate': stats.uniform(.03, .1), # so called `eta` value 75 | 'max_depth': [3, 5, 6, 7, 9], 76 | 'min_child_weight': [4], 77 | 'subsample': stats.uniform(0.5, 0.4), 78 | 'colsample_bytree': stats.uniform(0.5, 0.4), 79 | 'n_estimators': stats.randint(100, 500), 80 | 'gamma': [0.1, 0.5, 1, 1.5], 81 | 'lambda': [0.01, 0.5, 1, 2], 82 | 'seed': [1]} 83 | self.xgb_grid = RandomizedSearchCV(self.xgb1, 84 | parameters, 85 | cv=4, 86 | n_jobs=4, 87 | verbose=True, 88 | n_iter=100) 89 | return 90 | 91 | def define_random_forest_model(self): 92 | """ 93 | 94 | :return: 95 | """ 96 | parameters = {'criterion': ['mse'], 97 | 'max_depth': [5, 6, 7], 98 | 'min_samples_leaf': [5, 10], 99 | 'min_impurity_decrease': [.001, .005, 0.01], 100 | 'max_features': ["sqrt", "log2"], 101 | 'n_estimators': [100, 500], 102 | 'ccp_alpha': [0.01, 0.05, .1], 103 | 'random_state': [1]} 104 | self.rf = RandomForestRegressor() 105 | self.rf_grid = RandomizedSearchCV(self.rf, 106 | parameters, 107 | cv=4, 108 | n_jobs=4, 109 | verbose=True, 110 | n_iter=100) 111 | 112 | def define_catboost_model_params(self): 113 | self.cat1 = CatBoostRegressor() 114 | 115 | parameters = {'loss_function': ['RMSE'], 116 | 'depth': [4, 6, 8], 117 | 'cat_features': [self.cat_features_catboost], 118 | 'learning_rate': [0.01, 0.05, 0.1], 119 | 'iterations': [30, 100, 300, 1000], 120 | 'l2_leaf_reg': [.1, 1, 10, 100], 121 | 'early_stopping_rounds': [100], 122 | 'random_strength': [1], 123 | 'od_type': ['IncToDec'], 124 | 'random_seed': [1], 125 | 'use_best_model': [True]} 126 | 127 | 128 | self.cat_grid = GridSearchCV(estimator=self.cat1, 129 | param_grid=parameters, 130 | cv=4, 131 | n_jobs=4, 132 | verbose=False) 133 | 134 | return 135 | 136 | 137 | def train_model(self,model): 138 | """ 139 | 140 | :return: 141 | """ 142 | start = time.time() 143 | X = self.train_data[self.predictors] 144 | y = self.train_data[self.target_col] 145 | 146 | X_test = self.test_data[self.predictors] 147 | y_test = self.test_data[self.target_col] 148 | 149 | 150 | if model == 'xgb': 151 | self.define_xgb_model_params() 152 | model = self.xgb1 153 | model_grid = self.xgb_grid 154 | elif model == 'rf': 155 | self.define_random_forest_model() 156 | model = self.rf 157 | model_grid = self.rf_grid 158 | X = X.fillna(-100) 159 | elif model == 'catboost': 160 | self.cat_features_catboost = [X.columns.get_loc(col) for col in self.cat_cols] 161 | self.define_catboost_model_params() 162 | model = self.cat1 163 | model_grid = self.cat_grid 164 | else: 165 | print('Model selected is not available') 166 | return 167 | print("test Shape", X_test.shape) 168 | model_grid.fit(X, y, eval_set=(X_test, y_test)) 169 | model.set_params(**model_grid.best_params_) 170 | model.fit(X, y, eval_set=(X_test, y_test)) 171 | print(model_grid.best_score_) 172 | print(model_grid.best_params_) 173 | self.feat_imp_df = pd.DataFrame(zip(self.predictors, model_grid.best_estimator_.feature_importances_), columns=['feature_name', 'feature_importance']) 174 | print(self.feat_imp_df) 175 | end = time.time() 176 | # total time taken 177 | print(f"Runtime of the program is {(end - start)/60} mins") 178 | 179 | return self.enc, self.scaler, model 180 | 181 | 182 | @staticmethod 183 | def get_timeseries_forecast(masterdf, target_col, timeseries_col, pred_points): 184 | """ 185 | 186 | :return: 187 | """ 188 | start = time.time() 189 | timeseries_key_list = masterdf[timeseries_col].unique() 190 | prediction = pd.DataFrame(columns=[pred_points]) 191 | for key in timeseries_key_list: 192 | print(key) 193 | ts_series = masterdf[masterdf[timeseries_col] == key][target_col] 194 | MIN_LEN = 5 195 | PRED_PERIOD = 5 196 | start_len = 0 197 | end_len = MIN_LEN 198 | if len(ts_series) < MIN_LEN: 199 | prediction = prediction.append(pd.DataFrame(pd.Series(np.nan), ts_series.index, columns=[pred_points])) 200 | print('Failure') 201 | else: 202 | i = 1 203 | prediction = prediction.append(pd.DataFrame(pd.Series(np.nan), index=ts_series[:end_len].index, columns=[pred_points])) 204 | while i > 0: 205 | train = ts_series[start_len:end_len] 206 | arima_model = auto_arima(train, random_state=1, suppress_warnings=True) 207 | if len(ts_series) - len(ts_series[:end_len]) > PRED_PERIOD: 208 | test = ts_series[end_len: end_len + PRED_PERIOD] 209 | pred = arima_model.predict(n_periods=PRED_PERIOD) 210 | prediction = prediction.append(pd.DataFrame(pred, index=test.index, columns=[pred_points])) 211 | if (len(ts_series) - len(train) >= 15): 212 | start_len = start_len + 5 213 | end_len = end_len + PRED_PERIOD 214 | else: 215 | test = ts_series[end_len-1:] 216 | pred = arima_model.predict(n_periods=len(test)) 217 | prediction = prediction.append(pd.DataFrame(pred, index=test.index, columns=[pred_points])) 218 | i = 0 219 | print("Success") 220 | end = time.time() 221 | # total time taken 222 | print(f"Runtime of the program is {(end - start)/60} mins") 223 | return prediction 224 | 225 | 226 | class ModelPredict: 227 | 228 | def __init__(self, masterdf, enc, model, modelname, predictors, cat_cols, points_pred_col): 229 | self.masterdf = masterdf 230 | self.enc = enc 231 | self.model = model 232 | self.points_pred_col = points_pred_col 233 | self.cat_cols = cat_cols 234 | self.predictors = predictors 235 | self.modelname = modelname 236 | 237 | def get_normalized_data(self): 238 | """ 239 | 240 | :return: 241 | """ 242 | 243 | master_catcols = self.masterdf[self.cat_cols] 244 | if (self.modelname == 'xgb') or (self.modelname == 'rf'): 245 | master_catcols = self.enc[0].transform(master_catcols) 246 | num_cols = [x for x in self.predictors if x not in self.cat_cols] 247 | master_numcols_df = self.masterdf[num_cols] 248 | master_numcols = self.enc[1].transform(master_numcols_df.values) 249 | master_numcols = pd.DataFrame(master_numcols, index=master_numcols_df.index, columns=master_numcols_df.columns) 250 | self.masterdf = pd.concat([master_numcols, master_catcols], axis=1) 251 | self.predictors = [x for x in self.predictors if x not in self.cat_cols] 252 | self.predictors.extend(master_catcols.columns.tolist()) 253 | return 254 | 255 | def get_model_predictions(self): 256 | """ 257 | 258 | :return: 259 | """ 260 | 261 | masterdf = self.masterdf[self.predictors] 262 | prediction_value = self.model.predict(masterdf) 263 | return prediction_value 264 | 265 | @staticmethod 266 | def get_model_error(masterdf, pred_col, target_col, groupbycol=None): 267 | """ 268 | , 269 | :param self: 270 | :return: 271 | """ 272 | # predictions_error = metrics.mean_absolute_error(masterdf[target_col].values, masterdf[pred_col].values) 273 | masterdf[target_col].fillna(0, inplace=True) 274 | masterdf['error'] = np.where((np.isnan(masterdf[pred_col])), np.nan, abs(masterdf[target_col] - masterdf[pred_col])) 275 | predictions_error = abs(masterdf['error']).mean() 276 | if groupbycol != None: 277 | yearly_summary = pd.DataFrame(masterdf.groupby([groupbycol])[['error']].mean()).reset_index() 278 | else: 279 | yearly_summary = None 280 | return predictions_error, yearly_summary 281 | 282 | class EnsembleModel(): 283 | 284 | def get_ensemble_model_train(self, masterdf, featurelist, target_col, predcol, modelpath): 285 | """ function to get ensemble model results 286 | 287 | :return: 288 | """ 289 | masterdf = masterdf.dropna() 290 | X = masterdf[featurelist] 291 | y = masterdf[target_col] 292 | reg = sm.OLS(y, X).fit() 293 | print(reg.summary()) 294 | print(f"R^2: {reg.rsquared}, coefficient {reg.params}") 295 | masterdf[predcol] = reg.fittedvalues 296 | pickle.dump(reg, open(modelpath, 'wb')) 297 | return masterdf[predcol] 298 | 299 | def get_ensemble_model_pred(self, datapath, masterdf, featurelist, pred_col): 300 | """ function to get ensemble model results 301 | 302 | :return: 303 | """ 304 | modelpkl = pickle.load(open(datapath['modelpath'], 'rb')) 305 | print('modelpkl', modelpkl) 306 | print("ensemble featurelist", featurelist) 307 | X = masterdf[featurelist] 308 | masterdf[pred_col] = modelpkl.predict(X) 309 | print(masterdf) 310 | masterdf.to_csv(datapath['modelresultspath'], index=False) 311 | return 312 | -------------------------------------------------------------------------------- /controller.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from main import * 3 | from send_email import send_email_team 4 | from point_prediction import EnsembleModel 5 | import os 6 | cwd = os.getcwd() 7 | 8 | if __name__ == "__main__": 9 | # Season Year 10 | YEAR = 2021 11 | # reading the source file from local 12 | matchdatapath = r'Data/matchdata.csv' 13 | matchsummarypath = r'Data/matchsummary.csv' 14 | # points as per dream11 website 15 | pointsconfig = { 16 | 'total_runs': 1, 17 | 'run_6': 2, 18 | 'run_4': 1, 19 | '>=50': 8, 20 | '>=100': 16, 21 | 'duck': -2, 22 | 'total_wickets': 25, 23 | '>=4W': 8, 24 | '>=5W': 16, 25 | 'maiden_overs': 8, 26 | '<=4E': 6, 27 | '<5E': 4, 28 | '<6E': 2, 29 | '>9E': -2, 30 | '>10E': -4, 31 | '>11E': -6 32 | } 33 | # rewards as per the result of one of the matches on dream11 34 | rewardconfig = { 35 | '1per': 5000, # 10000 36 | '2per': 3000, # 6000 37 | '3per': 500, # 500 38 | '4per': 200, 39 | '5per': 100, 40 | '6per': 80, 41 | '8per': 20, 42 | '10per': 8, 43 | '15per': 2.5, 44 | '20per': 2, 45 | '25per': 1 46 | } 47 | 48 | constconfig = {'MAXCOSTPOINT': 100, 49 | 'MINBATSMEN': 3, 50 | 'MAXBATSMEN': 7, 51 | 'MINBOWLER': 3, 52 | 'MAXBOWLER': 6, 53 | 'MINALLROUNDER': 1, 54 | 'MAXALLROUNDER': 4, 55 | 'MAXPLAYERCOUNT': 11, 56 | 'MAXTEAMCOUNT': 7} 57 | 58 | colconfig = {'MATCHID': 'matchid', 59 | 'BATSMANNAME': 'batsmanname', 60 | 'BOWLERNAME': 'bowlername', 61 | 'SCOREVALUE': 'scorevalue', 62 | 'OVER': 'over', 63 | 'INNINGS': 'innings', 64 | 'VENUE': 'venue', 65 | 'TOTALBALLSBOWLED': 'total_balls_bowled', 66 | 'BATTINGORDER': 'fallofwickets', 67 | 'BATTINGTEAM': 'battingteam', 68 | 'BOWLINGTEAM': 'bowlingteam', 69 | 'PLAYERNAME': 'playername', 70 | 'TOTALBATPOINTS': 'total_bat_points', 71 | 'TOTALBALLPOINTS': 'total_bowl_points', 72 | 'ACTUALPOINTS': 'total_points', 73 | 'PREDPOINTS': 'pred_points', 74 | 'PLAYERTEAM':'playing_team', 75 | 'PLAYERCOST': 'playercost', 76 | 'PLAYINGROLE': 'playing_role', 77 | 'PREDSELECTION': 'pred_selection_true', 78 | 'ACTUALSELECTION': 'actual_selection_true', 79 | 'PREDSELECTIONRANK': 'pred_selection_rank', 80 | 'ACTUALSELECTIONRANK': 'actual_selection_rank'} 81 | 82 | predictors = ['playing_team', 'opposition_team', 'playing_role', 'city', 'home_game', 'toss_flag','player_match_count', 83 | 'fallofwickets_playername_avg2', 'total_balls_bowled_playername_avg2', 84 | 'total_bat_points_venue_avg2', 'total_bowl_points_venue_avg2', 'total_points_playername_avg2', 85 | 'total_points_playername_avg5', 'fallofwickets_playername_avg5', 'total_balls_bowled_playername_avg5', 86 | 'total_bat_points_venue_avg5', 'total_bowl_points_venue_avg5', 87 | 'fallofwickets_playername_avg10', 'total_balls_bowled_playername_avg10', 88 | 'total_bat_points_venue_avg10', 'total_bowl_points_venue_avg10', 'total_points_playername_avg10', 89 | ] 90 | 91 | cat_cols = ['playing_team', 'playing_role', 'opposition_team', 'city'] 92 | target_col = 'total_points' 93 | pred_col = 'pred_points' 94 | 95 | modelname = 'catboost' # Options include 'rf','xgb','catboost','movingaverage', 'ensemble' 96 | matchdatascorecardpath = r'Data/ipl_scorecard_points.csv' 97 | matchdatascorecardpathipl20 = r'ipl20/ipl_scorecard_points_ipl20.csv' 98 | featenggpath = r'Data/ipl_scorecard_points_featengg.csv' 99 | 100 | modelpath = r"Data/" + modelname + "_model.pkl" 101 | encoderpath = r"Data/OnHotEncoder_" + modelname + ".pkl" 102 | 103 | modelresultspath = r"Data/model_prediction.csv" 104 | predfeaturepath = r"Data/pred_data_features.csv" 105 | predscorecardpath = r"Data/pred_data_scorecard.csv" 106 | predsummarypath = r"Data/pred_data_summary.csv" 107 | nextmatchteampath = r"Data/pred_team11.csv" 108 | matchdatapathipl20 = r"ipl20/matchdata_v2.csv" 109 | matchdatascorecardpathipl20 = r"ipl20/matchdatascorecardpathipl20.csv" 110 | predscorecardpath =r'ipl20/matchscorecard.csv' 111 | 112 | matchsummarypathipl20 = r"ipl20/match_summary_ipl20.csv" 113 | iplcurrentsquad = r"Data/ipl_squad_points.csv" 114 | teampoints = r'Data/team_points.csv' 115 | rewardspath =r'Data/rewards_df.csv' 116 | yearlyrewardspath = r'Data/rewards_yearly_summary.csv' 117 | 118 | 119 | datapath = {'matchdatapath': matchdatapath, 120 | 'matchsummarypath': matchsummarypath, 121 | 'matchdatascorecardpath': matchdatascorecardpath, 122 | 'matchdatascorecardpathipl20': matchdatascorecardpathipl20, 123 | "matchdatapathipl20": matchdatapathipl20, 124 | "matchsummarypathipl20": matchsummarypathipl20, 125 | 'featenggpath': featenggpath, 126 | 'modelpath': modelpath, 127 | 'encoderpath': encoderpath, 128 | 'modelresultspath': modelresultspath, 129 | 'predscorecardpath': predscorecardpath, 130 | 'predsummarypath': predsummarypath, 131 | 'predfeaturepath': predfeaturepath, 132 | 'nextmatchteampath': nextmatchteampath, 133 | 'predscorecardpath': predscorecardpath, 134 | "iplcurrentsquad": iplcurrentsquad, 135 | "teampoints": teampoints, 136 | "rewardspath": rewardspath, 137 | 'yearlrewardspath': yearlyrewardspath} 138 | 139 | # Change the below to true to run the training of the models part of the permissible list 140 | TRAIN_MODEL = False 141 | # Change the below to true to run the prediction on the entire training dataset we have 142 | PREDICT_MODEL = False 143 | # Change the below to true to run the training for an ensemble model using predicitons from other model 144 | PREDICT_ENSEMBLE = False 145 | # Change the below to true to create the dataframe of the upcoming match and adjust anything if required 146 | SELECT_PLAYING_SQUAD = True 147 | # Change the below to true if the squad file is ready at predfeaturepath to run prediction for the team 148 | SELECT_CURRENT_TEAM = True 149 | # Change this to True if the current playing XI is available 150 | SELECT_FROM_PLAYING_XI = True 151 | # Change this to true to send email if the file fo next match is present at nextmatchteampath 152 | SEND_EMAIL = False 153 | sender_email = "abhishek.anand374@gmail.com" 154 | # add more emails to this by using "," seperator 155 | receiver_email = "madhavgoswami93@gmail.com," + "sainiabhi7734@gmail.com," + "rapidnehal@gmail.com," + "sandeepch@zeta.tech," + "mandalravi04@gmail.com," + "vikashkumar72741234@gmail.com" 156 | # config dor send_email 157 | modelnamelist = ['xgb', 'catboost', 'rf', 'movingaverage'] 158 | # modelnamelist = ['catboost'] 159 | # Run the below function to train the model 160 | # run this to update the master 161 | print("updating the masterdata") 162 | update_master_data(datapath, pointsconfig,YEAR) 163 | 164 | if TRAIN_MODEL: 165 | execute_get_scorecard(datapath["matchdatapath"], datapath['matchdatascorecardpath'], pointsconfig) # Run the function to to get points in the scorecard format 166 | execute_featureengg(datapath['matchdatascorecardpath'], datapath['matchsummarypath'], datapath['featenggpath'], colconfig) # Run the function to create features 167 | execute_model_train(datapath, modelname, predictors, cat_cols, target_col, usetimeseries=False) # Run the function to build the model 168 | 169 | # Run the below function to predict using the saved model on the complete dataset 170 | if PREDICT_MODEL: 171 | finalmodelpred = pd.read_csv(datapath['featenggpath']) 172 | finalmodelpred = finalmodelpred[['matchid', 'playername', 'playing_role', 'playing_team', 'playercost', 'total_points']] 173 | predcol_list = [] 174 | for modelname in modelnamelist: 175 | modelpath = r"Data/" + modelname + "_model.pkl" 176 | encoderpath = r"Data/OnHotEncoder_" + modelname + ".pkl" 177 | datapath['modelpath'] = modelpath 178 | datapath['encoderpath'] = encoderpath 179 | modelpred_df = execute_model_prediction(datapath, predictors, modelname, cat_cols, pred_col + '_' + modelname, usetimeseries=False) # Run the function to predict the points based on the model 180 | modelpred_df = modelpred_df[['matchid','playername', 'playing_role', 'playing_team', 'playercost', 'total_points',pred_col + '_' + modelname]] 181 | predcol_list.append(pred_col + '_' + modelname) 182 | print(f"prediction for model {modelname} is complete") 183 | finalmodelpred = pd.merge(finalmodelpred, modelpred_df, on=['matchid','playername', 'playing_role', 'playing_team', 'playercost', 'total_points'], how='left') 184 | 185 | if PREDICT_ENSEMBLE: 186 | EM = EnsembleModel() 187 | temp = EM.get_ensemble_model_train(finalmodelpred, predcol_list, target_col='total_points',predcol= pred_col, modelpath=r"Data/" + 'ensemble' + "_model.pkl") 188 | finalmodelpred = pd.merge(finalmodelpred, temp, left_index=True, right_index=True, how='left') 189 | else: 190 | finalmodelpred[pred_col] = finalmodelpred[pred_col + '_' + modelname] 191 | finalmodelpred.to_csv(datapath['modelresultspath'], index=False) 192 | execute_team_selection(datapath, constconfig, colconfig) # Run the function to only select the predicted playing 11 193 | execute_rewards_calcualtion(datapath, constconfig, colconfig, rewardconfig) # Run the function to estimate rewards if actual playing 11 is available 194 | # Attempts to automatically select the playing team details based on the most recent match lined up. 195 | # Run the below function to predict the best 11 for the upcoming match 196 | 197 | if SELECT_PLAYING_SQUAD: 198 | # run this to update the master 199 | # Change the values of team1, team2, city and venue depending on the match. 200 | # Enter the details of the current match/ 201 | TEAM1 = "Mumbai Indians" 202 | TEAM2 = "Royal Challengers Bangalore" 203 | VENUE = 'Dubai International Cricket Stadium' 204 | print("creating pred features dataframe") 205 | # Change the values of team1, team2, city and venue depending on the match. 206 | # Enter the details of the current match/ 207 | TEAM1 = "Mumbai Indians" 208 | TEAM2 = "Royal Challengers Bangalore" 209 | VENUE = 'Dubai International Cricket Stadium' 210 | CITY = 'neutral venue' 211 | # This overwrites the variables declared above. 212 | TEAM1, TEAM2, VENUE = get_team_details(datapath, index=0) 213 | print("Team1",TEAM1,"Team2", TEAM2,"Venue", VENUE) 214 | create_pred_dataframe_before_playing_XI(datapath, colconfig, TEAM1, TEAM2, CITY, VENUE, toss_winner=TEAM1) 215 | 216 | if SELECT_CURRENT_TEAM: 217 | if SELECT_FROM_PLAYING_XI: 218 | create_pred_dataframe_after_playing_XI(datapath) 219 | finalteam = pd.DataFrame() 220 | predcol_list = [] 221 | print("Calculation for best XI started") 222 | for modelname in ['catboost', 'xgb', 'rf', 'movingaverage', 'ensemble']: # Keep ensemble in the end 223 | modelpath = r"Data/" + modelname + "_model.pkl" 224 | encoderpath = r"Data/OnHotEncoder_" + modelname + ".pkl" 225 | datapath['modelpath'] = modelpath 226 | datapath['encoderpath'] = encoderpath 227 | if modelname == 'ensemble': 228 | EnsembleModel().get_ensemble_model_pred(datapath, finalteam.copy(), predcol_list, pred_col) 229 | else: 230 | execute_model_prediction(datapath, predictors, modelname, cat_cols, pred_col, usetimeseries=False, predpath=True) 231 | teamtemp = execute_team_selection(datapath, constconfig, colconfig).team_points 232 | print("teamtemp1", teamtemp.iloc[:, 13:15]) 233 | teamtemp.sort_values(by=['matchid', 'pred_selection_true', 'pred_points', 'playername'], inplace=True, ascending=False) 234 | teamtemp.rename(columns={'pred_points': 'pred_points' + '_' + modelname, 'pred_selection_true': 'pred_selection_true' + '_' + modelname}, inplace=True) 235 | teamtemp = teamtemp[['matchid', 'playername', 'playing_role', 'playing_team', 'playercost', 'pred_points' + '_' + modelname, 'pred_selection_true' + '_' + modelname]] 236 | print("teamtemp2", teamtemp.iloc[:, 4:6]) 237 | predcol_list.append('pred_points' + '_' + modelname) 238 | if finalteam.shape[0] == 0: 239 | finalteam = teamtemp 240 | else: 241 | finalteam = pd.merge(finalteam, teamtemp, on=['matchid','playername', 'playing_role', 'playing_team','playercost'], how='left') 242 | 243 | finalteam.to_csv(cwd + r'\pred_team11_details.csv',index =False) 244 | finalteam = formatdata(finalteam) 245 | finalteam.to_csv(nextmatchteampath, index=False) 246 | if SEND_EMAIL: 247 | send_email_team(TEAM1, TEAM2, nextmatchteampath,sender_email,receiver_email ) 248 | 249 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from data_prep import ScoreCard, Dream11Points, FeatEngineering 2 | from optimized_selection import SelectPlayingTeam,RewardEstimate 3 | import pandas as pd 4 | import numpy as np 5 | import pickle 6 | from point_prediction import ModelTrain, ModelPredict 7 | from download_ipl20 import update_ipl20_master,get_current_squad 8 | from datetime import datetime 9 | import pytz 10 | 11 | ##################Part to create additional features for modeling####################################################### 12 | 13 | def execute_get_scorecard(matchdatapath, scorecardpath,pointsconfig): 14 | """ 15 | 16 | :return: 17 | """ 18 | # getting the scorecard from a batsmen's perspective 19 | matchdata = pd.read_csv(matchdatapath) 20 | ipl_scorecard = ScoreCard(matchdata) 21 | # merging both the batsmen and bowler's points to get a single view 22 | ipl_scorecard.merge_player_scorecard() 23 | # calculating the points scored by the players based on dream11 scoring method 24 | ipl_scorecard_points = Dream11Points(ipl_scorecard.ipl_merged_scorecard, pointsconfig) 25 | ipl_scorecard_points.get_batsmen_bowler_points() 26 | ipl_scorecard_points.player_scorecard.to_csv(scorecardpath,index = False) 27 | return ipl_scorecard_points.player_scorecard 28 | 29 | ##################Part to create additional features for modeling################################################### 30 | def execute_featureengg(matchdatascorecardpath,matchsummarypath, featenggpath,colconfig): 31 | """ 32 | 33 | :param matchdatascorecardpath: 34 | :param matchsummary: 35 | :param featenggpath: 36 | :return: 37 | """ 38 | points_df = pd.read_csv(matchdatascorecardpath) 39 | matchsummary = pd.read_csv(matchsummarypath) 40 | FeatEng = FeatEngineering(points_df, matchsummary.copy()) 41 | FeatEng.add_venue_info() 42 | FeatEng.add_homegame_flag() 43 | FeatEng.add_toss_info() 44 | FeatEng.add_player_match_count() 45 | 46 | rolling_window = [2, 3, 5, 10] 47 | for i in rolling_window: 48 | FeatEng.add_lagging_feat(colconfig['MATCHID'], colconfig['VENUE'], i, colconfig['TOTALBATPOINTS'], colconfig['TOTALBALLPOINTS']) 49 | FeatEng.add_lagging_feat(colconfig['MATCHID'], colconfig['PLAYERNAME'], i, colconfig['ACTUALPOINTS'], colconfig['BATTINGORDER'], colconfig['TOTALBALLSBOWLED']) 50 | # writing the featengg to save it 51 | # Temp till we get better alternate to cost of each player 52 | # FeatEng.ipl_features['playercost'] = 10 53 | FeatEng.ipl_features.to_csv(featenggpath, index=False) 54 | 55 | return FeatEng.ipl_features 56 | 57 | 58 | ##################Part to train the model ################################################# 59 | 60 | def execute_model_train(datapath,modelname, predictors, cat_cols, target_col, usetimeseries=False): 61 | """ 62 | 63 | :return: 64 | """ 65 | masterdf = pd.read_csv(datapath['featenggpath']) 66 | if usetimeseries: 67 | ts_prediction = ModelTrain.get_timeseries_forecast(masterdf, target_col, 'playername', 'ts_pred_points') 68 | masterdf = pd.merge(masterdf, ts_prediction, left_index=True, right_index=True, how='left') 69 | masterdf.to_csv(r'Data\time_series_output.csv', index=False) 70 | predictors = predictors + ['ts_pred_points'] 71 | if modelname == 'movingaverate': 72 | return 73 | modeltrain = ModelTrain(masterdf, target_col, predictors, cat_cols, modelname) 74 | modeltrain.get_normalized_data() 75 | modeltrain.get_test_train(split_col='year', split_value=[2019]) 76 | modelobjects = modeltrain.train_model(model=modelname) 77 | pickle.dump(modelobjects[2], open(datapath['modelpath'], 'wb')) 78 | pickle.dump(modelobjects[:2], open(datapath['encoderpath'], 'wb')) 79 | print(modeltrain.feat_imp_df) 80 | return 81 | 82 | 83 | def execute_model_prediction(datapath, predictors, modelname, cat_cols, pred_col, usetimeseries=False, predpath=False): 84 | """ 85 | 86 | :return: 87 | """ 88 | 89 | if predpath: 90 | masterdf = pd.read_csv(datapath['predfeaturepath']) 91 | else: 92 | masterdf = pd.read_csv(datapath['featenggpath']) 93 | 94 | if modelname == 'rf': 95 | masterdf.fillna(-100, inplace=True) 96 | 97 | if usetimeseries: 98 | predictors = predictors + ['ts_pred_points'] 99 | 100 | if modelname == 'movingaverage': 101 | masterdf[pred_col] = masterdf['total_points_playername_avg3'] 102 | masterdf.to_csv(datapath['modelresultspath'], index=False) 103 | return masterdf 104 | 105 | modelpkl = pickle.load(open(datapath['modelpath'], 'rb')) 106 | enc = pickle.load(open(datapath['encoderpath'], 'rb')) 107 | mod_predict = ModelPredict(masterdf, enc, modelpkl, modelname, predictors, cat_cols, pred_col) 108 | mod_predict.get_normalized_data() 109 | masterdf[pred_col] = mod_predict.get_model_predictions() 110 | masterdf.to_csv(datapath['modelresultspath'], index=False) 111 | return masterdf 112 | 113 | 114 | ##################Part to run the optimization to select the playing 11################################################# 115 | def execute_team_selection(datapath, constconfig, colconfig): 116 | """ 117 | 118 | :return: 119 | """ 120 | ipl_features = pd.read_csv(datapath['modelresultspath']) 121 | # selecting the 11 players from a team of 22 based on historic points average 122 | 123 | # get the team by running binary LP solver 124 | optimum_team = SelectPlayingTeam(ipl_features, constconfig, colconfig) 125 | # select Top11 based on the predicted points 126 | optimum_team.select_top11_players(pointscol=colconfig['PREDPOINTS'], selectioncol=colconfig['PREDSELECTION'], 127 | rankcol=colconfig['PREDSELECTIONRANK'], adjustcappoints=False) 128 | return optimum_team 129 | 130 | ##################Part to calculate the accuracy of the selected 11 if the actual 11 is available####################### 131 | def execute_rewards_calcualtion(datapath, constconfig, colconfig, rewardconfig): 132 | """ 133 | 134 | :return: 135 | """ 136 | matchdata = pd.read_csv(datapath['matchdatapath']) 137 | optimum_team = execute_team_selection(datapath, constconfig, colconfig) 138 | SQUADCOUNT = 11 139 | 140 | # select Top11 based on the actual points 141 | optimum_team.select_top11_players(pointscol=colconfig['ACTUALPOINTS'], selectioncol=colconfig['ACTUALSELECTION'], 142 | rankcol=colconfig['ACTUALSELECTIONRANK'], adjustcappoints=True) 143 | 144 | optimum_team.team_points.to_csv(datapath['teampoints'], index=False) 145 | # get the rewards estimate 146 | ipl_team_rewards = RewardEstimate(optimum_team.team_points, matchdata.copy()) 147 | 148 | # get the percentile of the predicted team vs actual tam 149 | ipl_team_rewards.compare_pred_vs_actual_points(minplayercount=SQUADCOUNT) 150 | 151 | # estimating the monetary impact of the project 152 | ipl_team_rewards.get_estimated_rewards(rewardconfig, fixed_multipler=50) 153 | ipl_team_rewards.total_match_points.to_csv(datapath['rewardspath'], index=False) 154 | 155 | # calculating a yearly summary of the model 156 | yearly_summary = ipl_team_rewards.get_rewards_summary() 157 | yearly_summary.to_csv(datapath['yearlrewardspath'], index=False) 158 | print(ipl_team_rewards.total_match_points['rewards_earned'].sum()) 159 | 160 | 161 | def create_pred_dataframe_before_playing_XI(datapath, colconfig, team1, team2, city, venue, toss_winner): 162 | """ 163 | 164 | :param team1: 165 | :param team2: 166 | :param city: 167 | :param venue: 168 | :return: 169 | """ 170 | matchdatatemp = pd.read_csv(datapath['matchdatascorecardpath']) 171 | matchsummary = pd.read_csv(datapath['matchsummarypath']) 172 | 173 | ipl_curr_squad = pd.read_csv(datapath['iplcurrentsquad']) 174 | ipl_curr_squad = ipl_curr_squad[ipl_curr_squad['playing_team'].isin([team1, team2])] 175 | 176 | ipl_curr_squad['opposition_team'] = np.where(ipl_curr_squad['playing_team'] == team1, team2, team1) 177 | ipl_curr_squad = ipl_curr_squad[['playername', 'playing_team', 'playing_role', 'opposition_team', 'playercost']] 178 | MATCHID = matchdatatemp['matchid'].max() + 1 179 | ipl_curr_squad['matchid'] = MATCHID 180 | print("after importing ipl squad") 181 | print(ipl_curr_squad) 182 | matchdatatemp = pd.concat([matchdatatemp, ipl_curr_squad], axis =0) 183 | matchdatatemp.to_csv(datapath['predscorecardpath'], index=False) 184 | summarydf = pd.DataFrame({"matchid": [MATCHID], "venue": [venue], "city": [city], "team1": [team1], "team2": [team2], 185 | "year": [2020], "toss_winner": [toss_winner]}) 186 | matchsummary_pred = pd.concat([matchsummary, summarydf], axis=0) 187 | matchsummary_pred.to_csv(datapath['predsummarypath'], index=False) 188 | matchdatafeatures = execute_featureengg(datapath['predscorecardpath'], datapath['predsummarypath'], datapath['predfeaturepath'], colconfig) 189 | matchdatafeatures = matchdatafeatures[matchdatafeatures['matchid'] == MATCHID] 190 | print("after running the feat engg function") 191 | print(matchdatafeatures[['playing_team','opposition_team']]) 192 | matchdatafeatures.to_csv(datapath['predfeaturepath'], index=False) 193 | print("Added pred features for the current match") 194 | return 195 | 196 | 197 | def create_pred_dataframe_after_playing_XI(datapath): 198 | """ 199 | 200 | :param datapath: 201 | :return: 202 | """ 203 | playing_squad = get_current_squad() 204 | print("shape of playing squad", playing_squad.shape) 205 | prefeaturedata = pd.read_csv(datapath['predfeaturepath']) 206 | team_list = prefeaturedata['playing_team'].unique() 207 | if playing_squad.shape[0] != 0: 208 | prefeaturedata = prefeaturedata[prefeaturedata['playername'].isin(playing_squad['playername'])] 209 | else: 210 | matchdatatemp = pd.read_csv(datapath['matchdatascorecardpath']) 211 | matchdatatemp['playing_team'] = np.where(pd.isnull(matchdatatemp['batsmen_innings']),matchdatatemp['bowler_bowlingteam'],matchdatatemp['batsmen_battingteam']) 212 | matchdatatemp2 = matchdatatemp[(matchdatatemp['playing_team'].isin(team_list))] 213 | matchid_rank = pd.DataFrame(matchdatatemp2[['matchid', 'playing_team']].groupby('playing_team')['matchid'].rank(ascending=False,method='dense'). 214 | reset_index().rename(columns={'matchid': 'rank'})) 215 | matchid_rank_list = matchid_rank[matchid_rank['rank'] <= 2]['index'].unique() 216 | matchdatatemp2 = matchdatatemp2[matchdatatemp2.index.isin(matchid_rank_list)][ 217 | ['playername', 'playing_team', 'playing_role', 'batsmen_innings', 'bowler_bowlingteam','batsmen_battingteam', 'batsmen_bowlingteam']] 218 | matchdatatemp2 = matchdatatemp2.drop_duplicates(subset=['playername', 'playing_team']) 219 | prefeaturedata = prefeaturedata[prefeaturedata['playername'].isin(matchdatatemp2['playername'])] 220 | prefeaturedata.to_csv(datapath['predfeaturepath'], index=False) 221 | print("preddatafeature updated with currently playing members") 222 | 223 | return 224 | 225 | 226 | def formatdata(finaloutdf): 227 | """ 228 | 229 | :param finaloutdf: 230 | :return: 231 | """ 232 | 233 | finaloutdf = finaloutdf[['playername','playing_team','playing_role','playercost','pred_points_catboost','pred_selection_true_catboost','pred_points_ensemble','pred_selection_true_ensemble']] 234 | finaloutdf.columns = ['playername','teamname','playingrole','playercost','model1_points','model1_team','model2_points','model2_team'] 235 | finaloutdf['model1_points'] = finaloutdf['model1_points'].apply(lambda x: round(x, 0)) 236 | finaloutdf['model2_points'] = finaloutdf['model2_points'].apply(lambda x: round(x, 0)) 237 | return finaloutdf 238 | 239 | def update_master_data(datapath,pointsconfig,year): 240 | matchdata_ipl20 = update_ipl20_master(year) 241 | matchdata = pd.read_csv(datapath['matchdatapath']) 242 | if matchdata_ipl20.shape[0] != 0: 243 | matchlistipl20 = matchdata_ipl20['matchid'].unique() 244 | matchlistoverall = matchdata['matchid'].unique() 245 | matchid_list = [i for i in matchlistipl20 if i not in matchlistoverall] 246 | if matchid_list: 247 | matchdata_ipl20_sub = matchdata_ipl20[matchdata_ipl20['matchid'].isin(matchid_list)] 248 | matchdata = pd.concat([matchdata, matchdata_ipl20_sub], join='inner', axis=0) 249 | matchdata.to_csv(datapath['matchdatapath'], index=False) 250 | 251 | # update scorecard 252 | master_scorecard = pd.read_csv(datapath['matchdatascorecardpath']) 253 | matchlistipl20 = matchdata_ipl20['matchid'].unique() 254 | matchlistoverall = master_scorecard['matchid'].unique() 255 | matchid_list = [i for i in matchlistipl20 if i not in matchlistoverall] 256 | if matchid_list: 257 | matchdata_ipl20_sub = matchdata_ipl20[matchdata_ipl20['matchid'].isin(matchid_list)] 258 | matchdata_ipl20_sub.to_csv(datapath['matchdatapathipl20'], index=False) 259 | sorecard_sub = execute_get_scorecard(datapath['matchdatapathipl20'], datapath['matchdatascorecardpathipl20'], pointsconfig) 260 | master_scorecard = pd.concat([master_scorecard, sorecard_sub], join='inner', axis=0) 261 | print(master_scorecard.columns) 262 | master_scorecard.to_csv(datapath['matchdatascorecardpath'], index=False) 263 | print("matchscorecard updated complete") 264 | 265 | matchsummary_ipl20 = pd.read_csv(datapath['matchsummarypathipl20']) 266 | matchsummary_ipl20 = matchsummary_ipl20[~(matchsummary_ipl20['winner'] == "Match Tied/Cancelled/Not yet ended")] 267 | matchsummary = pd.read_csv(datapath['matchsummarypath']) 268 | matchlistipl20 = matchsummary_ipl20['matchid'].unique() 269 | matchlistoverall = matchsummary['matchid'].unique() 270 | matchid_list = [i for i in matchlistipl20 if i not in matchlistoverall] 271 | print(matchid_list) 272 | if matchid_list: 273 | print("start of match summary updation") 274 | matchsum_ipl20_sub = matchsummary_ipl20[matchsummary_ipl20['matchid'].isin(matchid_list)] 275 | print(matchsum_ipl20_sub.columns) 276 | print(matchsummary.columns) 277 | matchsummary = pd.concat([matchsummary, matchsum_ipl20_sub],axis=0) 278 | matchsummary.to_csv(datapath['matchsummarypath'], index=False) 279 | print("matchsummary updated complete") 280 | 281 | return matchdata 282 | 283 | 284 | 285 | def get_team_details(datapath,index =0): 286 | 287 | tz_dubai = pytz.timezone('Asia/Dubai') 288 | datetime_dubai = datetime.now(tz_dubai) 289 | matchsummary = pd.read_csv(datapath['matchsummarypathipl20']) 290 | matchid = matchsummary.iloc[next(x[0] for x in enumerate(pd.to_datetime(matchsummary['date']).tolist()) if x[1] > datetime_dubai), 0] 291 | today_match = matchsummary[matchsummary['matchid'] == matchid] 292 | print(today_match) 293 | team1 = today_match['team1'].iloc[index] 294 | team2 = today_match['team2'].iloc[index] 295 | venue = today_match['venue'].iloc[index].split(",")[index] 296 | return team1, team2, venue -------------------------------------------------------------------------------- /data_prep.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | 4 | class ScoreCard: 5 | 6 | def __init__(self, matchdata): 7 | self.matchdata = matchdata 8 | self.matchdata['batsmanname'] = self.matchdata['batsmanname'].str.replace('-', ' ') 9 | self.matchdata['bowlername'] = self.matchdata['bowlername'].str.replace('-', ' ') 10 | self.matchdata['over_num'] = self.matchdata['over'].apply(lambda x: int(x)) 11 | return 12 | 13 | def batsmen_summary_fun(self) -> None: 14 | """ 15 | matchdata: pandas dataframe of ball by ball data for the matches 16 | return: batsmen_summary: pandas datarame with summary scorecard of a batsmen 17 | """ 18 | batsmen_score = pd.DataFrame(self.matchdata.groupby(['matchid', 'batsmanname'])['scorevalue'].sum()).\ 19 | rename(columns={"scorevalue": "total_runs"}) 20 | batsmen_ball_faced = pd.DataFrame(self.matchdata.groupby(['matchid', 'batsmanname'])['over'].count()).\ 21 | rename(columns={"over": "total_balls_faced"}) 22 | batsmen_ball_faced_legal = pd.DataFrame(self.matchdata.groupby(['matchid', 'batsmanname'])['over'].nunique()).\ 23 | rename(columns={"over": "total_legal_balls_faced"}) 24 | batsmen_scores6 = pd.DataFrame(self.matchdata[self.matchdata['scorevalue'] == 6].groupby(['matchid', 'batsmanname'])['scorevalue'].count()).\ 25 | rename(columns={"scorevalue": "run_6"}) 26 | batsmen_scores4 = pd.DataFrame(self.matchdata[self.matchdata['scorevalue'] == 4].groupby(['matchid', 'batsmanname'])['scorevalue'].count()).\ 27 | rename(columns={"scorevalue": "run_4"}) 28 | batsmen_position = pd.DataFrame(self.matchdata.groupby(['matchid', 'batsmanname'])['fallofwickets'].min()) 29 | df_list = [batsmen_score, batsmen_ball_faced, batsmen_ball_faced_legal, batsmen_scores6, batsmen_scores4, batsmen_position] 30 | batsmen_summary = pd.concat(df_list, join='outer', axis=1).fillna(np.nan).reset_index() 31 | batsmen_summary = pd.merge(batsmen_summary, self.matchdata[['matchid', 'batsmanname', 'innings', 'battingteam', 'bowlingteam']]. 32 | drop_duplicates(), on=['matchid', 'batsmanname'], how='left') 33 | batsmen_summary.rename(columns={'innings': 'batsmen_innings', 'batsmanname': 'playername', 'battingteam': 'batsmen_battingteam', 34 | 'bowlingteam': 'batsmen_bowlingteam'}, inplace=True) 35 | self.batsmen_summary = batsmen_summary 36 | return 37 | 38 | def bowler_summary_fun(self) -> None: 39 | """ 40 | matchdata: pandas dataframe of ball by ball data for the matches 41 | 42 | return: bowler_summary: pandas datarame with summary scorecard of a bowler 43 | """ 44 | bowler_wickets = pd.DataFrame(self.matchdata[(((self.matchdata['dismissal'] == 't') | (self.matchdata['dismissal'] == True)) & (~self.matchdata['dismissedtype'].isin(['run out','retired hurt'])))]. 45 | groupby(['matchid', 'bowlername'])['dismissal'].count()).\ 46 | rename(columns={"dismissal": "total_wickets"}) 47 | bowler_overs_bow = pd.DataFrame(self.matchdata.groupby(['matchid', 'bowlername'])['over'].count()).\ 48 | rename(columns={"over": "total_balls_bowled"}) 49 | bowler_ball_faced_legal = pd.DataFrame(self.matchdata.groupby(['matchid', 'bowlername'])['over'].nunique()).\ 50 | rename(columns={"over": "total_legal_balls_bowled"}) 51 | # calculating the number of maiden overs bowled in a match 52 | bowler_runs_given = pd.DataFrame(self.matchdata.groupby(['matchid', 'bowlername'])['batsmanscorevalue'].sum()).\ 53 | rename(columns={"batsmanscorevalue": "total_runs_given"}) 54 | matchdata_runs_per_over = pd.DataFrame(self.matchdata.groupby(['matchid', 'bowlername', 'over_num'])['batsmanscorevalue'].sum()).reset_index() 55 | matchdata_runs_per_over['maiden_overs'] = np.where(matchdata_runs_per_over['batsmanscorevalue'] == 0, 1, 0) 56 | matchdata_runs_per_over = matchdata_runs_per_over.groupby(['matchid', 'bowlername'])['maiden_overs'].sum() 57 | # combining all the features created so far 58 | df_list = [bowler_wickets, bowler_overs_bow, bowler_ball_faced_legal, bowler_runs_given, matchdata_runs_per_over] 59 | bowler_summary = pd.concat(df_list, join='outer', axis=1).fillna(np.nan).reset_index() 60 | # adding additional columns just in case we need for modeling 61 | bowler_summary = pd.merge(bowler_summary, self.matchdata[['matchid', 'bowlername', 'innings', 'battingteam', 'bowlingteam']].drop_duplicates(), on=['matchid', 'bowlername'], how='left') 62 | bowler_summary.rename(columns={'innings': 'bowlers_innings', 'bowlername': 'playername', 'battingteam': 'bowler_battingteam', 63 | 'bowlingteam': 'bowler_bowlingteam'}, inplace=True) 64 | bowler_summary['economy_rate'] = (bowler_summary['total_runs_given'] * 6) / bowler_summary['total_legal_balls_bowled'] 65 | self.bowler_summary = bowler_summary 66 | return 67 | 68 | def merge_player_scorecard(self): 69 | """ 70 | batting_points: scorecard from batsmen perspective with dream11 points 71 | bowling_points: scorecard from bowling perspective with dream11 points 72 | :return: ipl_points: merged dataset with the total points per player in a match 73 | """ 74 | self.batsmen_summary_fun() 75 | self.bowler_summary_fun() 76 | ipl_merged_scorecard = pd.merge(self.batsmen_summary, self.bowler_summary, on=['matchid', 'playername'], how='outer') 77 | player_avg = self.get_player_role(ipl_merged_scorecard) 78 | ipl_merged_scorecard = pd.merge(ipl_merged_scorecard, player_avg[['playername', 'playing_role']], on='playername', how='left') 79 | self.ipl_merged_scorecard = ipl_merged_scorecard 80 | return 81 | 82 | def get_player_role(self, input_df) -> pd.DataFrame: 83 | """" 84 | function to get the players role in the team 85 | input_df: input dataframe that has the combined scorecard of the players with batting and bowling 86 | :return player_avg: df with the player name and player's playing role 87 | """ 88 | MINAVGBALLSFACED = 8 89 | MINAVGBOWLSBOWLED = 6 90 | player_avg = input_df[['playername', 'total_balls_faced', 'total_balls_bowled']].fillna(0) 91 | player_avg = pd.DataFrame(player_avg.groupby('playername')[['total_balls_faced', 'total_balls_bowled']].mean()) 92 | conditions = [((player_avg['total_balls_faced'] >= MINAVGBALLSFACED) & (player_avg['total_balls_bowled'] >= MINAVGBOWLSBOWLED)), 93 | (player_avg['total_balls_bowled'] >= MINAVGBOWLSBOWLED)] 94 | choices = ['AllRounder', 'Bowler'] 95 | player_avg['playing_role'] = np.select(conditions, choices, default='Batsmen') 96 | player_avg = player_avg.reset_index() 97 | return player_avg 98 | 99 | 100 | class Dream11Points: 101 | 102 | def __init__(self, player_scorecard, pointsconfig): 103 | self.player_scorecard = player_scorecard 104 | self.pointsconfig = pointsconfig 105 | 106 | return 107 | 108 | def get_batting_points(self) -> None: 109 | """ 110 | pointsconfig: dictionary with points per score type as per dream11 111 | :return: 112 | """ 113 | self.player_scorecard['total_runs_points'] = self.player_scorecard['total_runs'] * self.pointsconfig['total_runs'] 114 | self.player_scorecard['run_6_points'] = self.pointsconfig['run_6'] * self.player_scorecard['run_6'] 115 | self.player_scorecard['run_4_points'] = self.pointsconfig['run_4'] * self.player_scorecard['run_4'] 116 | self.player_scorecard['run_bonus_points'] = np.where(self.player_scorecard['total_runs'] == 0, self.pointsconfig['duck'], 0) 117 | self.player_scorecard['run_bonus_points'] = np.where(self.player_scorecard['total_runs'] >= 50, self.pointsconfig['>=50'] + 118 | self.player_scorecard['run_bonus_points'], self.player_scorecard['run_bonus_points']) 119 | self.player_scorecard['run_bonus_points'] = np.where(self.player_scorecard['total_runs'] >= 100, self.pointsconfig['>=100'] + 120 | self.player_scorecard['run_bonus_points'], self.player_scorecard['run_bonus_points']) 121 | self.player_scorecard['total_bat_points'] = np.nan 122 | self.player_scorecard['total_bat_points'] = self.player_scorecard['total_runs_points'].add(self.player_scorecard['run_6_points'], fill_value=0). \ 123 | add(self.player_scorecard['run_4_points'], fill_value=0).add(self.player_scorecard['run_bonus_points'], fill_value=0) 124 | self.player_scorecard['total_bat_points'] = np.where(self.player_scorecard['total_balls_faced'] >= 1, self.player_scorecard['total_bat_points'], np.nan) 125 | 126 | return 127 | 128 | def get_bowling_points(self) -> None: 129 | """ 130 | pointsconfig: dictionary with points per score type as per dream11 131 | :return: 132 | """ 133 | self.player_scorecard['total_wickets_points'] = self.pointsconfig['total_wickets'] * self.player_scorecard['total_wickets'] 134 | self.player_scorecard['economy_rate_points'] = np.where(self.player_scorecard['economy_rate'] >= 11, self.pointsconfig['>11E'], 135 | np.where(self.player_scorecard['economy_rate'] >= 10, self.pointsconfig['>10E'], 136 | np.where(self.player_scorecard['economy_rate'] >= 9,self.pointsconfig['>9E'], 137 | np.where(self.player_scorecard['economy_rate'] <= 4,self.pointsconfig['<=4E'], 138 | np.where(self.player_scorecard['economy_rate'] <= 5,self.pointsconfig['<5E'], 139 | np.where(self.player_scorecard['economy_rate'] <= 6, self.pointsconfig['<6E'],0)))))) 140 | self.player_scorecard['maiden_overs_points'] = self.pointsconfig['maiden_overs'] * self.player_scorecard['maiden_overs'] 141 | self.player_scorecard['wicket_bonus_points'] = np.where(self.player_scorecard['total_wickets'] >= 5, self.pointsconfig['>=5W'], 142 | np.where(self.player_scorecard['total_wickets'] >= 4, self.pointsconfig['>=4W'], 0)) 143 | self.player_scorecard['total_bowl_points'] = np.nan 144 | self.player_scorecard['total_bowl_points'] = self.player_scorecard['total_wickets_points'].\ 145 | add(self.player_scorecard['maiden_overs_points'], fill_value=0). \ 146 | add(self.player_scorecard['wicket_bonus_points'], fill_value=0).\ 147 | add(self.player_scorecard['economy_rate_points'], fill_value=0) 148 | self.player_scorecard['total_bowl_points'] = np.where(self.player_scorecard['total_balls_bowled'] >= 1, self.player_scorecard['total_bowl_points'], np.nan) 149 | return 150 | 151 | def get_batsmen_bowler_points(self): 152 | self.get_batting_points() 153 | self.get_bowling_points() 154 | self.player_scorecard['total_points'] = self.player_scorecard['total_bat_points'].add(self.player_scorecard['total_bowl_points'], fill_value=0) 155 | return 156 | 157 | 158 | class FeatEngineering: 159 | 160 | def __init__(self, ipl_features, matchsummary): 161 | self.ipl_features = ipl_features 162 | matchsummary['city'] = np.where(matchsummary['city'].isin(['Bangalore', 'Bengaluru']), 'Bengaluru', matchsummary['city']) 163 | matchsummary['venue'] = np.where(matchsummary['venue'].isin(['M Chinnaswamy Stadium', 'M.Chinnaswamy Stadium']),'M Chinnaswamy Stadium',matchsummary['venue']) 164 | matchsummary['venue'] = np.where(matchsummary['venue'].isin(['Punjab Cricket Association IS Bindra Stadium, Mohali', 'Punjab Cricket Association Stadium, Mohali']),'Punjab Cricket Association Stadium', matchsummary['venue']) 165 | self.matchsummary = matchsummary 166 | if "playing_team" not in self.ipl_features.columns: 167 | self.ipl_features['playing_team'] = np.where(pd.isnull(self.ipl_features['batsmen_innings']), self.ipl_features['bowler_bowlingteam'], self.ipl_features['batsmen_battingteam']) 168 | if "opposition_team" not in ipl_features.columns: 169 | self.ipl_features['opposition_team'] = np.where(pd.isnull(self.ipl_features['batsmen_innings']), self.ipl_features['bowler_battingteam'], self.ipl_features['batsmen_bowlingteam']) 170 | self.ipl_features[['playing_team', 'opposition_team']].replace({'Delhi Daredevils': 'Delhi Capitals', 'Rising Pune Supergiants': 'Pune Warriors', 171 | 'Rising Pune Supergiant': 'Pune Warriors', 'Deccan Chargers': 'Sunrisers Hyderabad'}, inplace=True) 172 | 173 | return 174 | 175 | def add_venue_info(self): 176 | """ 177 | 178 | :param matchsummary: 179 | :return: 180 | """ 181 | 182 | self.ipl_features = pd.merge(self.ipl_features, self.matchsummary[['matchid', 'year', 'city', 'venue','team1','team2','toss_winner']], on='matchid', how='left') 183 | 184 | self.ipl_features.rename(columns={'team1': "home_team", 'team2': 'away_team'}, inplace=True) 185 | 186 | # # add a feature to check if its the home game for the player 187 | # self.add_homegame_flag() 188 | # # add a feature to check if the player's team won the toss 189 | # self.add_toss_info() 190 | return 191 | def add_homegame_flag(self): 192 | self.ipl_features['home_game'] = np.where((self.ipl_features['playing_team'] == self.ipl_features['home_team']),1, 0) 193 | return 194 | 195 | def add_toss_info(self): 196 | self.ipl_features['toss_flag'] = np.where((self.ipl_features['playing_team'] == self.ipl_features['toss_winner']), 1, 0) 197 | return 198 | 199 | def add_player_match_count(self): 200 | self.ipl_features = self.ipl_features.sort_values(by=['matchid', 'playername'], ascending=True) 201 | self.ipl_features['player_match_count'] = 1 202 | self.ipl_features['player_match_count'] = self.ipl_features.groupby(['playername'])['player_match_count'].cumsum() 203 | return 204 | 205 | 206 | def add_lagging_feat(self, match_id, groupby_id, rolling_window, *args): 207 | """ 208 | add rolling average feature to add the average batting and bowling points scored by the player, strike rate, economy rate, average batting position 209 | :return: 210 | """ 211 | ipl_features = self.ipl_features.sort_values(by=[match_id, groupby_id], ascending=True) 212 | for col in args: 213 | print('col:', col) 214 | outcolname = col + "_" + groupby_id + '_avg' + str(rolling_window) 215 | # why are we removing duplicates ? 216 | rolling_avg_points = ipl_features[[match_id, groupby_id, col]].drop_duplicates() 217 | # 218 | rolling_avg_points = pd.DataFrame(rolling_avg_points.groupby([match_id, groupby_id])[col].sum()).reset_index() 219 | rolling_avg_points.set_index(match_id, inplace=True) 220 | rolling_avg_points = pd.DataFrame(rolling_avg_points.groupby([groupby_id])[col].rolling(rolling_window).mean()).reset_index().rename(columns={col: outcolname}) 221 | rolling_avg_points[outcolname] = pd.DataFrame(rolling_avg_points.groupby([groupby_id])[outcolname].shift(1)) 222 | self.ipl_features = pd.merge(self.ipl_features, rolling_avg_points, on=[match_id, groupby_id], how='left') 223 | return 224 | 225 | 226 | def add_player_leanpatch(self): 227 | self.ipl_features['lean_patch_3'] = np.where( np.isnan(self.ipl_features['totalpoints_playername_avg_10']),0, 228 | np.where(self.ipl_features['totalpoints_playername_avg_3'] < self.ipl_features['totalpoints_playername_avg_10']*.6, 1, 0)) 229 | self.ipl_features['lean_patch_2'] = np.where( np.isnan(self.ipl_features['totalpoints_playername_avg_5']),0, 230 | np.where(self.ipl_features['totalpoints_playername_avg_2'] < self.ipl_features['totalpoints_playername_avg_5']*.6, 1, 0)) 231 | self.ipl_features['lean_patch_5'] = np.where( np.isnan(self.ipl_features['totalpoints_playername_avg_10']),0, 232 | np.where(self.ipl_features['totalpoints_playername_avg_5'] < self.ipl_features['totalpoints_playername_avg_10']*.6, 1, 0)) 233 | 234 | -------------------------------------------------------------------------------- /download_ipl20.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | import pandas as pd 4 | import os 5 | from datetime import datetime 6 | import pytz 7 | import time 8 | 9 | 10 | def parse_commentary_to_data(data, page, eventid, inning, ipl): 11 | 12 | # print ("Parsing the data now to fetch relevant information") 13 | five_ball_summary = pd.DataFrame(columns=['ipl_season', 'sequence', 'eventid', 'innings', 'target', 'remainingballs', 'homescore', 'awayscore', 'fallofwickets', 'ball', 'over', 'scorevalue', 'validball', 'extras', 14 | 'dismissal', 'dismissaltype', 'batsmanid', 'batsman', 'batsmanteam', 'bowlerid', 'bowler', 'bowlerteam', 'otherathleteinvolvedid', 'otherathleteinvolved', 'nonstrikerid', 'nonstriker', 'runs', 'runrate']) 15 | 16 | for x in data['commentary']['items']: 17 | 18 | if not x: 19 | # print ("there is no data in this "+ str(page)+ " and inning "+str(inning)) 20 | break 21 | else: 22 | # print ("entered to add rows") 23 | dict = {} 24 | ipl_season = ipl 25 | sequence = x['sequence'] 26 | eventid = eventid 27 | innings = x['periodText'] 28 | ball = x['innings']['balls'] 29 | over = x['over']['overs'] 30 | scorevalue = x['scoreValue'] 31 | validball = x['over']['noBall'] + x['over']['wide'] 32 | extras = x['over']['noBall'] + x['over']['wide'] + \ 33 | x['over']['byes'] + x['innings']['legByes'] 34 | dismissal = x['dismissal']['dismissal'] 35 | dismissaltype = x['dismissal']['type'] 36 | batsmanid = x['batsman']['athlete']['id'] 37 | batsman = x['batsman']['athlete']['name'] 38 | batsmanteam = x['batsman']['team']['name'] 39 | bowlerid = x['bowler']['athlete']['id'] 40 | bowler = x['bowler']['athlete']['name'] 41 | bowlerteam = x['bowler']['team']['name'] 42 | if dismissal == 1: 43 | otherathleteinvolvedid = x['athletesInvolved'][0]['id'] 44 | otherathleteinvolved = x['athletesInvolved'][0]['name'] 45 | else: 46 | otherathleteinvolvedid = '' 47 | otherathleteinvolved = '' 48 | nonstrikerid = x['otherBatsman']['athlete']['id'] 49 | nonstriker = x['otherBatsman']['athlete']['name'] 50 | runs = x['innings']['totalRuns'] 51 | fallofwickets = x['innings']['fallOfWickets'] 52 | runrate = x['innings']['runRate'] 53 | target = x['innings']['target'] 54 | remainingballs = x['innings']['remainingBalls'] 55 | homescore = x['homeScore'] 56 | awayscore = x['awayScore'] 57 | dict = {'ipl_season': ipl_season, 'sequence': sequence, 'eventid': eventid, 'innings': innings, 58 | 'target': target, 'remainingballs': remainingballs, 'homescore': homescore, 59 | 'awayscore': awayscore, 60 | 'fallofwickets': fallofwickets, 'ball': ball, 'over': over, 'scorevalue': scorevalue, 61 | 'validball': validball, 62 | 'extras': extras, 'dismissal': dismissal, 'dismissaltype': dismissaltype, 63 | 'batsmanid': batsmanid, 'batsman': batsman, 'batsmanteam': batsmanteam, 64 | 'bowlerid': bowlerid, 'bowler': bowler, 'bowlerteam': bowlerteam, 65 | 'otherathleteinvolvedid': otherathleteinvolvedid, 66 | 'otherathleteinvolved': otherathleteinvolved, 67 | 'nonstrikerid': nonstrikerid, 'nonstriker': nonstriker, 68 | 'runs': runs, 'runrate': runrate 69 | } 70 | # print("Dictionary from this page is :" + str(dict)) 71 | five_ball_summary = five_ball_summary.append( 72 | dict, ignore_index=True) 73 | # print (df.head()) 74 | # Hypothesis 1 = runrate and balls completed should be somewhat related with the required run rate, 75 | # so cant use these 2 data simultaneously 76 | return five_ball_summary 77 | 78 | 79 | def hit_api(tournamentid, eventid, headers, ipl): 80 | print('Downloading data for eventid : ' + str(eventid)) 81 | matchdata = pd.DataFrame() 82 | 83 | for inning in range(1, 3): 84 | print('Downloading data for inning : ' + str(inning)) 85 | # This loop should be increased to range(1,5) for test matches 86 | try: 87 | for j in range(1, 8): 88 | # Will need a better mechanism to see how many pages of data needs to be present for ODIs and 89 | # test matches 90 | page = j 91 | URL = 'https://site.web.api.espn.com/apis/site/v2/sports/cricket/' + str( 92 | tournamentid) + '/playbyplay?contentorigin=espn&event=' + str(eventid) + '&page=' + str( 93 | page) + '&period=' + str(inning) + '§ion=cricinfo' 94 | # print (URL) 95 | response = requests.get(URL, headers=headers) 96 | data = json.loads(response.text) 97 | # print (len(data['commentary']['items'])) 98 | five_ball_summary = parse_commentary_to_data( 99 | data, page, eventid, inning, ipl) 100 | # print (parse_commentary_to_data(data, page, eventid, inning,ipl)) 101 | # print (five_ball_summary.head()) 102 | matchdata = matchdata.append(five_ball_summary) 103 | 104 | except: 105 | print("caught an exception while downloading data for below :") 106 | print(URL) 107 | return matchdata 108 | 109 | 110 | def get_data_for_event(tournamentid, eventid, directory, headers, ipl): 111 | fullpath = os.path.join(directory, str(eventid) + '.csv') 112 | 113 | matchdata = hit_api(tournamentid, eventid,headers,ipl ) 114 | matchdata.to_csv(fullpath, index=False, header=True) 115 | return matchdata 116 | 117 | 118 | def update_ipl20_master(year): 119 | directory = os.getcwd() +"/ipl20" 120 | tournamentid = "8048" 121 | year= str(year) 122 | #directory = '~/Documents/GitHub/dream11/ipl20' 123 | 124 | ipl20_schedule_url = "https://hsapi.espncricinfo.com/v1/pages/series/schedule?lang=en&leagueId="+tournamentid+"&year="+year 125 | headers = { 126 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36', 127 | "Upgrade-Insecure-Requests": "1", "DNT": "1", 128 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.5", 129 | "Accept-Encoding": "gzip, deflate" 130 | } 131 | response = requests.get(ipl20_schedule_url, headers=headers) 132 | data = json.loads(response.text) 133 | match_summary_ipl20 = pd.DataFrame(columns=['matchid', 'date', 'year', 'city', 'venue','team1', 'team2', 'result', 'tossdecision', 'winner', 'by_what', 'by_how_many', 'mom']) 134 | print("data",data) 135 | for match_details in data['content']['matchEvents']: 136 | dict = {} 137 | matchid = match_details['id'] 138 | date = match_details['date'] 139 | city = match_details['venue']['name'] 140 | venue = match_details['venue']['name'] 141 | team1 = match_details['competitors'][0]['name'] 142 | team2 = match_details['competitors'][1]['name'] 143 | tossdecision = "" 144 | result = match_details['statusText'] 145 | by_what = "" 146 | by_how_many = 0 147 | mom = "" 148 | winner = "" 149 | 150 | if match_details['competitors'][0]['isWinner'] == True: 151 | # print(match_details['competitors'][1]['isWinner']) 152 | winner = match_details['competitors'][0]['name'] 153 | elif match_details['competitors'][1]['isWinner'] == True: 154 | winner = match_details['competitors'][1]['name'] 155 | else: 156 | winner = 'Match Tied/Cancelled/Not yet ended' 157 | 158 | if 'runs' in match_details['statusText']: 159 | by_what = 'runs' 160 | elif 'wickets' in match_details['statusText']: 161 | by_what = 'wickets' 162 | else: 163 | by_what = '' 164 | 165 | by_how_many = [int(i) for i in match_details['statusText'].split() if i.isdigit()] 166 | dict = {'matchid': matchid, 'date': date, 'year': year, 'city': city, 'venue': venue, 'team1': team1, 'team2': team2, 'result': result,'tossdecision': tossdecision, 'winner': winner, 'by_what': by_what, 'by_how_many': by_how_many, 'mom': mom} 167 | match_summary_ipl20 = match_summary_ipl20.append(dict, ignore_index=True) 168 | 169 | # if not os.path.exists(directory): 170 | # os.makedirs(directory) 171 | # else: 172 | # os.chdir(directory) 173 | 174 | match_summary_ipl20.to_csv(directory+'/match_summary_ipl20.csv', index=False) 175 | 176 | match_summary_ipl20 = pd.read_csv(directory+'/match_summary_ipl20.csv') 177 | 178 | # matchdata_full = pd.DataFrame(columns=['ipl_season', 'sequence', 'eventid', 'innings', 'target', 'remainingballs', 'homescore', 'awayscore', 'fallofwickets', 'ball', 'over', 'scorevalue', 'validball', 'extras', 179 | # 'dismissal', 'dismissaltype', 'batsmanid', 'batsman', 'batsmanteam', 'bowlerid', 'bowler', 'bowlerteam', 'otherathleteinvolvedid', 'otherathleteinvolved', 'nonstrikerid', 'nonstriker', 'runs', 'runrate']) 180 | 181 | matchdata_full = pd.read_csv(directory+'/matchdata_ipl20.csv') 182 | # matchdata_v2 = pd.DataFrame(columns=['date', 'matchid', 'innings', 'target', 'fallofwickets', 'ball', 'over', 'scorevalue', 183 | # 'validball', 'extras', 'extratype', 'batsmanname', 'batsmanscorevalue', 'bowlername', 'nonstrikername', 184 | # 'totalruns', 'dismissal', 'dismissedtype', 'dismissedplayer', 'battingteam', 'bowlingteam']) 185 | matchdata_v2 = pd.read_csv(directory+'/matchdata_v2.csv') 186 | 187 | for eventid in match_summary_ipl20[~match_summary_ipl20['result'].str.contains('Starts') & match_summary_ipl20['result'].str.contains('won')].matchid: 188 | print(eventid) 189 | if eventid not in matchdata_full.eventid.unique().tolist(): 190 | _match_data_ = get_data_for_event(tournamentid, eventid,directory,headers,'ipl20') 191 | matchdata_full = matchdata_full.append(_match_data_, ignore_index=True, sort=True) 192 | else: 193 | print('data already downloaded') 194 | 195 | 196 | matchdata_full.to_csv(directory+'/matchdata_ipl20.csv', index = False) 197 | ipl20_matchdata = pd.read_csv(directory+'/matchdata_ipl20.csv') 198 | 199 | names_mapping = pd.read_csv(directory+'/name_mapping_clean.csv') 200 | eventids_to_be_backfilled = [x for x in ipl20_matchdata.eventid.unique().tolist() if x not in matchdata_v2.matchid.unique().tolist()] 201 | print("matchdata_v2 needs to be updated for ") 202 | print(eventids_to_be_backfilled) 203 | 204 | for iter, row in ipl20_matchdata[ipl20_matchdata['eventid'].isin(eventids_to_be_backfilled)].iterrows(): 205 | print("row",row) 206 | print("row['eventid']",row['eventid']) 207 | date = pd.to_datetime(match_summary_ipl20[match_summary_ipl20.matchid == row['eventid']].date).dt.date 208 | matchid = row['eventid'] 209 | innings = row['innings'] 210 | target = row['target'] 211 | fallofwickets = row['fallofwickets'] 212 | ball = row['ball'] 213 | over = row['over'] 214 | scorevalue = row['scorevalue'] 215 | validball = row['validball'] 216 | extras = row['extras'] 217 | extratype = 'Nan' 218 | batsmanscorevalue = row['scorevalue'] 219 | 220 | if row['batsman'] in names_mapping.values: 221 | batsmanname = names_mapping[names_mapping.ipl20_name == 222 | row['batsman']]['old_name'].tolist()[0] 223 | else: 224 | batsmanname = row['batsman'] 225 | 226 | if row['bowler'] in names_mapping.values: 227 | bowlername = names_mapping[names_mapping.ipl20_name == 228 | row['bowler']]['old_name'].tolist()[0] 229 | else: 230 | bowlername = row['bowler'] 231 | 232 | if row['nonstriker'] in names_mapping.values: 233 | nonstrikername = names_mapping[names_mapping.ipl20_name == 234 | row['nonstriker']]['old_name'].tolist()[0] 235 | else: 236 | nonstrikername = row['nonstriker'] 237 | 238 | if row['homescore'] == 0: 239 | totalruns = row['awayscore'].split('/')[0] 240 | else: 241 | totalruns = row['homescore'].split('/')[0] 242 | 243 | dismissal = row['dismissal'] 244 | dismissedtype = row['dismissaltype'] 245 | 246 | if row['dismissal'] == True: 247 | dismissedplayer = batsmanname 248 | else: 249 | dismissedplayer = '' 250 | 251 | battingteam = row['batsmanteam'] 252 | bowlingteam = row['bowlerteam'] 253 | 254 | dict = {"date": date, "matchid": matchid, "innings": innings, "target": target, "fallofwickets": fallofwickets, 255 | "ball": ball, "over": over, "scorevalue": scorevalue, "validball": validball, "extras": extras, 256 | "extratype": extratype, "batsmanname": batsmanname, "batsmanscorevalue": batsmanscorevalue, 257 | "bowlername": bowlername, "nonstrikername": nonstrikername, "totalruns": totalruns, "dismissal": dismissal, 258 | "dismissedtype": dismissedtype, "dismissedplayer": dismissedplayer, "battingteam": battingteam, 259 | "bowlingteam": bowlingteam} 260 | matchdata_v2 = matchdata_v2.append(dict, ignore_index=True) 261 | 262 | matchdata_v2.to_csv(directory+'/matchdata_v2.csv', index=False) 263 | matchdata_v2 = pd.read_csv(directory+'/matchdata_v2.csv') 264 | return matchdata_v2 265 | 266 | 267 | def get_current_squad(): 268 | 269 | directory = os.getcwd() +"/ipl20" 270 | 271 | headers = { 272 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36', 273 | "Upgrade-Insecure-Requests": "1", "DNT": "1", 274 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 275 | "Accept-Language": "en-US,en;q=0.5", 276 | "Accept-Encoding": "gzip, deflate" 277 | } 278 | 279 | match_summary_ipl20 = pd.read_csv(directory + '/match_summary_ipl20.csv') 280 | 281 | tz_dubai = pytz.timezone('Asia/Dubai') 282 | datetime_dubai = datetime.now(tz_dubai) 283 | 284 | eventid = match_summary_ipl20.iloc[next(x[0] for x in enumerate(pd.to_datetime(match_summary_ipl20['date']).tolist()) if x[1] > datetime_dubai), 0] 285 | 286 | print('Playing XI need to be downloaded for : ') 287 | print(eventid) 288 | 289 | today_squad = pd.DataFrame(columns = ['playername','iscaptain', 'position', 'profilelink', 'teamname']) 290 | squad_title = 'Squads' 291 | 292 | counter = 0 293 | while squad_title != 'Playing XI' and counter < 3: 294 | URL= "https://hsapi.espncricinfo.com/v1/pages/match/home?lang=en&leagueId=8048&eventId="+str(eventid)+"&liveTest=false&qaTest=false" 295 | print(URL) 296 | response = requests.get(URL, headers=headers) 297 | data = json.loads(response.text) 298 | squad_title = data['content']['squads'][0]['title'] 299 | 300 | if squad_title == 'Playing XI': 301 | for team in data['content']['squads']: 302 | for playerlist in team['players']: 303 | dict ={} 304 | playername = playerlist['name'] 305 | iscaptain = playerlist['isCaptain'] 306 | position = playerlist['position'] 307 | profilelink = playerlist['link']['href'] 308 | teamname = team['teamName'] 309 | dict = {'playername':playername, 'iscaptain': iscaptain, 'position': position, 'profilelink': profilelink,'teamname':teamname} 310 | today_squad = today_squad.append(dict, ignore_index=True) 311 | 312 | today_squad.drop_duplicates(subset=None, keep='first', inplace=True) 313 | names_mapping = pd.read_csv(directory + '/name_mapping_clean.csv') 314 | names_mapping.columns = ['playername', 'new_playername'] 315 | today_squad = pd.merge(today_squad, names_mapping, on='playername', how='inner') 316 | today_squad.drop(columns=['playername'], inplace=True) 317 | today_squad.rename(columns={'new_playername': "playername"}, inplace=True) 318 | today_squad.to_csv(directory+'/teams/'+str(eventid)+'_squad.csv', index=False) 319 | 320 | else: 321 | print('could not find the playing XI on page, trying again in 60 secs') 322 | time.sleep(60) 323 | counter = counter + 1 324 | return today_squad -------------------------------------------------------------------------------- /ipl20/1216501.csv: -------------------------------------------------------------------------------- 1 | ipl_season,sequence,eventid,innings,target,remainingballs,homescore,awayscore,fallofwickets,ball,over,scorevalue,validball,extras,dismissal,dismissaltype,batsmanid,batsman,batsmanteam,bowlerid,bowler,bowlerteam,otherathleteinvolvedid,otherathleteinvolved,nonstrikerid,nonstriker,runs,runrate 2 | ipl20,200001,1216501,2nd innings,168,119,0,0/0,0,1,0.1,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,44828,Faf du Plessis,0,0.0 3 | ipl20,200002,1216501,2nd innings,168,118,0,0/0,0,2,0.2,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,44828,Faf du Plessis,0,0.0 4 | ipl20,200003,1216501,2nd innings,168,117,0,1/0,0,3,0.3,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,44828,Faf du Plessis,1,2.0 5 | ipl20,200004,1216501,2nd innings,168,116,0,1/0,0,4,0.4,0,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,0,1.5 6 | ipl20,200005,1216501,2nd innings,168,115,0,2/0,0,5,0.5,1,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,1,2.4 7 | ipl20,200006,1216501,2nd innings,168,114,0,6/0,0,6,0.6,4,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,44828,Faf du Plessis,4,6.0 8 | ipl20,200101,1216501,2nd innings,168,113,0,7/0,0,7,1.1,1,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,8180,Shane Watson,1,6.0 9 | ipl20,200102,1216501,2nd innings,168,112,0,8/0,0,8,1.2,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,44828,Faf du Plessis,1,6.0 10 | ipl20,200103,1216501,2nd innings,168,111,0,9/0,0,9,1.3,1,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,8180,Shane Watson,1,6.0 11 | ipl20,200104,1216501,2nd innings,168,110,0,10/0,0,10,1.4,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,44828,Faf du Plessis,1,6.0 12 | ipl20,200105,1216501,2nd innings,168,109,0,14/0,0,11,1.5,4,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,8180,Shane Watson,4,7.63 13 | ipl20,200106,1216501,2nd innings,168,108,0,18/0,0,12,1.6,4,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,8180,Shane Watson,4,9.0 14 | ipl20,200201,1216501,2nd innings,168,107,0,18/0,0,13,2.1,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,44828,Faf du Plessis,0,8.3 15 | ipl20,200202,1216501,2nd innings,168,106,0,18/0,0,14,2.2,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,44828,Faf du Plessis,0,7.71 16 | ipl20,200203,1216501,2nd innings,168,105,0,19/0,0,15,2.3,1,0,1,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,44828,Faf du Plessis,1,7.6 17 | ipl20,200204,1216501,2nd innings,168,104,0,21/0,0,16,2.4,2,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,2,7.87 18 | ipl20,200205,1216501,2nd innings,168,103,0,25/0,0,17,2.5,4,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,4,8.82 19 | ipl20,200206,1216501,2nd innings,168,102,0,25/0,0,18,2.6,0,0,0,False,,44828,Faf du Plessis,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,0,8.33 20 | ipl20,200301,1216501,2nd innings,168,101,0,25/0,0,19,3.1,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,44828,Faf du Plessis,0,7.89 21 | ipl20,200302,1216501,2nd innings,168,100,0,29/0,0,20,3.2,4,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,44828,Faf du Plessis,4,8.7 22 | ipl20,200303,1216501,2nd innings,168,99,0,30/0,0,21,3.3,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,44828,Faf du Plessis,1,8.57 23 | ipl20,200304,1216501,2nd innings,168,98,0,30/1,1,22,3.4,0,0,0,True,caught,44828,Faf du Plessis,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,13653,George Goldsmith,8180,Shane Watson,0,8.18 24 | ipl20,200305,1216501,2nd innings,168,97,0,31/1,0,23,3.5,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,8180,Shane Watson,1,8.08 25 | ipl20,200306,1216501,2nd innings,168,96,0,32/1,0,24,3.6,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.0 26 | ipl20,200401,1216501,2nd innings,168,95,0,32/1,0,25,4.1,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,33141,Ambati Rayudu,0,7.68 27 | ipl20,200402,1216501,2nd innings,168,94,0,33/1,0,26,4.2,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,7.61 28 | ipl20,200403,1216501,2nd innings,168,94,0,34/1,0,26,4.2,1,1,1,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,1,7.84 29 | ipl20,200404,1216501,2nd innings,168,93,0,38/1,0,27,4.3,4,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,4,8.44 30 | ipl20,200405,1216501,2nd innings,168,92,0,39/1,0,28,4.4,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,1,8.35 31 | ipl20,200406,1216501,2nd innings,168,91,0,40/1,0,29,4.5,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.27 32 | ipl20,200407,1216501,2nd innings,168,90,0,41/1,0,30,4.6,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,1,8.2 33 | ipl20,200501,1216501,2nd innings,168,89,0,42/1,0,31,5.1,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,8180,Shane Watson,1,8.12 34 | ipl20,200502,1216501,2nd innings,168,88,0,46/1,0,32,5.2,4,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,33141,Ambati Rayudu,4,8.62 35 | ipl20,200503,1216501,2nd innings,168,87,0,52/1,0,33,5.3,6,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,33141,Ambati Rayudu,6,9.45 36 | ipl20,200504,1216501,2nd innings,168,86,0,52/1,0,34,5.4,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,33141,Ambati Rayudu,0,9.17 37 | ipl20,200505,1216501,2nd innings,168,85,0,53/1,0,35,5.5,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,9.08 38 | ipl20,200506,1216501,2nd innings,168,84,0,54/1,0,36,5.6,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1079848,Shivam Mavi,Kolkata Knight Riders,,,8180,Shane Watson,1,9.0 39 | ipl20,200601,1216501,2nd innings,168,83,0,55/1,0,37,6.1,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,8180,Shane Watson,1,8.91 40 | ipl20,200602,1216501,2nd innings,168,82,0,55/1,0,38,6.2,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,33141,Ambati Rayudu,0,8.68 41 | ipl20,200603,1216501,2nd innings,168,81,0,56/1,0,39,6.3,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.61 42 | ipl20,200604,1216501,2nd innings,168,80,0,57/1,0,40,6.4,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,8180,Shane Watson,1,8.55 43 | ipl20,200605,1216501,2nd innings,168,79,0,58/1,0,41,6.5,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.48 44 | ipl20,200606,1216501,2nd innings,168,78,0,62/1,0,42,6.6,4,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,8180,Shane Watson,4,8.85 45 | ipl20,200701,1216501,2nd innings,168,77,0,63/1,0,43,7.1,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.79 46 | ipl20,200702,1216501,2nd innings,168,76,0,63/1,0,44,7.2,0,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,0,8.59 47 | ipl20,200703,1216501,2nd innings,168,75,0,67/1,0,45,7.3,4,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,4,8.93 48 | ipl20,200704,1216501,2nd innings,168,74,0,67/1,0,46,7.4,0,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,0,8.73 49 | ipl20,200705,1216501,2nd innings,168,73,0,68/1,0,47,7.5,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,1,8.68 50 | ipl20,200706,1216501,2nd innings,168,72,0,69/1,0,48,7.6,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.62 51 | ipl20,200801,1216501,2nd innings,168,71,0,73/1,0,49,8.1,4,0,0,False,,8180,Shane Watson,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,33141,Ambati Rayudu,4,8.93 52 | ipl20,200802,1216501,2nd innings,168,70,0,74/1,0,50,8.2,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.88 53 | ipl20,200803,1216501,2nd innings,168,69,0,75/1,0,51,8.3,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,8180,Shane Watson,1,8.82 54 | ipl20,200804,1216501,2nd innings,168,68,0,76/1,0,52,8.4,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.76 55 | ipl20,200805,1216501,2nd innings,168,67,0,77/1,0,53,8.5,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,8180,Shane Watson,1,8.71 56 | ipl20,200806,1216501,2nd innings,168,66,0,78/1,0,54,8.6,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.66 57 | ipl20,200901,1216501,2nd innings,168,65,0,79/1,0,55,9.1,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.61 58 | ipl20,200902,1216501,2nd innings,168,64,0,80/1,0,56,9.2,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,1,8.57 59 | ipl20,200903,1216501,2nd innings,168,63,0,84/1,0,57,9.3,4,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,33141,Ambati Rayudu,4,8.84 60 | ipl20,200904,1216501,2nd innings,168,62,0,85/1,0,58,9.4,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.79 61 | ipl20,200905,1216501,2nd innings,168,61,0,86/1,0,59,9.5,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,1,8.74 62 | ipl20,200906,1216501,2nd innings,168,60,0,90/1,0,60,9.6,4,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,33141,Ambati Rayudu,4,9.0 63 | ipl20,201001,1216501,2nd innings,168,59,0,90/1,0,61,10.1,0,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,0,8.85 64 | ipl20,201002,1216501,2nd innings,168,58,0,90/1,0,62,10.2,0,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,0,8.7 65 | ipl20,201003,1216501,2nd innings,168,57,0,91/1,0,63,10.3,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,1,8.66 66 | ipl20,201004,1216501,2nd innings,168,56,0,92/1,0,64,10.4,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.62 67 | ipl20,201005,1216501,2nd innings,168,55,0,93/1,0,65,10.5,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,8180,Shane Watson,1,8.58 68 | ipl20,201006,1216501,2nd innings,168,55,0,94/1,0,65,10.5,1,1,1,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.67 69 | ipl20,201007,1216501,2nd innings,168,54,0,94/1,0,66,10.6,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,489889,Pat Cummins,Kolkata Knight Riders,,,33141,Ambati Rayudu,0,8.54 70 | ipl20,201101,1216501,2nd innings,168,53,0,94/1,0,67,11.1,0,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,8180,Shane Watson,0,8.41 71 | ipl20,201102,1216501,2nd innings,168,52,0,96/1,0,68,11.2,2,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,8180,Shane Watson,2,8.47 72 | ipl20,201103,1216501,2nd innings,168,51,0,96/1,0,69,11.3,0,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,8180,Shane Watson,0,8.34 73 | ipl20,201104,1216501,2nd innings,168,50,0,97/1,0,70,11.4,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,8180,Shane Watson,1,8.31 74 | ipl20,201105,1216501,2nd innings,168,49,0,98/1,0,71,11.5,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,33141,Ambati Rayudu,1,8.28 75 | ipl20,201106,1216501,2nd innings,168,48,0,99/1,0,72,11.6,1,0,0,False,,33141,Ambati Rayudu,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,8180,Shane Watson,1,8.25 76 | ipl20,201201,1216501,2nd innings,168,47,0,99/2,2,73,12.1,0,0,0,True,caught,33141,Ambati Rayudu,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,33141,Ambati Rayudu,8180,Shane Watson,0,8.13 77 | ipl20,201202,1216501,2nd innings,168,46,0,99/2,0,74,12.2,0,0,0,False,,28081,MS Dhoni,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,0,8.02 78 | ipl20,201203,1216501,2nd innings,168,45,0,100/2,0,75,12.3,1,0,0,False,,28081,MS Dhoni,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,8180,Shane Watson,1,8.0 79 | ipl20,201204,1216501,2nd innings,168,44,0,100/2,0,76,12.4,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,28081,MS Dhoni,0,7.89 80 | ipl20,201205,1216501,2nd innings,168,43,0,100/2,0,77,12.5,0,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,28081,MS Dhoni,0,7.79 81 | ipl20,201206,1216501,2nd innings,168,42,0,101/2,0,78,12.6,1,0,0,False,,8180,Shane Watson,Chennai Super Kings,1070188,Kamlesh Nagarkoti,Kolkata Knight Riders,,,28081,MS Dhoni,1,7.76 82 | ipl20,201301,1216501,2nd innings,168,41,0,101/3,3,79,13.1,0,0,0,True,leg before wicket,8180,Shane Watson,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,8180,Shane Watson,28081,MS Dhoni,0,7.67 83 | ipl20,201302,1216501,2nd innings,168,40,0,101/3,0,80,13.2,0,0,0,False,,662973,Sam Curran,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,28081,MS Dhoni,0,7.57 84 | ipl20,201303,1216501,2nd innings,168,39,0,103/3,0,81,13.3,2,0,0,False,,662973,Sam Curran,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,28081,MS Dhoni,2,7.62 85 | ipl20,201304,1216501,2nd innings,168,38,0,104/3,0,82,13.4,1,0,0,False,,662973,Sam Curran,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,28081,MS Dhoni,1,7.6 86 | ipl20,201305,1216501,2nd innings,168,37,0,104/3,0,83,13.5,0,0,0,False,,28081,MS Dhoni,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,662973,Sam Curran,0,7.51 87 | ipl20,201306,1216501,2nd innings,168,36,0,104/3,0,84,13.6,0,0,0,False,,28081,MS Dhoni,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,662973,Sam Curran,0,7.42 88 | ipl20,201401,1216501,2nd innings,168,35,0,104/3,0,85,14.1,0,0,0,False,,662973,Sam Curran,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,28081,MS Dhoni,0,7.34 89 | ipl20,201402,1216501,2nd innings,168,34,0,105/3,0,86,14.2,1,0,0,False,,662973,Sam Curran,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,28081,MS Dhoni,1,7.32 90 | ipl20,201403,1216501,2nd innings,168,33,0,105/3,0,87,14.3,0,0,0,False,,28081,MS Dhoni,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,0,7.24 91 | ipl20,201404,1216501,2nd innings,168,32,0,107/3,0,88,14.4,2,0,0,False,,28081,MS Dhoni,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,2,7.29 92 | ipl20,201405,1216501,2nd innings,168,31,0,109/3,0,89,14.5,2,0,0,False,,28081,MS Dhoni,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,2,7.34 93 | ipl20,201406,1216501,2nd innings,168,30,0,110/3,0,90,14.6,1,0,0,False,,28081,MS Dhoni,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,1,7.33 94 | ipl20,201501,1216501,2nd innings,168,29,0,111/3,0,91,15.1,1,0,1,False,,28081,MS Dhoni,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,662973,Sam Curran,1,7.31 95 | ipl20,201502,1216501,2nd innings,168,28,0,112/3,0,92,15.2,1,0,0,False,,662973,Sam Curran,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,28081,MS Dhoni,1,7.3 96 | ipl20,201503,1216501,2nd innings,168,27,0,113/3,0,93,15.3,1,0,0,False,,28081,MS Dhoni,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,662973,Sam Curran,1,7.29 97 | ipl20,201504,1216501,2nd innings,168,26,0,119/3,0,94,15.4,6,0,0,False,,662973,Sam Curran,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,28081,MS Dhoni,6,7.59 98 | ipl20,201505,1216501,2nd innings,168,25,0,123/3,0,95,15.5,4,0,0,False,,662973,Sam Curran,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,28081,MS Dhoni,4,7.76 99 | ipl20,201506,1216501,2nd innings,168,24,0,124/3,0,96,15.6,1,0,0,False,,662973,Sam Curran,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,28081,MS Dhoni,1,7.75 100 | ipl20,201601,1216501,2nd innings,168,23,0,125/3,0,97,16.1,1,0,0,False,,662973,Sam Curran,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,28081,MS Dhoni,1,7.73 101 | ipl20,201602,1216501,2nd innings,168,22,0,129/3,0,98,16.2,4,0,0,False,,28081,MS Dhoni,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,4,7.89 102 | ipl20,201603,1216501,2nd innings,168,21,0,129/4,4,99,16.3,0,0,0,True,bowled,28081,MS Dhoni,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,28081,MS Dhoni,662973,Sam Curran,0,7.81 103 | ipl20,201604,1216501,2nd innings,168,20,0,129/4,0,100,16.4,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,0,7.74 104 | ipl20,201605,1216501,2nd innings,168,19,0,129/4,0,101,16.5,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,0,7.66 105 | ipl20,201606,1216501,2nd innings,168,18,0,129/4,0,102,16.6,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,1108375,Varun Chakravarthy,Kolkata Knight Riders,,,662973,Sam Curran,0,7.58 106 | ipl20,201701,1216501,2nd innings,168,17,0,129/5,5,103,17.1,0,0,0,True,caught,662973,Sam Curran,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,53284,T Walker,290716,Kedar Jadhav,0,7.51 107 | ipl20,201702,1216501,2nd innings,168,16,0,130/5,0,104,17.2,1,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,290716,Kedar Jadhav,1,7.5 108 | ipl20,201703,1216501,2nd innings,168,15,0,130/5,0,105,17.3,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,234675,Ravindra Jadeja,0,7.42 109 | ipl20,201704,1216501,2nd innings,168,14,0,130/5,0,106,17.4,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,234675,Ravindra Jadeja,0,7.35 110 | ipl20,201705,1216501,2nd innings,168,13,0,131/5,0,107,17.5,1,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,234675,Ravindra Jadeja,1,7.34 111 | ipl20,201706,1216501,2nd innings,168,12,0,132/5,0,108,17.6,1,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,290716,Kedar Jadhav,1,7.33 112 | ipl20,201801,1216501,2nd innings,168,11,0,133/5,0,109,18.1,1,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,290716,Kedar Jadhav,1,7.32 113 | ipl20,201802,1216501,2nd innings,168,10,0,137/5,0,110,18.2,4,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,234675,Ravindra Jadeja,4,7.47 114 | ipl20,201803,1216501,2nd innings,168,9,0,137/5,0,111,18.3,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,234675,Ravindra Jadeja,0,7.4 115 | ipl20,201804,1216501,2nd innings,168,8,0,138/5,0,112,18.4,1,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,234675,Ravindra Jadeja,1,7.39 116 | ipl20,201805,1216501,2nd innings,168,7,0,142/5,0,113,18.5,4,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,290716,Kedar Jadhav,4,7.53 117 | ipl20,201806,1216501,2nd innings,168,6,0,142/5,0,114,18.6,0,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,230558,Sunil Narine,Kolkata Knight Riders,,,290716,Kedar Jadhav,0,7.47 118 | ipl20,201901,1216501,2nd innings,168,5,0,142/5,0,115,19.1,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,234675,Ravindra Jadeja,0,7.4 119 | ipl20,201902,1216501,2nd innings,168,4,0,142/5,0,116,19.2,0,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,234675,Ravindra Jadeja,0,7.34 120 | ipl20,201903,1216501,2nd innings,168,3,0,143/5,0,117,19.3,1,0,0,False,,290716,Kedar Jadhav,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,234675,Ravindra Jadeja,1,7.33 121 | ipl20,201904,1216501,2nd innings,168,2,0,149/5,0,118,19.4,6,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,290716,Kedar Jadhav,6,7.57 122 | ipl20,201905,1216501,2nd innings,168,1,0,153/5,0,119,19.5,4,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,290716,Kedar Jadhav,4,7.71 123 | ipl20,201906,1216501,2nd innings,168,0,0,157/5,0,120,19.6,4,0,0,False,,234675,Ravindra Jadeja,Chennai Super Kings,276298,Andre Russell,Kolkata Knight Riders,,,290716,Kedar Jadhav,4,7.85 124 | --------------------------------------------------------------------------------