Views
No views yet
shots_per_90 and goals_per_90) as additional features to capture individual player shooting ability.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 goals1import torch
2import joblib
3import pandas as pd
4from huggingface_hub import hf_hub_download
5
6# Download files
7model_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="best_mlp_model.pth")
8architecture_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="model_architecture.py")
9scaler_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="scaler.pkl")
10config_path = hf_hub_download(repo_id="rokati/mlp_with_kpis_xg", filename="config.json")
11
12# Load architecture
13import importlib.util
14spec = importlib.util.spec_from_file_location("model_architecture", architecture_path)
15model_module = importlib.util.module_from_spec(spec)
16spec.loader.exec_module(model_module)
17
18# Load model
19model = model_module.MLP(input_dim=25, hidden_dims=[128, 64, 32], dropout_rate=0.3)
20model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
21model.eval()
22
23# Load scaler
24scaler = joblib.load(scaler_path)
25
26# Make prediction
27# X_new should be a pandas DataFrame with all 25 features including player KPIs
28X_scaled = scaler.transform(X_new)
29X_tensor = torch.FloatTensor(X_scaled)
30with torch.no_grad():
31 xg_prediction = model(X_tensor).numpy()player_id before making predictions