-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23ba9ee
commit 596b55c
Showing
6 changed files
with
102 additions
and
42 deletions.
There are no files selected for viewing
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pandas as pd | ||
import torch | ||
from sklearn import preprocessing | ||
from torch.utils.data import Dataset | ||
|
||
pd.set_option('display.max_rows', 50) | ||
pd.set_option('display.max_columns', 30) | ||
pd.set_option('display.width', 1000) | ||
|
||
|
||
class FootballDataset(Dataset): | ||
def __init__(self, csv_file): | ||
self.data = pd.read_csv(csv_file) | ||
self.data.drop( | ||
columns=["game_id", | ||
"date", | ||
"competition_id", | ||
"home_club_name", | ||
"away_club_name", | ||
"competition_type"], | ||
inplace=True) | ||
self.data.dropna(inplace=True) | ||
# self.data.fillna(0, inplace=True) | ||
|
||
# transform all except result columns | ||
x_scaled = preprocessing.MinMaxScaler().fit_transform(self.data) | ||
|
||
# concat scaled and result columns | ||
self.data = pd.DataFrame(x_scaled) | ||
|
||
def __len__(self): | ||
return len(self.data) | ||
|
||
def __getitem__(self, idx): | ||
sample = self.data.iloc[idx] | ||
features = sample[:-3].values.astype(dtype=float) | ||
target = sample[-3:].values.astype(dtype=float) | ||
|
||
return torch.tensor(features, dtype=torch.float32), torch.tensor(target, dtype=torch.float32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import torch | ||
|
||
from main import NeuralNetwork | ||
|
||
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | ||
model = torch.load( | ||
"./models/football_predictor_2024_04_27_18_57_29_model.pt").to(device) | ||
model.eval() | ||
|
||
# current_position_distance | ||
# home_goals_scored | ||
# home_goals_conceded | ||
# home_goal_difference | ||
# away_goals_scored | ||
# away_goals_conceded | ||
# away_goal_difference | ||
# home_last_5_wins | ||
# home_last_5_draws | ||
# home_last_5_losses | ||
# away_last_5_wins | ||
# away_last_5_draws | ||
# away_last_5_losses | ||
# home_season_wins | ||
# home_season_draws | ||
# home_season_losses | ||
# away_season_wins | ||
# away_season_draws | ||
# away_season_losses | ||
|
||
# home_win | ||
# draw | ||
# away_win | ||
|
||
# milan - inter | ||
# data = torch.tensor( | ||
# [1, 63, 37, 24, 77, 17, 60, 3, 1, 1, 3, 2, 0, 21, 6, 6, 27, 5, 1], | ||
# dtype=torch.float).to(device) | ||
|
||
# milan - juve | ||
# data = torch.tensor( | ||
# [1, 47, 26, 21, 64, 39, 25, 1, 3, 1, 3, 1, 1, 18, 10, 5, 21, 6, 6], | ||
# dtype=torch.float).to(device) | ||
|
||
data = torch.tensor( | ||
[1, 62, 20, 42, 58, 24, 34, 5, 0, 0, 5, 0, 0, 22, 5, 4, 22, 6, 4], | ||
dtype=torch.float).to(device) | ||
|
||
output = model(data) | ||
print() | ||
print(f"Prediction (home_win, draw, away_win): {output}") | ||
print( | ||
f"Prediction (home_win, draw, away_win): {torch.nn.functional.softmax(output, dim=0)}") | ||
|
||
predicted = torch.argmax(output, dim=0) | ||
predicted_one_hot = torch.nn.functional.one_hot(predicted, | ||
num_classes=3) | ||
print(f"Prediction one_hot (home_win, draw, away_win): {predicted_one_hot}") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters