Sports betting is a popular past-time for many and a great use-case for an important concept known as dynamic programming that I’ll introduce in this video. We’ll go over concepts like value iteration, the markov decision process, and the bellman optimality principle, all to help create a system that will help US optimally bet on the winning hockey team in order to maximize profits. Code, animations, theory, and yours truly. Enjoy!

Code for this video:

Please Subscribe! And like. And comment. That’s what keeps me going.

Want more education? Connect with me here:

The School of AI:

Github Syllabus:

More learning resources:

Join us in the Wizards Slack channel:

And please support me on Patreon:

#SirajRaval #SportsBetting #ReinforcementLearning
Signup for my newsletter for exciting updates in the field of AI:
Hiring? Need a Job? See our job board!:

Need help on a project? See our consulting group:
Hit the Join button above to sign up to become a member of my channel for access to exclusive content!

Previous articleBest Bets for UFC Fight Night: Derek Brunson vs. Kevin Holland | ESPN MMA
Next articleHow to make money betting on sports! ($$$ EASY MONEY $$$)


  1. A GUI based click and go approach to sports betting modelling, no programming or ML experience required using MySportsAI

  2. Let me give some insights from a Sports Trader’s perspective.

    1. Almost all sports have handicaps and more importantly handicap opening odds. If the bookmaker things a team is going to win (E.g. for Soccer/Football), they will offer 1.85 for one team and 2.00 for the other. Of course they are thinking that the team with 1.85 odds is going to win and hence winning a 15% spread, or what we term as water money in Asia.

    2. Market Consensus. Without knowing what is the opening odds and tracking the odds movement, one is clueless about the marketing movement. Only by knowing how to track opening odd, odds movement transition and market consensus from multiple sources can a person estimate what is really happening behind the scenes.

    3. Trading Signals. Most people like to use machine learning or deep learning to try to use past results to figure out what is a good trading signal. Unfortunately things doesn’t work out that way for trading. What you do in paper trading and actual trading are totally different. In paper trading, one would take on more risk or less risk compared to actual trading or vice versa. In real trading, it has got to do with the information that was present at that moment, the execution of the trade, trading psychology, capital (bankroll) management and much more. So in short, successful traders are only able to derive strong golden trading signals from real successful trading executions from thousands of trades. Not by running probability tests using machine learning or deep learning. These are only tools that are meant to enhance the probabilities of trades rather than trying to find out trading signals from the scratch.

    4. Trading psychology. Without understanding the limitations of human trading, e.g. Emotional trading, Trading Euphoria (God Mode), it is hard to factor in the different aspects of risk taking into an automated A.I. trading bot for any kinds of trading instruments.

  3. Thank you for simplifying what I learnt at the University of Capetown Computer Science department

  4. The way, you explain. OMG!
    It’s important to look upto to a person as a senior Most Skilled Mentor to Excel in World Of AI .

    Already looking upto you, my Genius Friend!

  5. I’m not very smart so don’t laugh. But doesn’t P change depending on team? Some teams better at home then others. If P is constantly changing because of this will it not produce the same?

  6. how does this code say which team to bet for? I mean we are not feeding any data of the hockey teams here..

  7. High-quality video! Keep producing worthy content and you will expand fast! Subscribe to our channel and so we can subscribe to you!

  8. I have a few questions and found mistakes:
    0) The number 0.4 is not the probability of home team winning but the probability of us winning the bet. For the number 0.4 it means that we do bets even worse than a coin flip.
    1) How did you get a graph shown on 8:25. Your GitHub has a different graph
    2) How did you get a graph in your GitHub:
    The code from your GitHub: produces different results

    There are also two mistakes in your code:
    3) while delta > theta:
    This turns out to be not enough, try to do 500 iterations instead:
    for i in range(500):
    and you will get substantially different results

    4) for bet in range(0, … # Minimum bet should be 1
    Try doing 500 iterations (the point #3) and you will see that almost everywhere optimal policy becomes to take zero bets.

    I create Google Colab Notebook for Siraj’s code:
    And for my code:

  9. Graphics looking very neat! Also loved the BetterExplained-style equation explainer with different colors for each term.

  10. Shouldn’t we discount all future values to the goal for each policy to know which is the best (highest discounted value) policy in a state s ?

  11. The betting is absolutely prohibited in some religions, but I think it is very useful for studying very different fields, such as economy, psychology and Neuro physiology

  12. Could you please make a reinforcement learning demo of the inventory reorder system of a shop, in order to maximize the efficiency of it, given as inputs:
    – date
    – actual inventory
    – sales forecast?
    – other key metrics

    It would be delightful! Thanks in advance 👌🏻👌🏻🇮🇹

  13. t_shirt the school of AI awesome wee need kaggle fo begennir
    siraj how can we get that t_shirt

  14. Siraj! Got a request for you. I’ve recently read about a sports betting technique called “Matched betting” that supposedly eliminates the chance of losing money. It sounds very fishy to me, but yet I’m curious about it. I would like to see if you could make a video explaining it, and maybe even automate it to an extent? All online guides on matched betting are sponsored and aren’t really objective at all. Thanks!!

  15. Loves your technique of teaching Us & Great Course but having problems in installations and need more tutorials from where we can Understand as much as possible @Siraj_Raval Sir 🇮🇳

  16. Im 17 years old and following #100DaysOfMLCode
    And im at #3rd day
    Plz wish me luck
    I want to be part of this fast changing world.

Comments are closed.