0

I'm trying to backtest a sports betting model that calculates probabilities based on last 5 games.

Here I have all the games from last season, but I'm having problems wrapping my mind around how I should approach this.

enter image description here

Each team is given a predetermined ranking id (1,2,3) that'll reflect whether the team is worse, even, or better than the current opponent :

1 Team is Worse 2 Team is Even 3 Team is Better

The model itself calculates:

Wins Losses Goals For Goals Against

These categories will give out points based on what category their opponent was that they won/lost to.

Example: Team A vs. Team B

  • Team A is categorized worse than team B
  • Team A gets 1,3 points for scoring a goal (1*1,3)

Example: Team A vs. Team B

  • Team A is categorized better than Team B
  • Team A gets 1 point for scoring a goal

Pseudo:

I can do this team by team basis, but I would need to iterate through their match history in 5 indexed rows at a time, and then counting the probabilities for the 6th match. Here's an example what indexed rows I'd need to calculate the probabilities for Team A's match number 6 and 7

To calculate match number 6, I need rows: 0,1,2,3,4

To calculate match number 7, I need rows: 1,2,3,4,5

....So basically last 5 matches needs to be accounted.

  • It's always a good practice to provide your data in a minimal reproducible example ([here's the guide](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples)), rather than a picture. Providing a brief piece of code works much better towards encouraging other users to answer your question, since they could simply reproduce it. – Nikita Shabankin Sep 22 '22 at 01:57
  • 1
    Thank you. I tried to post the code but no matter what I did, I always got the error from stackoverflow that I have code in my question that isn't formatted properly. I couldn't figure out how to fix that to save my life. – codeinecoder Sep 22 '22 at 07:19
  • I recently had the same problem. Either wrapping the markdown table in ``` or adding a new line somewhere around it helped. You may try copying `df.to_markdown()` format output too. – Nikita Shabankin Sep 22 '22 at 07:33

0 Answers0