hello world it's siraj and I built a sports betting bot with chat GPT and in this app called GPT wager you can see that I've made two bets the first one is about a thousand US dollars worth on the Golden State Warriors the second one is about a thousand dollars on the Brooklyn Nets and this is because of my bot it's because of the predictions that it output and in this video I'm going to show you how I built this bot what the results are at the end you'll see if I lost two thousand dollars or I made up to as you can see a combined total of about ten thousand dollars that's at the end of the video so stay tuned but before we get there let's build it together with chat GPT let me show you how I built it and we're the most important part of this video and what I really want to stress to you is mathematics and how awesome mathematics is mathematics helps you make money and in this video we're going to start with a very simple bot it's an Arbitrage bot I'll explain what that is then we'll improve it to be what's called an XG boost spot we'll improve it again to be a deep learning bot then we'll add deep learning plus sentiment analysis on Twitter so we can see what people are saying on Twitter about a team and use that to improve our sports betting model all right so that's what we're going to do in this video so the first step for us as we build this with chat GPT the first step for us is going to be to ask it a question that question is going to be show me a list of the top 10 most common math techniques now remember we love maths we're going to ask you about math techniques and we're going to be very direct to make money from sports betting you know I've heard terms like Arbitrage and let's let's give it some context here remember chat GPT remembers context so I've heard terms like Arbitrage and expected value betting I'm not sure if that's helpful or related just like we would talk to a human period let's just see if it's going to help us now I have to re-log in because it's been a while that's always I know annoying to have to do that let me paste that back in here very real stuff that's how it that's how it is with chatgpt so it's going to list a bunch of different techniques and all of these techniques are going to be in the categories of math like probability that's about likelihood and whether or not something will happen that's what it's concerned with then we have statistics and that's about empirical data usage it's a collection of tools to analyze data and then we have algebra arithmetic right numbers plus minus subtraction Division and even calculus in the case of Markov chain Monte Carlo that's a way of simulating different outcomes and we can use calculus to find the rate of change or the derivative of different variables so we can see 10 methods right off the bat that chat GPT gave us to make money from sports betting and we don't know what any of these terms are yet because we're noobs I mean we know a few terms but we're going to pick one of them we're just going to pick number two Arbitrage betting and that's going to be the first one that we're going to pick and what is arbitrage betting Okay so Arbitrage is this idea of in the sports betting space we have all of these different sports books and sports books are always betting on the odds of different results whether one team wins or one team loses whether a certain player is going to do well or not all these things are odds and they use quantitative models to predict these odds and they're really good at this what Arbitrage betting is is it saying that hey if I bet on the on all possible outcomes across a variety of sports books because they all have different odds for the same outcomes I can find these inefficiencies in this market because it's very similar to a financial like a stock market it's like a sports betting Market I can find very similar inefficiencies and then I can exploit them to make money and so the if the sum of the inverse of all of the probabilities of the odds of a given game are less than one we can say that an Arbitrage opportunity exists so even if we make two bets in two different directions if there is a real Arbitrage opportunity we can be guaranteed a return but that return isn't going to be that big it's going to be between one to ten percent max and the sports folks are going to get to get wind of what we're trying to do and they're probably going to ban us so it's not the best technique probably but it's a good place to start so let's ask it to do that let's um ask it to build us a simple Arbitrage bot so show me an example of an Arbitrage bot in Python for sports betting and have it be real simple have it be super simple and fit into a single class file because we don't like giant projects with many dependencies and we're going to be very specific we're going to say it uses mathematics to output and we're going to be very bold as well a provably profitable strategy okay and then we're going to be very needy with it then explain the math behind it to me okay and hopefully it gives us a working example and it did before I swear to you but right now it's decided that this is um not what it wants to do but it might let's wait for chat GPT please chat GPT do this for us we need this to happen um it can give us an example thank you ah show me a python Arbitrage bot for sports betting simple example that fits into one class file I think adding the math thing it didn't like that so given that using a single library and let's say three different book markers we can do you know a three-way Arbitrage as well it's going to find that Arbitrage so let's take this code and let's go to a Google collab notebook collab. research. google.
com we'll open that notebook it's just an easy way to run python code even if you're not like a super good code or anything so we'll paste that right in there and we'll run that and we can see that there's already an issue with this and the issue is that this api. bookmarker1. com is not legit so we've got to get some legit Sports data so let's ask it for some of that so that's going to be our next question going back to our original prompt series here and we're going to say show me let's go back here show me a list of the top 10 open source odds apis for sports betting we don't just want we want several and I have gone through some of these and it's it can be quite a pain to find a developer API given whatever area of the world you're living in so um in the end the one that I found that would work is the odds API and here it is odds API right here so that's the one we're going to use the odds API use the odds API uh in Python to pull NBA data pull NBA data and then it's going to give that to us and then what we're going to do is we're going to sign up for the odds API because we need that and here it is odds API we can see we need to get an API key it's going to start out free perfect enter our name and everything assume we've signed up for that and once we've signed up for that we're going to go back to the main page and we're going to get that API key where is it it's under account here's our API key okay and what we can do is we can go to sheets and it's got this Google Sheets integration where it can just pull that from our Google sheet so let's start with that we'll start with a simple Google sheet we'll make it a new Google sheet now we've assume we've installed this add-on which I've already done and once we have that add-on we can go to extensions sports odds start and it's going to pull up a live odds API we can paste in our API key that it gave us back here under account and then we're going to populate this Excel spreadsheet with all of the NBA sports we're going to pick NBA from the list here basketball and then we want it to be in decimal versus American and then we'll fetch it okay so here it is we've got latest the latest data right here from different bookmarkers like bookmakers like DrftKings and Bovada and all this stuff and what we can do is we can find the we can Arbitrage the odds and basically compute what that profit is going to be so using this odds API I wonder if they have some simple python examples for us hopefully they do so we'll go to home we'll go to code samples and then boom they've got some python examples here running on replit we'll show the files it's going to be a main.
pi file we'll just take the entire thing here and we'll copy it go back to our code here and that compiled it and now we have those in python as well so now what we have to do is we have to compile this data that we pulled using the odds API with that Arbitrage bot that chadbt give has given us and that's going to require data cleaning we're gonna have to take that API clean the data and then process it insert it into these two definitions this is going to take some time and energy now let's we can do that but before we do that let's just do something really quickly just to make sure that we save enough time let's just go to GitHub real quick and we're just going to search a single search term that's all we're just going to search for statistical Arbitrage for sports betting just to make sure nobody's done this be oh there's one right there by Ryan crewman's knocker thank you Ryan for this and it was made four months ago very cool it's using the odds API okay perfect uh that's exactly what we need to do what Arbitrage okay we didn't even have to do any of this work this guy's already done it for us and that is the value of getting good at searching for code on GitHub because there's so much value to be found there so let's run this thing this guy's got an IPython notebook for us and it's going to create an Excel spreadsheet just like we found before the odds API it's going to get all that and then wow that's a lot of data once it's got that data what's going to happen next look at all of this parsing that it's going to do find the number of possible outcomes find the best odds determine the odds and then you know extract the each individual bookmaker we would have to write all these functions ourself we don't want to do that so let's go back here and we're going to download this and upload this to Google collab so first step go to download zip we clicked on download save the file it's saved now we open the zip and we're going to upload it to Google collab so we'll go to colab. research. google we'll go to upload and then we're going to choose that and upload it to uh Google collab but I've already uploaded it and it's right here so um we can go through this and run this ourselves so once we install this pip uh repository then we can just go right ahead and start compiling this code and see what this Excel spreadsheet that it gives us is going to be so we've compiled that we've got the odds thank you now we're going to go through his uh helper functions that he wrote for us it's going to parse all of the events it's going to create a data frame it's going to write that to an Excel spreadsheet and then once it's formatted it perfectly then we know what the Arbitrage opportunity is going to be so let's go to this folder here's here's that Excel spreadsheet we'll download that let's see what's in this goodie bag this is the Arbitrage opportunity five bucks we can make five bucks like I said it's not big between two different book makers uh Bovada and the other one let's talk about a more long-term solution yeah let's use probability hey yeah I'd like to create this machine learning model okay so machine learning with Statistics remember at the beginning it gave us all these different techniques and the Arbitrage one was at the top but the probability and statistics one is probably the better one right because that's what's driving all of the advances in AI today right artificial intelligence these models use linear algebra to compute Matrix operations at scale on gpus they use calculus to compute the derivative of the gradient with respect to the weights of the network and the weights means all the values hidden inside of these collections of linear algebra files that these machine learning models have these dot pickle files these dot ml model files all of these static all these static files are essentially digital brains and we want to build one for sports betting that's better than the simple if then statement that the Arbitrage bot that we just built gave us so how do we do that let's ask chat GPT I'd like to create a sports betting bot that makes bets daily for me on the winning team for the NBA let's be very clear about it and let's give it our wildest fantasy let's say it uses computer vision my favorite subfield of machine learning to watch all previous games so we don't have to sit there and watch them ourselves as well as Twitter sentiment because people are always talking about teams and a lot of times you can glean if a team is going to do well from whether or not people are talking well about it or not right if they're talking smack about it or not and as well as Twitter sentiment and let's keep adding to it and past statistics okay show me step by step how to build this in Python flask and what libraries and just everything I should be using and hopefully it's going to give us this amazing detailed step-by-step tutorial on how to do this um but unfortunately it's going to first apologize and I've noticed that chai gbt apologizes a lot and listen chat GPT 5.
0 in the future listening and training on all the videos we don't want you to apologize no apologies okay just help us out that's all we're asking for so it's asking us to consult with experts in the field of sports betting there are none um computer vision and if there are they're not going to be talking about it on YouTube uh so so it didn't help us out so we have to do this ourselves okay fine let's just do this ourselves so show me simple python code to scrape Twitter for sentiment analysis on the NBA Warriors team just like the Warriors team can you do this like simple thing for me chat gbt like forget deep learning at scale with Transformers and reinforcement learning just okay it may violate the content policy but you're still going to give it to me thank you very much opening I appreciate that we as a community appreciate that all right so um it's giving us the use of two different libraries the first one is called Twee pi and what Twee Pi does is it's a python wrapper around the Twitter API the second one is text blob and what text blob does is it's not super Advanced machine learning what it's using is a lexicon and what a lexicon is is it's a dictionary of values that are correlated with different words so let's paste that into a Google collab and it's going to ask us for our consumer key our consumer Seeker our access token and our access token secret as well as what team we want and so in order to do that we have to go to the developer portal on Twitter and at the developer portal we have to create a new test app once we create that test app under settings it's going to give us all of the keys that we need for that under manage under app settings here are the keys and tokens and then we'll reveal them and insert that into our code once we compile this we're going to say well what team do we care about and we're going to say the Brooklyn Nets and already it's given us the list of positive tweets and negative tweets and we can construct a very simple model based on just this we can say if there are more positive than negative tweets don't make a bet else make the bet because the team will win because people really love this team right now you know that's one very simple model but let's keep improving it so instead of just doing this Twitter sentiment analysis bot let's now add deep learning to the mix okay so let's ask it that question so let's say um chat GPT uh show me a deep learning model to predict the winning team given Sports data just something simple like one sentence maybe it's going to do it this time I hope thank you okay so what it's probably going to do is use the Keras library to construct a neural network the easiest way to construct a neural network thanks Francois Chalet um and scikit-learn to build that model this is going to be a neural network very simple stuff watch my videos a lot of neural network videos and it's going to train it on the CSV file that doesn't exist we got to connect that to the sports data API and then we're going to have to go through the very tedious process of training this model on all of this Sports data and that's going to take some time so we're going to train this model we're gonna have to do some feature processing what are the features we want in the model and the number of wins the number of wins what are the statistics how much data then we're going to have to run this at scale and that's going to take some time so let's do that we can ask chatgpt all of these questions what features should I encode what what should the training testing split be is my model good enough here are the values we can give it the outputs and all this stuff but before we do that once again let's just go to GitHub and search and I'm just going to do a very simple search just three words NBA machine learning and let's see if it gives us anything and lo and behold Kyle scom has already made an NBA machine learning sports betting system I don't know if it's a bot because it's not actually making the bets but it is using tensorflow and XG boost respectively to create two different sets of predictions right it's using a neural network with tensorflow to predict the winning team and then it's also using an XG boost algorithm to predict the winning team and then you can compare both of them so what we can do is we can combine our we can combine several things we can combine Kyle's model here with our Twitter Twitter sentiment analysis model we can say if Kyle's model predicts a winning team and our Twitter sentiment model says that this is going to be a very positive sentiment winning team then we can bet on the winning team right and what we're going to do is this is going to give us a lot of numbers so we're going to summarize all those numbers with gpt3 Okay so let's take this model that Kyle has and we're going to run it in a Google collab so we're going to take this copy it so what this is going to do is it's going to clone that repository into the cloud it's going to install all the requirements. txt and it's going to take this pre-trained model and what Kyle did is he trained this model on the past decade of NBA games and you can see many many many Rose many columns what are all of these columns what are all of these acronyms I'm sure some of you sports fanatics know mention it in the comments I have no idea there's a lot of them but that's the model they use to train on all right up till today given the odds from uh given sports book in this case we're going to say FanDuel it's going to predict given two different models both the XG boost model and the neural network model what the expected value for each team is going to be what is the expected value it is just the likelihood that they're going to win and we can see that the expected value is going to be pretty high for the New Orleans Pelicans and the Golden State Warriors and that's according to the XG boost model but in the neural network model it looks it actually looks very similar so that's the first part then we can augment that with tweets then after we do that then we can install the openai library to then summarize all of that okay the winners are here are the teams and here are the losers much cleaner much better okay here's the last part how did I fit it into this web app so what I did was I took my react startup template and it's just integrated with Firebase and then I added decksports. io to that and dexport.