-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
54 lines (43 loc) · 1.86 KB
/
app.py
File metadata and controls
54 lines (43 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from flask import Flask, render_template, request
import pickle
import pandas as pd
app = Flask(__name__)
# Load the model
pipe = pickle.load(open('pipe.pkl', 'rb'))
teams = [
'Australia', 'India', 'Bangladesh', 'New Zealand', 'South Africa',
'England', 'West Indies', 'Afghanistan', 'Pakistan', 'Sri Lanka'
]
cities = [
'Colombo', 'Mirpur', 'Johannesburg', 'Dubai', 'Auckland', 'Cape Town',
'London', 'Pallekele', 'Barbados', 'Sydney', 'Melbourne', 'Durban',
'St Lucia', 'Wellington', 'Lauderhill', 'Hamilton', 'Centurion',
'Manchester', 'Abu Dhabi', 'Mumbai', 'Nottingham', 'Southampton',
'Mount Maunganui', 'Chittagong', 'Kolkata', 'Lahore', 'Delhi',
'Nagpur', 'Chandigarh', 'Adelaide', 'Bangalore', 'St Kitts', 'Cardiff',
'Christchurch', 'Trinidad'
]
@app.route('/', methods=['GET', 'POST'])
def index():
prediction = None
if request.method == 'POST':
batting_team = request.form['batting_team']
bowling_team = request.form['bowling_team']
city = request.form['city']
current_score = int(request.form['current_score'])
overs = float(request.form['overs'])
wickets = int(request.form['wickets'])
last_five = int(request.form['last_five'])
balls_left = 120 - (overs * 6)
wickets_left = 10 - wickets
crr = current_score / overs
input_df = pd.DataFrame(
{'batting_team': [batting_team], 'bowling_team': [bowling_team], 'city': [city],
'current_score': [current_score], 'balls_left': [balls_left],
'wicket_left': [wickets], 'current_run_rate': [crr], 'last_five': [last_five]}
)
result = pipe.predict(input_df)
prediction = int(result[0])
return render_template('index.html', teams=sorted(teams), cities=sorted(cities), prediction=prediction)
if __name__ == '__main__':
app.run(debug=True)