Updated info

This commit is contained in:
Koushik R Kirugulige 2020-04-25 20:41:18 +05:30
parent 5edbb92b07
commit e28748bc2e

View File

@ -5,7 +5,7 @@
"colab": {
"name": "xGStatsbombBarca.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyMF97QRHrDYc7GbvezxKQ7E",
"authorship_tag": "ABX9TyNQ/Xflwl0BRHHBlkVWMmvt",
"include_colab_link": true
},
"kernelspec": {
@ -702,75 +702,6 @@
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "DmLHncoSWCwg",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 187
},
"outputId": "46d6e21e-32b0-43fd-e0fc-eeeed7e9bf52"
},
"source": [
"main_df['play_pattern_id'].value_counts()"
],
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"1 4646\n",
"3 3026\n",
"4 1954\n",
"2 1818\n",
"6 557\n",
"7 426\n",
"5 223\n",
"9 155\n",
"8 152\n",
"Name: play_pattern_id, dtype: int64"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "BkwL_gQWYF3Z",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "5d3f96c9-a05b-499b-bd65-fc7d8d345c1d"
},
"source": [
"main_df['location'].iloc[0]"
],
"execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[104.4, 41.8]"
]
},
"metadata": {
"tags": []
},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"metadata": {
@ -779,6 +710,7 @@
"colab": {}
},
"source": [
"\"\"\"Distance of shot location to centre of goal\"\"\"\n",
"def distFormula(coordinate):\n",
" a =(math.sqrt(((coordinate.location[0] - 120)**2) + ((coordinate.location[1] - 36)**2))) \n",
" b =(math.sqrt(((coordinate.location[0] - 120)**2) + ((coordinate.location[1] - 44)**2))) \n",
@ -795,7 +727,7 @@
"colab": {}
},
"source": [
"\"\"\" near x y (nx,ny) (100,54)and far x y (fx,fy) (100,46)\"\"\" \n",
"\"\"\" near x y (nx,ny) (120,44)and far x y (fx,fy) (120,36)\"\"\" \n",
"nx = 120\n",
"ny = 44\n",
"fx = 120\n",
@ -1210,6 +1142,16 @@
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "54NSbs9R1HQD",
"colab_type": "text"
},
"source": [
"#xG Model"
]
},
{
"cell_type": "code",
"metadata": {
@ -1253,6 +1195,16 @@
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "mJrKwMAy1Pdl",
"colab_type": "text"
},
"source": [
"**Logistic Regression** Model"
]
},
{
"cell_type": "code",
"metadata": {
@ -1298,6 +1250,16 @@
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "DBQ7Hrsm1WNv",
"colab_type": "text"
},
"source": [
"**SGD** Model"
]
},
{
"cell_type": "code",
"metadata": {
@ -1348,6 +1310,16 @@
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "LVID9Zsn1atX",
"colab_type": "text"
},
"source": [
"Predict Shot Probability"
]
},
{
"cell_type": "code",
"metadata": {
@ -1356,6 +1328,7 @@
"colab": {}
},
"source": [
"# change model here sgcclf(SGD) or clf(LR)\n",
"xG = sgdclf.predict_proba(X_test[['Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne']])[:,1]"
],
"execution_count": 0,
@ -1374,7 +1347,7 @@
},
"source": [
"X_test['xG'] = xG\n",
"X_test.head()"
"#X_test.head()"
],
"execution_count": 101,
"outputs": [
@ -1751,7 +1724,7 @@
" a = plt.scatter(xe,ye,color=\"#fbb021\",edgecolors=\"none\",zorder=6,alpha=0.5,s = 20 ) \n",
" else:\n",
" b = plt.scatter(xe,ye,color=\"#1b8a5a\",edgecolors=\"none\",zorder=4,alpha=0.25,s = 10 ) \n",
"plt.axis('on')\n",
"plt.axis('off')\n",
"plt.legend((g,o,a,b),('>=0.75','>=0.5','>=0.25','<0.25'),scatterpoints=1,loc=2,title = 'xG Value',fontsize='small', fancybox=True)\n",
"#plt.title('xG SGD model')\n",
"#plt.savefig('xgSGDmodel.png')\n",
@ -1801,7 +1774,7 @@
" a = plt.scatter(ye,xe,color=\"#fbb021\",edgecolors=\"none\",zorder=6,alpha=0.5,s = 20 ) \n",
" else:\n",
" b = plt.scatter(ye,xe,color=\"#1b8a5a\",edgecolors=\"none\",zorder=4,alpha=0.25,s = 10 ) \n",
"plt.axis('on')\n",
"plt.axis('off')\n",
"plt.legend((g,o,a,b),('>=0.75','>=0.5','>=0.25','<0.25'),scatterpoints=1,loc=3,title = 'xG Value',fontsize='small', fancybox=True,edgecolor = 'black',framealpha = 2\n",
" )\n",
"\n",