Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pickle
|
3 |
-
import pandas as pd
|
4 |
-
|
5 |
-
teams = ['Sunrisers Hyderabad',
|
6 |
-
'Mumbai Indians',
|
7 |
-
'Royal Challengers Bangalore',
|
8 |
-
'Kolkata Knight Riders',
|
9 |
-
'Kings XI Punjab',
|
10 |
-
'Chennai Super Kings',
|
11 |
-
'Rajasthan Royals',
|
12 |
-
'Delhi Capitals']
|
13 |
-
|
14 |
-
cities = ['Hyderabad', 'Bangalore', 'Mumbai', 'Indore', 'Kolkata', 'Delhi',
|
15 |
-
'Chandigarh', 'Jaipur', 'Chennai', 'Cape Town', 'Port Elizabeth',
|
16 |
-
'Durban', 'Centurion', 'East London', 'Johannesburg', 'Kimberley',
|
17 |
-
'Bloemfontein', 'Ahmedabad', 'Cuttack', 'Nagpur', 'Dharamsala',
|
18 |
-
'Visakhapatnam', 'Pune', 'Raipur', 'Ranchi', 'Abu Dhabi',
|
19 |
-
'Sharjah', 'Mohali', 'Bengaluru']
|
20 |
-
|
21 |
-
pipe = pickle.load(open('pipe.pkl','rb'))
|
22 |
-
st.title('IPL Win Predictor')
|
23 |
-
|
24 |
-
col1, col2 = st.
|
25 |
-
|
26 |
-
with col1:
|
27 |
-
batting_team = st.selectbox('Select the batting team',sorted(teams))
|
28 |
-
with col2:
|
29 |
-
bowling_team = st.selectbox('Select the bowling team',sorted(teams))
|
30 |
-
|
31 |
-
selected_city = st.selectbox('Select host city',sorted(cities))
|
32 |
-
|
33 |
-
target = st.number_input('Target')
|
34 |
-
|
35 |
-
col3,col4,col5 = st.
|
36 |
-
|
37 |
-
with col3:
|
38 |
-
score = st.number_input('Score')
|
39 |
-
with col4:
|
40 |
-
overs = st.number_input('Overs completed')
|
41 |
-
with col5:
|
42 |
-
wickets = st.number_input('Wickets out')
|
43 |
-
|
44 |
-
if st.button('Predict Probability'):
|
45 |
-
runs_left = target - score
|
46 |
-
balls_left = 120 - (overs*6)
|
47 |
-
wickets = 10 - wickets
|
48 |
-
crr = score/overs
|
49 |
-
rrr = (runs_left*6)/balls_left
|
50 |
-
|
51 |
-
input_df = pd.DataFrame({'batting_team':[batting_team],'bowling_team':[bowling_team],'city':[selected_city],'runs_left':[runs_left],'balls_left':[balls_left],'wickets':[wickets],'total_runs_x':[target],'crr':[crr],'rrr':[rrr]})
|
52 |
-
|
53 |
-
result = pipe.predict_proba(input_df)
|
54 |
-
loss = result[0][0]
|
55 |
-
win = result[0][1]
|
56 |
-
st.header(batting_team + "- " + str(round(win*100)) + "%")
|
57 |
st.header(bowling_team + "- " + str(round(loss*100)) + "%")
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pickle
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
teams = ['Sunrisers Hyderabad',
|
6 |
+
'Mumbai Indians',
|
7 |
+
'Royal Challengers Bangalore',
|
8 |
+
'Kolkata Knight Riders',
|
9 |
+
'Kings XI Punjab',
|
10 |
+
'Chennai Super Kings',
|
11 |
+
'Rajasthan Royals',
|
12 |
+
'Delhi Capitals']
|
13 |
+
|
14 |
+
cities = ['Hyderabad', 'Bangalore', 'Mumbai', 'Indore', 'Kolkata', 'Delhi',
|
15 |
+
'Chandigarh', 'Jaipur', 'Chennai', 'Cape Town', 'Port Elizabeth',
|
16 |
+
'Durban', 'Centurion', 'East London', 'Johannesburg', 'Kimberley',
|
17 |
+
'Bloemfontein', 'Ahmedabad', 'Cuttack', 'Nagpur', 'Dharamsala',
|
18 |
+
'Visakhapatnam', 'Pune', 'Raipur', 'Ranchi', 'Abu Dhabi',
|
19 |
+
'Sharjah', 'Mohali', 'Bengaluru']
|
20 |
+
|
21 |
+
pipe = pickle.load(open('pipe.pkl','rb'))
|
22 |
+
st.title('IPL Win Predictor')
|
23 |
+
|
24 |
+
col1, col2 = st.columns(2)
|
25 |
+
|
26 |
+
with col1:
|
27 |
+
batting_team = st.selectbox('Select the batting team',sorted(teams))
|
28 |
+
with col2:
|
29 |
+
bowling_team = st.selectbox('Select the bowling team',sorted(teams))
|
30 |
+
|
31 |
+
selected_city = st.selectbox('Select host city',sorted(cities))
|
32 |
+
|
33 |
+
target = st.number_input('Target')
|
34 |
+
|
35 |
+
col3,col4,col5 = st.columns(3)
|
36 |
+
|
37 |
+
with col3:
|
38 |
+
score = st.number_input('Score')
|
39 |
+
with col4:
|
40 |
+
overs = st.number_input('Overs completed')
|
41 |
+
with col5:
|
42 |
+
wickets = st.number_input('Wickets out')
|
43 |
+
|
44 |
+
if st.button('Predict Probability'):
|
45 |
+
runs_left = target - score
|
46 |
+
balls_left = 120 - (overs*6)
|
47 |
+
wickets = 10 - wickets
|
48 |
+
crr = score/overs
|
49 |
+
rrr = (runs_left*6)/balls_left
|
50 |
+
|
51 |
+
input_df = pd.DataFrame({'batting_team':[batting_team],'bowling_team':[bowling_team],'city':[selected_city],'runs_left':[runs_left],'balls_left':[balls_left],'wickets':[wickets],'total_runs_x':[target],'crr':[crr],'rrr':[rrr]})
|
52 |
+
|
53 |
+
result = pipe.predict_proba(input_df)
|
54 |
+
loss = result[0][0]
|
55 |
+
win = result[0][1]
|
56 |
+
st.header(batting_team + "- " + str(round(win*100)) + "%")
|
57 |
st.header(bowling_team + "- " + str(round(loss*100)) + "%")
|