I'm designing a model to forecast football results and ultimately the final league table. For this purpose, my training set is a set of adjusted scores derived from the underlying metrics and advanced stats of each team in their previous league games. I want to assign more importance to recent games/fixtures because of changes in tactics, managers, players, etc.
The dataframe looks like this:
| Date | attack_score | defence_score |
|---|---|---|
| 2022-03-18 | 2.3 | 0.4 |
| 2022-03-24 | 1.6 | 1.2 |
| 2022-04-06 | 1.9 | 0.7 |
Then I calculate the mean of the scores. So far, my crude way of introducing a time-factor has been to manually assign arbitrary weights to separate ranges of observations like this:
df['attack_score'].iloc[:-20].mean()*0.4 + df['attack_score'].iloc[-20:].mean()*0.6
However, this is a rather inflexible approach and puts a firm ceiling on how accurate my model can be. Ideally, I'd like to have a function that dynamically and incrementally updates the weights of each observation before the calculation of the mean scores.