Downloads · 30 days
12
8% of all-time downloads
rokati/mlp_xg
mlp_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.
Downloads · 30 days
12
8% of all-time downloads
All-time downloads
146
Public
Repo size
199 KB
Likes
0
Public
Click a slice to open those files.
.pth64.9 KB · 89%
From the Hugging Face model README
This is a Multi-Layer Perceptron (MLP) model trained to predict Expected Goals (xG) in football/soccer.
The model uses the following 22 features:
import torch
import joblib
from huggingface_hub import hf_hub_download
# Download files
model_path = hf_hub_download(repo_id="rokati/mlp_xg", filename="best_mlp_model.pth")
architecture_path = hf_hub_download(repo_id="rokati/mlp_xg", filename="model_architecture.py")
scaler_path = hf_hub_download(repo_id="rokati/mlp_xg", filename="scaler.pkl")
config_path = hf_hub_download(repo_id="rokati/mlp_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=22, 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 or numpy array with the correct features
X_scaled = scaler.transform(X_new)
X_tensor = torch.FloatTensor(X_scaled)
with torch.no_grad():
xg_prediction = model(X_tensor).numpy()
The model was trained on football shot event data with:
MIT