This commit is contained in:
@@ -248,8 +248,8 @@ class FeatureEnrichmentService:
|
||||
away_team_venue_total = 0
|
||||
|
||||
for row in rows:
|
||||
sh = int(row['score_home'])
|
||||
sa = int(row['score_away'])
|
||||
sh = int(row['score_home'] or 0)
|
||||
sa = int(row['score_away'] or 0)
|
||||
match_goals = sh + sa
|
||||
total_goals += match_goals
|
||||
|
||||
@@ -284,13 +284,13 @@ class FeatureEnrichmentService:
|
||||
if total >= 6:
|
||||
recent_5_wins = sum(
|
||||
1 for r in rows[:5]
|
||||
if (str(r['home_team_id']) == home_team_id and int(r['score_home']) > int(r['score_away']))
|
||||
or (str(r['home_team_id']) != home_team_id and int(r['score_away']) > int(r['score_home']))
|
||||
if (str(r['home_team_id']) == home_team_id and int(r['score_home'] or 0) > int(r['score_away'] or 0))
|
||||
or (str(r['home_team_id']) != home_team_id and int(r['score_away'] or 0) > int(r['score_home'] or 0))
|
||||
)
|
||||
older_5_wins = sum(
|
||||
1 for r in rows[-5:]
|
||||
if (str(r['home_team_id']) == home_team_id and int(r['score_home']) > int(r['score_away']))
|
||||
or (str(r['home_team_id']) != home_team_id and int(r['score_away']) > int(r['score_home']))
|
||||
if (str(r['home_team_id']) == home_team_id and int(r['score_home'] or 0) > int(r['score_away'] or 0))
|
||||
or (str(r['home_team_id']) != home_team_id and int(r['score_away'] or 0) > int(r['score_home'] or 0))
|
||||
)
|
||||
recent_trend = (recent_5_wins - older_5_wins) / 5.0
|
||||
|
||||
@@ -302,6 +302,12 @@ class FeatureEnrichmentService:
|
||||
- away_team_venue_wins / away_team_venue_total
|
||||
)
|
||||
|
||||
if total == 0:
|
||||
return dict(self._DEFAULT_H2H)
|
||||
if total == 0:
|
||||
return dict(self._DEFAULT_H2H)
|
||||
if total == 0:
|
||||
return dict(self._DEFAULT_H2H)
|
||||
return {
|
||||
'total_matches': total,
|
||||
'home_win_rate': home_wins / total,
|
||||
@@ -366,8 +372,8 @@ class FeatureEnrichmentService:
|
||||
|
||||
for row in rows:
|
||||
is_home = str(row['home_team_id']) == team_id
|
||||
goals_for = int(row['score_home'] if is_home else row['score_away'])
|
||||
goals_against = int(row['score_away'] if is_home else row['score_home'])
|
||||
goals_for = int((row['score_home'] if is_home else row['score_away']) or 0)
|
||||
goals_against = int((row['score_away'] if is_home else row['score_home']) or 0)
|
||||
|
||||
if goals_against == 0:
|
||||
clean_sheets += 1
|
||||
@@ -390,6 +396,15 @@ class FeatureEnrichmentService:
|
||||
else:
|
||||
streak_broken_u = True
|
||||
|
||||
if total == 0:
|
||||
return {'clean_sheet_rate': 0.25, 'scoring_rate': 0.75,
|
||||
'winning_streak': 0, 'unbeaten_streak': 0}
|
||||
if total == 0:
|
||||
return {'clean_sheet_rate': 0.25, 'scoring_rate': 0.75,
|
||||
'winning_streak': 0, 'unbeaten_streak': 0}
|
||||
if total == 0:
|
||||
return {'clean_sheet_rate': 0.25, 'scoring_rate': 0.75,
|
||||
'winning_streak': 0, 'unbeaten_streak': 0}
|
||||
return {
|
||||
'clean_sheet_rate': clean_sheets / total,
|
||||
'scoring_rate': scored_count / total,
|
||||
@@ -433,8 +448,8 @@ class FeatureEnrichmentService:
|
||||
match_ids = []
|
||||
|
||||
for row in rows:
|
||||
sh = int(row['score_home'])
|
||||
sa = int(row['score_away'])
|
||||
sh = int(row['score_home'] or 0)
|
||||
sa = int(row['score_away'] or 0)
|
||||
total_goals += sh + sa
|
||||
if sh > sa:
|
||||
home_wins += 1
|
||||
@@ -464,6 +479,12 @@ class FeatureEnrichmentService:
|
||||
pass
|
||||
|
||||
# home_bias: (actual home win rate) - 0.46 (league average ~46%)
|
||||
if total == 0:
|
||||
return dict(self._DEFAULT_REFEREE)
|
||||
if total == 0:
|
||||
return dict(self._DEFAULT_REFEREE)
|
||||
if total == 0:
|
||||
return dict(self._DEFAULT_REFEREE)
|
||||
home_bias = (home_wins / total) - 0.46
|
||||
|
||||
return {
|
||||
@@ -633,8 +654,8 @@ class FeatureEnrichmentService:
|
||||
over25_count = 0
|
||||
|
||||
for row in rows:
|
||||
sh = int(row['score_home'])
|
||||
sa = int(row['score_away'])
|
||||
sh = int(row['score_home'] or 0)
|
||||
sa = int(row['score_away'] or 0)
|
||||
match_goals = sh + sa
|
||||
total_goals += match_goals
|
||||
if match_goals == 0:
|
||||
@@ -828,8 +849,8 @@ class FeatureEnrichmentService:
|
||||
goals = []
|
||||
conceded_list = []
|
||||
for row in rows:
|
||||
sh = int(row['score_home'])
|
||||
sa = int(row['score_away'])
|
||||
sh = int(row['score_home'] or 0)
|
||||
sa = int(row['score_away'] or 0)
|
||||
if is_home:
|
||||
goals.append(sh)
|
||||
conceded_list.append(sa)
|
||||
|
||||
Reference in New Issue
Block a user