Season matches added to categorize methods

This commit is contained in:
Halal37 2024-01-22 15:59:58 +01:00
parent b52ce30136
commit 651b3562da
3 changed files with 31 additions and 24 deletions

View File

@ -8,9 +8,10 @@ def generateTrainingData(dataframe):
def generateFuzzyLogicData(dataframe):
columns = ['season','date','home_team','away_team','result_full','c_home_passes','c_away_passes',
'c_home_possession','c_away_possession','c_home_shots','c_away_shots','c_home_form','c_away_form',
'c_home_diff', 'c_away_diff']
columns = ['season','date','home_team','away_team','result_full','c_home_form_5m','c_away_form_5m',#,'c_home_passes','c_away_passes',
# 'c_home_possession','c_away_possession','c_home_shots','c_away_shots',
'c_home_diff_5m', 'c_away_diff_5m','c_home_form_season','c_away_form_season',
'c_home_diff_season', 'c_away_diff_season']
return dataframe[columns]
def last5Matches(season, teamA, data, df):

30
main.py
View File

@ -34,22 +34,28 @@ if __name__ == "__main__":
print(calculatePoints(result,'Blackburn Rovers'))
print(calculateGoalDifference(result, 'Blackburn Rovers'))
df = generateTrainingData(df)
df = add_column(df, categorize_passes, "c_away_passes", "away_passes")
df = add_column(df, categorize_passes, "c_home_passes", "home_passes")
# df = generateTrainingData(df)
# df = add_column(df, categorize_passes, "c_away_passes", "away_passes")
# df = add_column(df, categorize_passes, "c_home_passes", "home_passes")
df = add_column(df, categorize_possesion, "c_away_possession", "away_possession")
df = add_column(df, categorize_possesion, "c_home_possession", "home_possession")
# df = add_column(df, categorize_possesion, "c_away_possession", "away_possession")
# df = add_column(df, categorize_possesion, "c_home_possession", "home_possession")
df = add_column(df, categorize_shots, "c_away_shots", "away_shots")
df = add_column(df, categorize_shots, "c_home_shots", "home_shots")
print(df.columns)
# df = add_column(df, categorize_shots, "c_away_shots", "away_shots")
# df = add_column(df, categorize_shots, "c_home_shots", "home_shots")
# print(df.columns)
df = add_column(df, get_method(df, True, categorize_points), "c_home_form")
df = add_column(df, get_method(df, False, categorize_points), "c_away_form")
df = add_column(df, get_method(df, True, categorize_points, last5Matches), "c_home_form_5m")
df = add_column(df, get_method(df, False, categorize_points, last5Matches), "c_away_form_5m")
df = add_column(df, get_method(df, True, categorize_diff), "c_home_diff")#categorize_diff
df = add_column(df, get_method(df, False, categorize_diff), "c_away_diff")
df = add_column(df, get_method(df, True, categorize_diff, last5Matches), "c_home_diff_5m")#categorize_diff
df = add_column(df, get_method(df, False, categorize_diff,last5Matches), "c_away_diff_5m")
df = add_column(df, get_method(df, True, categorize_points, seasonMatches), "c_home_form_season")
df = add_column(df, get_method(df, False, categorize_points, seasonMatches), "c_away_form_season")
df = add_column(df, get_method(df, True, categorize_diff, seasonMatches), "c_home_diff_season")#categorize_diff
df = add_column(df, get_method(df, False, categorize_diff,seasonMatches), "c_away_diff_season")
df = generateFuzzyLogicData(df)

View File

@ -8,7 +8,7 @@ FS = FuzzySystem()
# Jakość strzałów - Witek
# Agresesywnosc (zolte + czerwone kartki) - Wojtek
# odbiory i wslizgi (xDef) - Michał, ekspert od xDef
# statystyki z calego sezonu - Wojtek
# statystyki z calego sezonu - Wojtek OK
# 5 ostatnich spotkan miedzy druzynami - Witek
def categorize_fuzzy_passes(passes,possession):
@ -141,12 +141,12 @@ def categorize_possesion(shots):
else:
return 1
def categorize_points(data, row, teamHome):
def categorize_points(data, row, teamHome, matches_type):
if teamHome:
data_5 = last5Matches(row['season'], row['home_team'], row['date'], data)
data_5 = matches_type(row['season'], row['home_team'], row['date'], data)
points = calculatePoints(data_5,row['home_team'])
else:
data_5 = last5Matches(row['season'], row['away_team'], row['date'], data)
data_5 = matches_type(row['season'], row['away_team'], row['date'], data)
points = calculatePoints(data_5,row['away_team'])
if points <=1:
return 0
@ -155,10 +155,10 @@ def categorize_points(data, row, teamHome):
else:
return 1
def get_method(data, home_away, method):
def get_method(data, home_away, method, matches_type):
values = []
for index, row in data.iterrows():
values.append(method(data, row, home_away))
values.append(method(data, row, home_away, matches_type))
return values
def get_points_home(data):
@ -178,12 +178,12 @@ def get_points_away(data):
def categorize_diff(data, row, teamHome):
def categorize_diff(data, row, teamHome, matches_type):
if teamHome:
data_5 = last5Matches(row['season'], row['home_team'], row['date'], data)
data_5 = matches_type(row['season'], row['home_team'], row['date'], data)
diff = calculateGoalDifference(data_5,row['home_team'])
else:
data_5 = last5Matches(row['season'], row['away_team'], row['date'], data)
data_5 = matches_type(row['season'], row['away_team'], row['date'], data)
diff = calculateGoalDifference(data_5,row['away_team'])
if diff <=0:
return 0