Spaces:
Runtime error
Runtime error
Commit
·
83a5655
1
Parent(s):
a3d78c8
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import pickle
|
4 |
+
|
5 |
+
# Declaring the teams
|
6 |
+
|
7 |
+
|
8 |
+
#st.write("Made_By_Arpon_Mandal")
|
9 |
+
st.set_page_config(
|
10 |
+
page_title="BPL Win Predictor",
|
11 |
+
page_icon="🔥",
|
12 |
+
layout="centered",
|
13 |
+
initial_sidebar_state="auto",
|
14 |
+
)
|
15 |
+
|
16 |
+
st.markdown(
|
17 |
+
"""
|
18 |
+
<h2 style='text-align: center'>
|
19 |
+
BPL Win Predictor
|
20 |
+
</h2>
|
21 |
+
<h6 style='text-align: center'>
|
22 |
+
Made_By_Arpon_Mandal
|
23 |
+
</h6>
|
24 |
+
""",
|
25 |
+
unsafe_allow_html=True,
|
26 |
+
)
|
27 |
+
|
28 |
+
st.markdown(
|
29 |
+
"""
|
30 |
+
<p style='text-align: center'>
|
31 |
+
<a href='https://github.com/arponmandal/BPL-win-prediction' target='_blank'>https://github.com/arponmandal/BPL-win-prediction</a>
|
32 |
+
<br />
|
33 |
+
Follow me for more! <a href='https://www.facebook.com/arpon0007' target='_blank'> <img src="https://img.icons8.com/color/48/000000/facebook.png" height="30"></a><a href='https://github.com/arponmandal' target='_blank'><img src="https://img.icons8.com/fluency/48/000000/github.png" height="27"></a><a href='https://www.linkedin.com/in/arponmandal' target='_blank'><img src="https://img.icons8.com/fluency/48/000000/linkedin.png" height="30"></a>
|
34 |
+
</p>
|
35 |
+
""",
|
36 |
+
unsafe_allow_html=True,
|
37 |
+
)
|
38 |
+
|
39 |
+
st.write("##")
|
40 |
+
|
41 |
+
teams = ['Comilla Victorians',
|
42 |
+
'Fortune Barishal',
|
43 |
+
'Chattogram Challengers',
|
44 |
+
'Khulna Tigers',
|
45 |
+
'Minister Dhaka',
|
46 |
+
'Sylhet Sunrisers',
|
47 |
+
'Rajshahi Royals',
|
48 |
+
'Rangpur Rangers'
|
49 |
+
]
|
50 |
+
|
51 |
+
# declaring the venues
|
52 |
+
|
53 |
+
cities = ['Chattogram', 'Khulna', 'Dhaka', 'Sylhet']
|
54 |
+
|
55 |
+
|
56 |
+
pipe = pickle.load(open('pipe.pkl', 'rb'))
|
57 |
+
#st.title('BPL Win Predictor')
|
58 |
+
|
59 |
+
|
60 |
+
col1, col2 = st.columns(2)
|
61 |
+
|
62 |
+
with col1:
|
63 |
+
battingteam = st.selectbox('Select the batting team', sorted(teams))
|
64 |
+
|
65 |
+
with col2:
|
66 |
+
|
67 |
+
bowlingteam = st.selectbox('Select the bowling team', sorted(teams))
|
68 |
+
|
69 |
+
|
70 |
+
city = st.selectbox(
|
71 |
+
'Select the city where the match is being played', sorted(cities))
|
72 |
+
|
73 |
+
|
74 |
+
target = st.number_input('Target')
|
75 |
+
|
76 |
+
col3, col4, col5 = st.columns(3)
|
77 |
+
|
78 |
+
with col3:
|
79 |
+
score = st.number_input('Score')
|
80 |
+
|
81 |
+
with col4:
|
82 |
+
overs = st.number_input('Overs Completed')
|
83 |
+
|
84 |
+
with col5:
|
85 |
+
wickets = st.number_input('Wickets Fallen')
|
86 |
+
|
87 |
+
|
88 |
+
if st.button('Predict Probability'):
|
89 |
+
|
90 |
+
runs_left = target-score
|
91 |
+
balls_left = 120-(overs*6)
|
92 |
+
wickets = 10-wickets
|
93 |
+
currentrunrate = score/overs
|
94 |
+
requiredrunrate = (runs_left*6)/balls_left
|
95 |
+
|
96 |
+
input_df = pd.DataFrame({'batting_team': [battingteam], 'bowling_team': [bowlingteam], 'city': [city], 'runs_left': [runs_left], 'balls_left': [
|
97 |
+
balls_left], 'wickets': [wickets], 'total_runs_x': [target], 'cur_run_rate': [currentrunrate], 'req_run_rate': [requiredrunrate]})
|
98 |
+
|
99 |
+
result = pipe.predict_proba(input_df)
|
100 |
+
lossprob = result[0][0]
|
101 |
+
winprob = result[0][1]
|
102 |
+
|
103 |
+
st.header(battingteam+"- "+str(round(winprob*100))+"%")
|
104 |
+
|
105 |
+
st.header(bowlingteam+"- "+str(round(lossprob*100))+"%")
|