Bettensor commited on
Commit
893341d
·
verified ·
1 Parent(s): 768df7f

copy bettensor soccer model over to org

Browse files
Files changed (5) hide show
  1. Podos_v1_model.py +25 -0
  2. README.md +88 -0
  3. config.json +9 -0
  4. label_encoder.pkl +3 -0
  5. model.safetensors +3 -0
Podos_v1_model.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ from huggingface_hub import PyTorchModelHubMixin
4
+
5
+ class PodosTransformer(nn.Module,PyTorchModelHubMixin):
6
+ def __init__(self, input_dim, model_dim, num_classes, num_heads=4, num_layers=2, dropout=0.1,temperature=1):
7
+ super(PodosTransformer, self).__init__()
8
+ self.temperature = temperature
9
+
10
+ self.projection = nn.Linear(input_dim, model_dim)
11
+ encoder_layer = nn.TransformerEncoderLayer(d_model=model_dim, nhead=num_heads, dropout=dropout)
12
+ self.transformer_encoder = nn.TransformerEncoder(encoder_layer, num_layers=num_layers)
13
+ self.fc = nn.Linear(model_dim, num_classes)
14
+
15
+ def forward(self, x):
16
+ x = self.projection(x)
17
+ x = x.unsqueeze(1)
18
+ x = self.transformer_encoder(x)
19
+ x = x.mean(dim=1)
20
+ x = self.fc(x)
21
+
22
+ if self.temperature != 1.0:
23
+ x = x / self.temperature
24
+
25
+ return x
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ # For reference on model card metadata, see the spec: https://github.com/huggingface/hub-docs/blob/main/modelcard.md?plain=1
3
+ # Doc / guide: https://huggingface.co/docs/hub/model-cards
4
+ {}
5
+ ---
6
+
7
+ # Podos v1 Baseline
8
+
9
+ Podos is a small baseline transformer model for soccer match prediction.
10
+
11
+ ## Model Details
12
+
13
+ ### Model Description
14
+
15
+ - **Developed by:** Bettensor | Nickel5
16
+ - **Model type:** PyTorch Transformer
17
+ - **Parameters** 276K parameters
18
+
19
+ ## Uses
20
+
21
+ Podos predicts soccer match outcomes based on 23 input parameters including sportsbook odds, recent team performance, win/loss streak, and more.
22
+ ### Direct Use
23
+
24
+ For direct use, download the source pytorch class, label_encoder (optional), and load the model. <p><code>PodosTransformer.from_pretrained("Bettensor/podos_soccer_model")</code></p>
25
+ The label encoder contains the id mappings to all teams the model was trained on.
26
+ Ensure you have Torch installed with:
27
+ <p><code>pip install torch</code></p>
28
+ scikit-learn version 1.4.2 if you want to use the label_encoder:
29
+ <p><code>pip install scikit-learn==1.4.2</code></p>
30
+ newer versions of sklearn may work but are untested.
31
+
32
+ You also need HuggingFace_hub and safetensors, install with:
33
+ <p><code>pip install huggingface_hub</code></p>
34
+ <p><code>pip install safetensors</code></p>
35
+
36
+ model expects 23 parameters for input, with team names mapped as ids:
37
+ - HS - Home shots
38
+ - AS - Away shots
39
+ - HST - Home shots on target
40
+ - AST - Away shots on target
41
+ - HC - Home corners
42
+ - AC - Away corners
43
+ - HO - Home offsides
44
+ - AO - Away offsides
45
+ - HY - Home yellow card
46
+ - AY - Away yellow cards
47
+ - HR - Home red cards
48
+ - AR - Away red cards
49
+ - oddsH - Home win odds
50
+ - oddsD - Draw odds
51
+ - oddsA - Away win odds
52
+ - home_encoded - Home team id
53
+ - away_encoded - Away team id
54
+ - WinStreakHome - Home win streak
55
+ - LossStreakHome - home loss streak
56
+ - WinStreakAway - Away win streak
57
+ - LossStreakAway - Away loss streak
58
+ - HomeTeamForm - Home team recent performance
59
+ - AwayTeamForm - Away team recent performance
60
+
61
+ The label_encoder currently contains mappings for 569 unique teams
62
+
63
+ ### Downstream Use
64
+
65
+ Model is available to use with Bettensor at https://github.com/Bettensor/bettensor
66
+
67
+ ## Bias, Risks, and Limitations
68
+
69
+ podos v1 presents some home team bias, and may provide overconfident scores to its predicted outcome.
70
+
71
+ ### Recommendations/Future work
72
+ - reduce bias by encoding home field advantage
73
+ - more teams and leagues, especially with more rigorous performance metrics
74
+ - Additional layers for larger input size
75
+ - team embedding layers
76
+ - individual player performance
77
+
78
+ ### Training Data
79
+ Model was trained on 100,000 games with 569 individual teams.
80
+
81
+ - data source: https://www.football-data.co.uk/downloadm.php
82
+
83
+ ## Model Card Authors
84
+
85
+ qucat | Nickel5
86
+
87
+ ## Model Card Contact
88
+ www.nickel5.com
config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dropout": 0.1,
3
+ "input_dim": 23,
4
+ "model_dim": 32,
5
+ "num_classes": 3,
6
+ "num_heads": 4,
7
+ "num_layers": 2,
8
+ "temperature": 2
9
+ }
label_encoder.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42e212c9b06d38fc01c25d52a2277f2d65168b96a83f7e123acf1b56913d7eb5
3
+ size 6862
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3eae2e96ac1e85de70214c2ff67e547b408a5f54274f53fc60e44ca04d534905
3
+ size 1106428