├── .gitignore
├── LICENSE
├── Procfile
├── README.md
├── __pycache__
└── app.cpython-37.pyc
├── app.py
├── model
└── ipl_model.pkl
├── requirements.txt
└── templates
└── main.html
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Harsh Bardhan Mishra
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: gunicorn app:app
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
IPL Match Predictor
9 |
10 |
11 | A simple Machine Learning Application developed and deployed on Flask Web Framework to predict an IPL Match Winner 🏏🎰
12 |
13 |
14 |
15 |
16 |
17 | ## About The Project
18 |
19 | IPL Match Predictor is a Flask Application that deploys a Machine Learning Model that can predict the winner of an IPL Match. The Algorithm
20 | used to develop and deploy the Machine Learning Application was Random Forest and has been developed to research intuitive work on utilizing Machine Learning in Sports and Academics. The project was displayed during Project Expo held on February 1, 2020 at Sathyabama Institute of Science and Technology.
21 |
22 | ## Technology Stack
23 |
24 | * [Flask](https://github.com/pallets/flask)
25 | * [HTML](https://www.w3.org/TR/html52/)
26 | * [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS)
27 | * [Bootstrap](https://getbootstrap.com/)
28 |
29 | ## Local Installation
30 |
31 | 1. Drop a ⭐ on the Github Repository.
32 | 2. Clone the Repo by going to your local Git Client and pushing in the command:
33 |
34 | ```sh
35 | git clone https://github.com/HarshCasper/IPL-Match-Predictor.git
36 | ```
37 |
38 | 3. Install the Packages:
39 | ```sh
40 | pip install -r requirements.txt
41 | ```
42 |
43 | 4. At last, push in the command:
44 | ```sh
45 | python app.py
46 | ```
47 |
48 | 5. Go to ` http://127.0.0.1:5000/` and enjoy the application.
49 |
50 | ## LICENSE
51 |
52 | [MIT](https://github.com/HarshCasper/IPL-Match-Predictor/blob/master/LICENSE)
53 |
--------------------------------------------------------------------------------
/__pycache__/app.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarshCasper/IPL-Match-Predictor/d82d13730644b51cec18d5573ec04fd4867d9b62/__pycache__/app.cpython-37.pyc
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | import flask
2 | import pickle
3 | import pandas as pd
4 | import numpy as np
5 |
6 | with open(f'model/ipl_model.pkl', 'rb') as f:
7 | model = pickle.load(f)
8 |
9 | app = flask.Flask(__name__, template_folder='templates')
10 |
11 | @app.route('/', methods=["GET", "POST"])
12 | def main():
13 | if flask.request.method == 'GET':
14 | return(flask.render_template('main.html'))
15 |
16 | if flask.request.method == 'POST':
17 | city = flask.request.form['city']
18 | Home = flask.request.form['Home']
19 | Away = flask.request.form['Away']
20 | toss_winner = flask.request.form['toss_winner']
21 | toss_decision = flask.request.form['toss_decision']
22 | venue = flask.request.form['venue']
23 |
24 | if toss_winner == 'Home Team':
25 | toss_winner = Home
26 | else:
27 | toss_winner = Away
28 |
29 | input_variables = pd.DataFrame([[city, Home, Away, toss_winner, toss_decision, venue]], columns=['city', 'Home', 'Away', 'toss_winner',
30 | 'toss_decision', 'venue'], dtype=object)
31 |
32 | input_variables.Home.replace(['Sunrisers Hyderabad', 'Mumbai Indians', 'Gujarat Lions',
33 | 'Rising Pune Supergiant', 'Royal Challengers Bangalore',
34 | 'Kolkata Knight Riders', 'Delhi Capitals', 'Kings XI Punjab',
35 | 'Chennai Super Kings', 'Rajasthan Royals', 'Deccan Chargers',
36 | 'Kochi Tuskers Kerala', 'Pune Warriors', 'Rising Pune Supergiants'],
37 | np.arange(0, 14), inplace=True)
38 | input_variables.Away.replace(['Sunrisers Hyderabad', 'Mumbai Indians', 'Gujarat Lions',
39 | 'Rising Pune Supergiant', 'Royal Challengers Bangalore',
40 | 'Kolkata Knight Riders', 'Delhi Capitals', 'Kings XI Punjab',
41 | 'Chennai Super Kings', 'Rajasthan Royals', 'Deccan Chargers',
42 | 'Kochi Tuskers Kerala', 'Pune Warriors', 'Rising Pune Supergiants'],
43 | np.arange(0, 14), inplace=True)
44 | #input_variables['toss_winner'] = np.where(input_variables['toss_winner'] == 'Home Team', input_variables['Home'], input_variables['Away'])
45 | input_variables.toss_winner.replace(['Sunrisers Hyderabad', 'Mumbai Indians', 'Gujarat Lions',
46 | 'Rising Pune Supergiant', 'Royal Challengers Bangalore',
47 | 'Kolkata Knight Riders', 'Delhi Capitals', 'Kings XI Punjab',
48 | 'Chennai Super Kings', 'Rajasthan Royals', 'Deccan Chargers',
49 | 'Kochi Tuskers Kerala', 'Pune Warriors', 'Rising Pune Supergiants'],
50 | np.arange(0, 14), inplace=True)
51 | input_variables.toss_decision.replace(['bat', 'field'], [0, 1], inplace=True)
52 | input_variables.city.replace(['Hyderabad', 'Pune', 'Rajkot', 'Indore', 'Bangalore', 'Mumbai',
53 | 'Kolkata', 'Delhi', 'Chandigarh', 'Kanpur', 'Jaipur', 'Chennai',
54 | 'Cape Town', 'Port Elizabeth', 'Durban', 'Centurion',
55 | 'East London', 'Johannesburg', 'Kimberley', 'Bloemfontein',
56 | 'Ahmedabad', 'Cuttack', 'Nagpur', 'Dharamsala', 'Kochi',
57 | 'Visakhapatnam', 'Raipur', 'Ranchi', 'Abu Dhabi', 'Sharjah'],
58 | np.arange(0, 30), inplace=True)
59 | input_variables.venue.replace(['Rajiv Gandhi International Stadium, Uppal',
60 | 'Maharashtra Cricket Association Stadium',
61 | 'Saurashtra Cricket Association Stadium', 'Holkar Cricket Stadium',
62 | 'M Chinnaswamy Stadium', 'Wankhede Stadium', 'Eden Gardens',
63 | 'Feroz Shah Kotla',
64 | 'Punjab Cricket Association IS Bindra Stadium, Mohali',
65 | 'Green Park', 'Punjab Cricket Association Stadium, Mohali',
66 | 'Sawai Mansingh Stadium', 'MA Chidambaram Stadium, Chepauk',
67 | 'Dr DY Patil Sports Academy', 'Newlands', "St George's Park",
68 | 'Kingsmead', 'SuperSport Park', 'Buffalo Park',
69 | 'New Wanderers Stadium', 'De Beers Diamond Oval',
70 | 'OUTsurance Oval', 'Brabourne Stadium',
71 | 'Sardar Patel Stadium, Motera', 'Barabati Stadium',
72 | 'Vidarbha Cricket Association Stadium, Jamtha',
73 | 'Himachal Pradesh Cricket Association Stadium', 'Nehru Stadium',
74 | 'Dr. Y.S. Rajasekhara Reddy ACA-VDCA Cricket Stadium',
75 | 'Subrata Roy Sahara Stadium',
76 | 'Shaheed Veer Narayan Singh International Stadium',
77 | 'JSCA International Stadium Complex', 'Sheikh Zayed Stadium',
78 | 'Sharjah Cricket Stadium'],
79 | np.arange(0, 34), inplace=True)
80 | prediction = model.predict(input_variables)
81 | prediction = pd.DataFrame(prediction, columns=['Winners'])
82 | prediction = prediction["Winners"].map({0:'Sunrisers Hyderabad', 1:'Mumbai Indians', 2:'Gujarat Lions',
83 | 3:'Rising Pune Supergiant', 4:'Royal Challengers Bangalore',
84 | 5:'Kolkata Knight Riders', 6:'Delhi Capitals', 7:'Kings XI Punjab',
85 | 8:'Chennai Super Kings', 9:'Rajasthan Royals', 10:'Deccan Chargers',
86 | 11:'Kochi Tuskers Kerala', 12:'Pune Warriors', 13:'Rising Pune Supergiants'})
87 | return flask.render_template('main.html', original_input={'city':city, 'Home':Home, 'Away':Away, 'toss_winner':toss_winner, 'toss_decision':toss_decision,
88 | 'venue':venue},
89 | result=prediction[0],
90 | )
91 |
92 | if __name__=='__main__':
93 | app.run(debug="True")
94 |
--------------------------------------------------------------------------------
/model/ipl_model.pkl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarshCasper/IPL-Match-Predictor/d82d13730644b51cec18d5573ec04fd4867d9b62/model/ipl_model.pkl
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | flask
2 | pandas
3 | numpy
4 |
--------------------------------------------------------------------------------
/templates/main.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
27 |
28 |
29 |
30 |
31 |
32 |
34 |
35 |
36 |
39 |
40 |
By Harsh Bardhan Mishra
41 |
42 |
43 |
44 |
127 |
128 |
129 | {% if result %}
130 | {% for variable, value in original_input.items() %}
131 |
{{ variable }} : {{ value }}
132 | {% endfor %}
133 |
134 |
Predicted Winner:
135 |
{{ result }}
136 | {% endif %}
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------