{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n\n# Predictions World Cup 2022\n\n## How it went in 2018\n\nMarius, Jan and myself placed a series of bets on the Wrold Cup 2018 and we won.\nLater I wrote...\n\n\n\nI am always in two minds as to whether to offer gambling tips. In the \nTen Equations I follow Jan and Marius as they start to profit from their gambling\nenterprise. They adopted a scientific approach, while many people looking for\nquick tips do not. This proved to be a common theme when I looked at the role of\nmaths in society: those with the knowledge accumulate financial resources, \nthose without the appropriate training lose out. \n\nNevertheless, it isn't an interesting experiment if we don't make predictions. \nSo here we go...\n\n## Try it in 2022\n\nWe now load in the odds for World Cup 2022 and try to find an edge using the model. \nWhen I collected the odds used here, they were still close to the opening level. \nSo I use the paramters measured for that value. You can upload closing odds \nbefore the match and change the alpha or beta values accordingly.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import pandas as pd\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nalpha = 1.0372197647675445\nbeta = 1.1051122982366652\n\nodds_load = pd.read_csv(\"../data/WC2022.csv\", delimiter=';')\n\ntotprob=1/odds_load['Home']+1/odds_load['Draw']+1/odds_load['Away']\nodds_load = odds_load.assign(homeprob=1/odds_load['Home']/totprob)\nodds_load = odds_load.assign(awayprob=1/odds_load['Away']/totprob)\nodds_load = odds_load.assign(drawprob=1/odds_load['Draw']/totprob) \n \n \n# Calculate in terms of favourite.\nodds_load = odds_load.assign(favodds=np.minimum(odds_load['Home'],odds_load['Away']))\nodds_load = odds_load.assign(underdogodds=np.maximum(odds_load['Home'],odds_load['Away']))\nodds_load = odds_load.assign(favprob=np.maximum(odds_load['homeprob'],odds_load['awayprob']))\nodds_load = odds_load.assign(favfair=1/odds_load['favprob'])\n\n\nodds_load['favourite'] = ''\nodds_load['underdog'] = ''\n\nfor i,odds_row in odds_load.iterrows():\n if (odds_row['homeprob'] > odds_row['awayprob']):\n odds_load.at[i,'favourite'] = odds_row['Home Team']\n odds_load.at[i,'underdog'] = odds_row['Away Team']\n else:\n odds_load.at[i,'favourite'] = odds_row['Away Team']\n odds_load.at[i,'underdog'] = odds_row['Home Team'] \n \nodds_load = odds_load.assign(favnewprob=1/(1+alpha*np.power(odds_load['favfair']-1,beta)))\nodds_load = odds_load.assign(underdognewprob=1-odds_load['favnewprob']-odds_load['drawprob'])\nodds_load = odds_load.assign(favfairodds=1/odds_load['favnewprob'])\nodds_load = odds_load.assign(underdogfairodds=1/odds_load['underdognewprob'])\n\nfor i,odds_row in odds_load.iterrows():\n if (odds_row['favfairodds']