Spaces:
Sleeping
Sleeping
Upload Score%20Prediction.py
Browse files- pages/Score%20Prediction.py +56 -0
pages/Score%20Prediction.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import joblib
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
# Load the trained model
|
6 |
+
model = joblib.load('score_prediction_model.pkl')
|
7 |
+
|
8 |
+
# App title
|
9 |
+
st.title("๐ Team Score Prediction App")
|
10 |
+
st.markdown("Predict a cricket team's score using batting and bowling stats + team name.")
|
11 |
+
|
12 |
+
# Team selection
|
13 |
+
teams = ['India', 'Australia', 'England', 'Pakistan', 'Afghanistan', 'Sri Lanka',
|
14 |
+
'South Africa', 'New Zealand', 'Bangladesh', 'West Indies']
|
15 |
+
|
16 |
+
team_name = st.selectbox("Select Team", teams)
|
17 |
+
|
18 |
+
# Input fields (main page)
|
19 |
+
st.subheader("๐ฅ Enter Team Performance Stats")
|
20 |
+
|
21 |
+
batting_innings = st.slider("Total Batting Innings", 0, 500, 100)
|
22 |
+
total_fours = st.slider("Total Fours", 0, 1000, 250)
|
23 |
+
total_sixes = st.slider("Total Sixes", 0, 800, 150)
|
24 |
+
batting_strike_rate = st.slider("Average Batting Strike Rate", 50.0, 200.0, 95.0)
|
25 |
+
bowling_wickets = st.slider("Total Bowling Wickets", 0, 500, 100)
|
26 |
+
bowling_economy = st.slider("Average Bowling Economy", 3.0, 10.0, 5.5)
|
27 |
+
|
28 |
+
# Encode team if your model used encoded values (optional - only if model trained that way)
|
29 |
+
# from sklearn.preprocessing import LabelEncoder
|
30 |
+
# team_encoder = LabelEncoder()
|
31 |
+
# team_encoded = team_encoder.transform([team_name])[0]
|
32 |
+
|
33 |
+
# Combine features
|
34 |
+
input_features = np.array([[batting_innings, total_fours, total_sixes,
|
35 |
+
batting_strike_rate, bowling_wickets, bowling_economy]])
|
36 |
+
|
37 |
+
# Predict button
|
38 |
+
if st.button("๐ฎ Predict Team Score"):
|
39 |
+
predicted_score = model.predict(input_features)[0]
|
40 |
+
st.success(f"๐ Predicted Score for **{team_name}**: **{int(predicted_score)} Runs**")
|
41 |
+
|
42 |
+
# Display input summary
|
43 |
+
st.subheader("๐ Team Stats You Entered")
|
44 |
+
st.write({
|
45 |
+
"Team": team_name,
|
46 |
+
"Batting Innings": batting_innings,
|
47 |
+
"Fours": total_fours,
|
48 |
+
"Sixes": total_sixes,
|
49 |
+
"Strike Rate": batting_strike_rate,
|
50 |
+
"Bowling Wickets": bowling_wickets,
|
51 |
+
"Bowling Economy": bowling_economy
|
52 |
+
})
|
53 |
+
|
54 |
+
# Footer
|
55 |
+
st.markdown("---")
|
56 |
+
st.markdown("Made with โค๏ธ using your streamlit")
|