File size: 1,969 Bytes
8efd853
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3f4d836
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
import streamlit as st
import joblib
import numpy as np

# Load the trained model
model = joblib.load('score_prediction_model.pkl')

# App title
st.title("๐Ÿ Team Score Prediction App")
st.markdown("Predict a cricket team's score using batting and bowling stats + team name.")

# Team selection
teams = ['India', 'Australia', 'England', 'Pakistan', 'Afghanistan', 'Sri Lanka',
         'South Africa', 'New Zealand', 'Bangladesh', 'West Indies']

team_name = st.selectbox("Select Team", teams)

# Input fields (main page)
st.subheader("๐Ÿ“ฅ Enter Team Performance Stats")

batting_innings = st.slider("Total Batting Innings", 0, 500, 100)
total_fours = st.slider("Total Fours", 0, 1000, 250)
total_sixes = st.slider("Total Sixes", 0, 800, 150)
batting_strike_rate = st.slider("Average Batting Strike Rate", 50.0, 200.0, 95.0)
bowling_wickets = st.slider("Total Bowling Wickets", 0, 500, 100)
bowling_economy = st.slider("Average Bowling Economy", 3.0, 10.0, 5.5)

# Encode team if your model used encoded values (optional - only if model trained that way)
# from sklearn.preprocessing import LabelEncoder
# team_encoder = LabelEncoder()
# team_encoded = team_encoder.transform([team_name])[0]

# Combine features
input_features = np.array([[batting_innings, total_fours, total_sixes,
                            batting_strike_rate, bowling_wickets, bowling_economy]])

# Predict button
if st.button("๐Ÿ”ฎ Predict Team Score"):
    predicted_score = model.predict(input_features)[0]
    st.success(f"๐Ÿ Predicted Score for **{team_name}**: **{int(predicted_score)} Runs**")

    # Display input summary
    st.subheader("๐Ÿ“Š Team Stats You Entered")
    st.write({
        "Team": team_name,
        "Batting Innings": batting_innings,
        "Fours": total_fours,
        "Sixes": total_sixes,
        "Strike Rate": batting_strike_rate,
        "Bowling Wickets": bowling_wickets,
        "Bowling Economy": bowling_economy
    })

# Footer
st.markdown("---")