Spaces:
Sleeping
Sleeping
Upload winner%20prediction.py
Browse files- pages/winner%20prediction.py +56 -0
pages/winner%20prediction.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
import joblib
|
4 |
+
|
5 |
+
# Load your trained winner prediction model
|
6 |
+
model = joblib.load("winner_prediction_model.pkl") # Update with your actual model file
|
7 |
+
|
8 |
+
st.title("๐ Cricket Match Winner Prediction")
|
9 |
+
st.markdown("Enter team stats below to predict which team will win the match.")
|
10 |
+
|
11 |
+
# Team names (example teams)
|
12 |
+
teams = ['India', 'Australia', 'England', 'Pakistan', 'Afghanistan',
|
13 |
+
'South Africa', 'New Zealand', 'Sri Lanka', 'West Indies', 'Bangladesh']
|
14 |
+
|
15 |
+
# Select teams
|
16 |
+
team1 = st.selectbox("Select Team 1", teams)
|
17 |
+
team2 = st.selectbox("Select Team 2", [t for t in teams if t != team1])
|
18 |
+
|
19 |
+
st.subheader("๐ฅ Enter Stats for Team 1")
|
20 |
+
team1_batting = st.number_input("Team 1 Batting Score (e.g. total runs, or batting rating)", 0, 10000, 500)
|
21 |
+
team1_bowling = st.number_input("Team 1 Bowling Score (e.g. wickets or bowling rating)", 0, 500, 100)
|
22 |
+
|
23 |
+
st.subheader("๐ฅ Enter Stats for Team 2")
|
24 |
+
team2_batting = st.number_input("Team 2 Batting Score", 0, 10000, 480)
|
25 |
+
team2_bowling = st.number_input("Team 2 Bowling Score", 0, 500, 90)
|
26 |
+
|
27 |
+
# Calculate combined score (you can change the weight if needed)
|
28 |
+
def combined_score(batting, bowling, weight=10):
|
29 |
+
return batting + (bowling * weight)
|
30 |
+
|
31 |
+
team1_combined = combined_score(team1_batting, team1_bowling)
|
32 |
+
team2_combined = combined_score(team2_batting, team2_bowling)
|
33 |
+
|
34 |
+
# Prepare input features for the model
|
35 |
+
features = np.array([[team1_batting, team1_bowling, team1_combined,
|
36 |
+
team2_batting, team2_bowling, team2_combined]])
|
37 |
+
|
38 |
+
# Predict button
|
39 |
+
if st.button("๐ฎ Predict Winner"):
|
40 |
+
prediction = model.predict(features)[0]
|
41 |
+
|
42 |
+
st.success(f"๐ **Predicted Winner: {team1 if prediction == 1 else team2}**")
|
43 |
+
|
44 |
+
st.subheader("๐ Team Comparison")
|
45 |
+
st.write({
|
46 |
+
f"{team1} - Batting": team1_batting,
|
47 |
+
f"{team1} - Bowling": team1_bowling,
|
48 |
+
f"{team1} - Combined": team1_combined,
|
49 |
+
f"{team2} - Batting": team2_batting,
|
50 |
+
f"{team2} - Bowling": team2_bowling,
|
51 |
+
f"{team2} - Combined": team2_combined,
|
52 |
+
})
|
53 |
+
|
54 |
+
# Footer
|
55 |
+
st.markdown("---")
|
56 |
+
st.markdown("Made with โค๏ธ using cricket dataset")
|