Downloads · 30 days
8
5% of all-time downloads
rokati/mlp_with_kpis_xg
mlp_with_kpis_xg is a machine learning model from rokati. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch.
This is a Multi-Layer Perceptron (MLP) model trained to predict Expected Goals (xG) in football/soccer. This version includes player-level KPIs (shotsper90 and goalsper90) as additional features to capture individual…
Downloads · 30 days
8
5% of all-time downloads
All-time downloads
156
Public
Repo size
271 KB
Likes
0
Public
Click a slice to open those files.
.pth66.4 KB · 88%
From the Hugging Face model README
This is a Multi-Layer Perceptron (MLP) model trained to predict Expected Goals (xG) in football/soccer. This version includes player-level KPIs (shots_per_90 and goals_per_90) as additional features to capture individual player shooting ability.
This model extends the baseline MLP by incorporating player-specific KPIs:
shots_per_90: Average shots per 90 minutes played by the playergoals_per_90: Average goals per 90 minutes played by the playergoals_percentage: Percentage of shots that result in goalsThese features help the model capture individual player shooting quality and finishing ability beyond just the shot characteristics.
The model uses the following 25 features:
import torch
import joblib
import pandas as pd
from huggingface_hub import hf_hub_download
# Download files
model_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="best_mlp_model.pth")
architecture_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="model_architecture.py")
scaler_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="scaler.pkl")
config_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="config.json")
# Load architecture
import importlib.util
spec = importlib.util.spec_from_file_location("model_architecture", architecture_path)
model_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(model_module)
# Load model
model = model_module.MLP(input_dim=25, hidden_dims=[128, 64, 32], dropout_rate=0.3)
model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
model.eval()
# Load scaler
scaler = joblib.load(scaler_path)
# Make prediction
# X_new should be a pandas DataFrame with all 25 features including player KPIs
X_scaled = scaler.transform(X_new)
X_tensor = torch.FloatTensor(X_scaled)
with torch.no_grad():
xg_prediction = model(X_tensor).numpy()
To use this model, you need:
player_id before making predictionsThe model was trained on football shot event data merged with player KPIs:
MIT