File size: 2,835 Bytes
83a5655
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import streamlit as st
import pandas as pd
import pickle

# Declaring the teams


#st.write("Made_By_Arpon_Mandal")
st.set_page_config(
    page_title="BPL Win Predictor",
    page_icon="🔥",
    layout="centered",
    initial_sidebar_state="auto",
)

st.markdown(
    """
    <h2 style='text-align: center'>
    BPL Win Predictor
    </h2>
    <h6 style='text-align: center'>
    Made_By_Arpon_Mandal
    </h6>
    """,
    unsafe_allow_html=True,
)

st.markdown(
    """
    <p style='text-align: center'>
    <a href='https://github.com/arponmandal/BPL-win-prediction' target='_blank'>https://github.com/arponmandal/BPL-win-prediction</a>
    <br />
    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> 
    </p>
    """,
    unsafe_allow_html=True,
)

st.write("##")

teams = ['Comilla Victorians',
         'Fortune Barishal',
         'Chattogram Challengers',
         'Khulna Tigers',
         'Minister Dhaka',
         'Sylhet Sunrisers',
         'Rajshahi Royals',
         'Rangpur Rangers'
         ]

# declaring the venues

cities = ['Chattogram', 'Khulna', 'Dhaka', 'Sylhet']


pipe = pickle.load(open('pipe.pkl', 'rb'))
#st.title('BPL Win Predictor')


col1, col2 = st.columns(2)

with col1:
    battingteam = st.selectbox('Select the batting team', sorted(teams))

with col2:

    bowlingteam = st.selectbox('Select the bowling team', sorted(teams))


city = st.selectbox(
    'Select the city where the match is being played', sorted(cities))


target = st.number_input('Target')

col3, col4, col5 = st.columns(3)

with col3:
    score = st.number_input('Score')

with col4:
    overs = st.number_input('Overs Completed')

with col5:
    wickets = st.number_input('Wickets Fallen')


if st.button('Predict Probability'):

    runs_left = target-score
    balls_left = 120-(overs*6)
    wickets = 10-wickets
    currentrunrate = score/overs
    requiredrunrate = (runs_left*6)/balls_left

    input_df = pd.DataFrame({'batting_team': [battingteam], 'bowling_team': [bowlingteam], 'city': [city], 'runs_left': [runs_left], 'balls_left': [
                            balls_left], 'wickets': [wickets], 'total_runs_x': [target], 'cur_run_rate': [currentrunrate], 'req_run_rate': [requiredrunrate]})

    result = pipe.predict_proba(input_df)
    lossprob = result[0][0]
    winprob = result[0][1]

    st.header(battingteam+"- "+str(round(winprob*100))+"%")

    st.header(bowlingteam+"- "+str(round(lossprob*100))+"%")