Spaces:
Sleeping
Sleeping
File size: 2,077 Bytes
5cf88ba 8e36782 5cf88ba |
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 |
import streamlit as st
import numpy as np
import joblib
# Load your trained winner prediction model
model = joblib.load("winner_prediction_model.pkl") # Update with your actual model file
st.title("Cricket Match Winner Prediction")
st.markdown("Enter team stats below to predict which team will win the match.")
# Team names (example teams)
teams = ['India', 'Australia', 'England', 'Pakistan', 'Afghanistan',
'South Africa', 'New Zealand', 'Sri Lanka', 'West Indies', 'Bangladesh']
# Select teams
team1 = st.selectbox("Select Team 1", teams)
team2 = st.selectbox("Select Team 2", [t for t in teams if t != team1])
st.subheader("๐ฅ Enter Stats for Team 1")
team1_batting = st.number_input("Team 1 Batting Score (e.g. total runs, or batting rating)", 0, 10000, 500)
team1_bowling = st.number_input("Team 1 Bowling Score (e.g. wickets or bowling rating)", 0, 500, 100)
st.subheader("๐ฅ Enter Stats for Team 2")
team2_batting = st.number_input("Team 2 Batting Score", 0, 10000, 480)
team2_bowling = st.number_input("Team 2 Bowling Score", 0, 500, 90)
# Calculate combined score (you can change the weight if needed)
def combined_score(batting, bowling, weight=10):
return batting + (bowling * weight)
team1_combined = combined_score(team1_batting, team1_bowling)
team2_combined = combined_score(team2_batting, team2_bowling)
# Prepare input features for the model
features = np.array([[team1_batting, team1_bowling, team1_combined,
team2_batting, team2_bowling, team2_combined]])
# Predict button
if st.button("๐ฎ Predict Winner"):
prediction = model.predict(features)[0]
st.success(f"๐ **Predicted Winner: {team1 if prediction == 1 else team2}**")
st.subheader("๐ Team Comparison")
st.write({
f"{team1} - Batting": team1_batting,
f"{team1} - Bowling": team1_bowling,
f"{team1} - Combined": team1_combined,
f"{team2} - Batting": team2_batting,
f"{team2} - Bowling": team2_bowling,
f"{team2} - Combined": team2_combined,
})
# Footer
st.markdown("---")
|