sportowe_wizualizacja/xGStatsbomb.ipynb

1836 lines
233 KiB
Plaintext
Raw Normal View History

2020-04-25 16:52:24 +02:00
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
2020-04-25 17:13:12 +02:00
"name": "xGStatsbomb.ipynb",
2020-04-25 16:52:24 +02:00
"provenance": [],
2020-04-25 17:13:12 +02:00
"authorship_tag": "ABX9TyP4BsBlm9b0/iB3JUbOMLVZ",
2020-04-25 16:52:24 +02:00
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
2020-04-25 17:13:12 +02:00
"<a href=\"https://colab.research.google.com/github/koushikkirugulige/Football-Analytics/blob/master/xGStatsbomb.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
2020-04-25 16:52:24 +02:00
]
},
{
"cell_type": "code",
"metadata": {
"id": "g37QpaaPZHA5",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 187
},
"outputId": "c8ee2fc2-3a61-41a1-dc0a-c5b738da11d3"
},
"source": [
"%%time\n",
"!git clone https://github.com/statsbomb/open-data.git"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Cloning into 'open-data'...\n",
"remote: Enumerating objects: 1088, done.\u001b[K\n",
"remote: Counting objects: 100% (1088/1088), done.\u001b[K\n",
"remote: Compressing objects: 100% (591/591), done.\u001b[K\n",
"remote: Total 9810 (delta 893), reused 674 (delta 479), pack-reused 8722\u001b[K\n",
"Receiving objects: 100% (9810/9810), 995.57 MiB | 14.28 MiB/s, done.\n",
"Resolving deltas: 100% (8640/8640), done.\n",
"Checking out files: 100% (1648/1648), done.\n",
"CPU times: user 548 ms, sys: 115 ms, total: 663 ms\n",
"Wall time: 2min 44s\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "nd6vcG3uZNJb",
"colab_type": "code",
"colab": {}
},
"source": [
"#import all modules\n",
"import json\n",
"import os\n",
"import codecs\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib.patches import Arc, Rectangle, ConnectionPatch\n",
"from matplotlib.offsetbox import OffsetImage\n",
"from matplotlib.patches import Ellipse\n",
"from functools import reduce\n",
"import math"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "5NMxa9NNZR5m",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 68
},
"outputId": "133de3d7-2515-4ec6-f479-d4c69cee4f8c"
},
"source": [
"%%time\n",
"comp = ['FIFA World Cup','La Liga']\n",
"main_df = pd.DataFrame(data=None)\n",
"path_match = \"/content/open-data/data/events/\" #location for play by play events\n",
"for root, dirs, files in os.walk('/content/open-data/data/matches/'):\n",
" for file in files:\n",
" with open(os.path.join(root, file), \"r\") as auto:\n",
" with codecs.open(root + str('/') + file,encoding='utf-8') as data_file:\n",
" data = json.load(data_file)\n",
" df = pd.DataFrame(data=None)\n",
" df = pd.json_normalize(data, sep = \"_\")\n",
" #for x in df.competition_country_name:\n",
" # if x == 'Spain':\n",
" # print(df.match_id)\n",
" #print(df['competition_competition_name'])\n",
" for i in range(len(df)):\n",
" if df.iloc[i]['competition_competition_name'] in comp :\n",
" match_no = df.iloc[i]['match_id'] #gets match with Spain as country\n",
" match_no = str(match_no) # from int to str \n",
" #print('match list \\n',match_no)\n",
" with codecs.open(path_match + match_no + str(r'.json'),encoding=\"utf8\") as event_file: #open the respective file\n",
" df_match = json.load(event_file)\n",
" df_match2 = pd.DataFrame(data=None)\n",
" df_match2 = pd.json_normalize(df_match,sep=\"_\") \n",
" df_match2 = df_match2[(df_match2['type_name'] == \"Shot\")]\n",
" main_df = main_df.append(df_match2,ignore_index=True,sort=False) \n",
"#print('total matches ',len(match_no)) \n",
"print('Done')"
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": [
"Done\n",
"CPU times: user 6min 3s, sys: 1.3 s, total: 6min 4s\n",
"Wall time: 6min 4s\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "waQI6t6OVM33",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 508
},
"outputId": "59fa3bca-64b8-4260-b33a-b34cbfdd9248"
},
"source": [
"main_df.head()"
],
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>index</th>\n",
" <th>period</th>\n",
" <th>timestamp</th>\n",
" <th>minute</th>\n",
" <th>second</th>\n",
" <th>possession</th>\n",
" <th>duration</th>\n",
" <th>type_id</th>\n",
" <th>type_name</th>\n",
" <th>possession_team_id</th>\n",
" <th>possession_team_name</th>\n",
" <th>play_pattern_id</th>\n",
" <th>play_pattern_name</th>\n",
" <th>team_id</th>\n",
" <th>team_name</th>\n",
" <th>tactics_formation</th>\n",
" <th>tactics_lineup</th>\n",
" <th>related_events</th>\n",
" <th>location</th>\n",
" <th>player_id</th>\n",
" <th>player_name</th>\n",
" <th>position_id</th>\n",
" <th>position_name</th>\n",
" <th>pass_recipient_id</th>\n",
" <th>pass_recipient_name</th>\n",
" <th>pass_length</th>\n",
" <th>pass_angle</th>\n",
" <th>pass_height_id</th>\n",
" <th>pass_height_name</th>\n",
" <th>pass_end_location</th>\n",
" <th>pass_type_id</th>\n",
" <th>pass_type_name</th>\n",
" <th>pass_body_part_id</th>\n",
" <th>pass_body_part_name</th>\n",
" <th>carry_end_location</th>\n",
" <th>under_pressure</th>\n",
" <th>pass_outcome_id</th>\n",
" <th>pass_outcome_name</th>\n",
" <th>pass_aerial_won</th>\n",
" <th>...</th>\n",
" <th>substitution_outcome_id</th>\n",
" <th>substitution_outcome_name</th>\n",
" <th>substitution_replacement_id</th>\n",
" <th>substitution_replacement_name</th>\n",
" <th>shot_one_on_one</th>\n",
" <th>bad_behaviour_card_id</th>\n",
" <th>bad_behaviour_card_name</th>\n",
" <th>50_50_outcome_id</th>\n",
" <th>50_50_outcome_name</th>\n",
" <th>dribble_overrun</th>\n",
" <th>goalkeeper_punched_out</th>\n",
" <th>pass_miscommunication</th>\n",
" <th>block_deflection</th>\n",
" <th>pass_goal_assist</th>\n",
" <th>clearance_other</th>\n",
" <th>injury_stoppage_in_chain</th>\n",
" <th>shot_deflected</th>\n",
" <th>dribble_no_touch</th>\n",
" <th>pass_deflected</th>\n",
" <th>shot_saved_off_target</th>\n",
" <th>goalkeeper_shot_saved_off_target</th>\n",
" <th>ball_recovery_offensive</th>\n",
" <th>pass_straight</th>\n",
" <th>foul_committed_penalty</th>\n",
" <th>foul_won_penalty</th>\n",
" <th>block_save_block</th>\n",
" <th>shot_open_goal</th>\n",
" <th>goalkeeper_lost_out</th>\n",
" <th>goalkeeper_success_in_play</th>\n",
" <th>player_off_permanent</th>\n",
" <th>goalkeeper_shot_saved_to_post</th>\n",
" <th>shot_redirect</th>\n",
" <th>shot_saved_to_post</th>\n",
" <th>shot_follows_dribble</th>\n",
" <th>goalkeeper_success_out</th>\n",
" <th>half_start_late_video_start</th>\n",
" <th>goalkeeper_lost_in_play</th>\n",
" <th>goalkeeper_saved_to_post</th>\n",
" <th>pass_backheel</th>\n",
" <th>half_end_early_video_end</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2f046b33-685c-4122-8af2-8ceadf56c83d</td>\n",
" <td>294</td>\n",
" <td>1</td>\n",
" <td>00:06:50.216</td>\n",
" <td>6</td>\n",
" <td>50</td>\n",
" <td>12</td>\n",
" <td>0.115400</td>\n",
" <td>16</td>\n",
" <td>Shot</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>4</td>\n",
" <td>From Throw In</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[58295c63-1ffa-4e27-9258-818ea90c6b04, f514442...</td>\n",
" <td>[104.4, 41.8]</td>\n",
" <td>5503.0</td>\n",
" <td>Lionel Andrés Messi Cuccittini</td>\n",
" <td>17.0</td>\n",
" <td>Right Wing</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>855d47fc-9017-4508-8b41-0275dfb4d755</td>\n",
" <td>962</td>\n",
" <td>1</td>\n",
" <td>00:22:27.038</td>\n",
" <td>22</td>\n",
" <td>27</td>\n",
" <td>38</td>\n",
" <td>2.046458</td>\n",
" <td>16</td>\n",
" <td>Shot</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>2</td>\n",
" <td>From Corner</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[aec80f5c-807e-47ac-8c33-092c92b222d1]</td>\n",
" <td>[110.8, 35.8]</td>\n",
" <td>5470.0</td>\n",
" <td>Ivan Rakitić</td>\n",
" <td>10.0</td>\n",
" <td>Center Defensive Midfield</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>7c69fb86-c77d-463b-8f00-503e447492a4</td>\n",
" <td>1153</td>\n",
" <td>1</td>\n",
" <td>00:27:08.522</td>\n",
" <td>27</td>\n",
" <td>8</td>\n",
" <td>46</td>\n",
" <td>0.804175</td>\n",
" <td>16</td>\n",
" <td>Shot</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>2</td>\n",
" <td>From Corner</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[350f13e2-16cc-449d-a72d-f7ccd571fc50, 662299b...</td>\n",
" <td>[109.9, 40.5]</td>\n",
" <td>5492.0</td>\n",
" <td>Samuel Yves Umtiti</td>\n",
" <td>5.0</td>\n",
" <td>Left Center Back</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>True</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>77ea8775-f9f4-4bf7-b3f9-7635ab861ab5</td>\n",
" <td>1254</td>\n",
" <td>1</td>\n",
" <td>00:30:13.151</td>\n",
" <td>30</td>\n",
" <td>13</td>\n",
" <td>59</td>\n",
" <td>0.380900</td>\n",
" <td>16</td>\n",
" <td>Shot</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>3</td>\n",
" <td>From Free Kick</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[30b9d0e1-5eeb-4cb0-86ea-a6e8967893e2, ae620c7...</td>\n",
" <td>[90.0, 36.2]</td>\n",
" <td>5503.0</td>\n",
" <td>Lionel Andrés Messi Cuccittini</td>\n",
" <td>17.0</td>\n",
" <td>Right Wing</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>09c2667a-4827-4871-a70a-96adb1d73243</td>\n",
" <td>1381</td>\n",
" <td>1</td>\n",
" <td>00:33:19.875</td>\n",
" <td>33</td>\n",
" <td>19</td>\n",
" <td>63</td>\n",
" <td>0.222600</td>\n",
" <td>16</td>\n",
" <td>Shot</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>4</td>\n",
" <td>From Throw In</td>\n",
" <td>217</td>\n",
" <td>Barcelona</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>[19491e5f-dd7c-47a8-994d-b6aae0630b55, a81b342...</td>\n",
" <td>[97.3, 28.8]</td>\n",
" <td>6998.0</td>\n",
" <td>Rafael Alcântara do Nascimento</td>\n",
" <td>15.0</td>\n",
" <td>Left Center Midfield</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 147 columns</p>\n",
"</div>"
],
"text/plain": [
" id ... half_end_early_video_end\n",
"0 2f046b33-685c-4122-8af2-8ceadf56c83d ... NaN\n",
"1 855d47fc-9017-4508-8b41-0275dfb4d755 ... NaN\n",
"2 7c69fb86-c77d-463b-8f00-503e447492a4 ... NaN\n",
"3 77ea8775-f9f4-4bf7-b3f9-7635ab861ab5 ... NaN\n",
"4 09c2667a-4827-4871-a70a-96adb1d73243 ... NaN\n",
"\n",
"[5 rows x 147 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "WPZPi5M7ZI5o",
"colab_type": "code",
"colab": {}
},
"source": [
2020-04-25 17:11:18 +02:00
"\"\"\"Distance of shot location to centre of goal\"\"\"\n",
2020-04-25 16:52:24 +02:00
"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",
" return ((a+b)/2)"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ZRX43XViZshf",
"colab_type": "code",
"colab": {}
},
"source": [
2020-04-25 17:11:18 +02:00
"\"\"\" near x y (nx,ny) (120,44)and far x y (fx,fy) (120,36)\"\"\" \n",
2020-04-25 16:52:24 +02:00
"nx = 120\n",
"ny = 44\n",
"fx = 120\n",
"fy = 36\n",
"\n",
"goalpostLength = 8\n",
"def shot_angle(points):\n",
" len1 = (math.sqrt(((points.location[0] - nx)**2) + ((points.location[1] - ny)**2))) \n",
" len2 = (math.sqrt(((points.location[0] - fx)**2) + ((points.location[1] - fy)**2)))\n",
" ang = (len1**2 + len2**2 - goalpostLength**2)/(2 * len1 * len2)\n",
" if ang > 1:\n",
" ang = 1\n",
" elif ang < -1:\n",
" ang = -1 \n",
" angRad = math.acos(ang)\n",
" return( (angRad * 180)/math.pi) "
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Skzv7m2GcOek",
"colab_type": "code",
"colab": {}
},
"source": [
"\"\"\"If shot was taken under Pressure?\"\"\"\n",
"def under_pressure(coordinate):\n",
" if coordinate['under_pressure'] == True:\n",
" return 1\n",
" return 0"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "VRBmlZBtdbCf",
"colab_type": "code",
"colab": {}
},
"source": [
"\"\"\"The Shot type Id\"\"\"\n",
"def shot_type(coordinate):\n",
" if coordinate['shot_type_id'] == 61:\n",
" return 1\n",
" if coordinate['shot_type_id'] == 62:\n",
" return 2\n",
" if coordinate['shot_type_id'] == 87:\n",
" return 3\n",
" if coordinate['shot_type_id'] == 88:\n",
" return 4\n",
" return 5"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "SfSB2laheYY4",
"colab_type": "code",
"colab": {}
},
"source": [
"\"\"\"The Shot Body part\"\"\"\n",
"def shot_body_part(coordinate):\n",
" if coordinate['shot_body_part_id'] == 37:\n",
" return 1\n",
" if coordinate['shot_body_part_id'] == 38:\n",
" return 2\n",
" if coordinate['shot_body_part_id'] == 70:\n",
" return 3\n",
" return 4"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "XshqSKelezC2",
"colab_type": "code",
"colab": {}
},
"source": [
"\"\"\"The Shot Technique Id\"\"\"\n",
"def shot_technique(coordinate):\n",
" if coordinate['shot_technique_id'] == 89:\n",
" return 1\n",
" if coordinate['shot_technique_id'] == 90:\n",
" return 2\n",
" if coordinate['shot_technique_id'] == 91:\n",
" return 3\n",
" if coordinate['shot_technique_id'] == 92:\n",
" return 4\n",
" if coordinate['shot_technique_id'] == 93:\n",
" return 5\n",
" if coordinate['shot_technique_id'] == 94:\n",
" return 6\n",
" return 7"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "7DLY4vXtffsL",
"colab_type": "code",
"colab": {}
},
"source": [
"\"\"\"If shot was taken first time?\"\"\"\n",
"def shot_first_time(coordinate):\n",
" if coordinate['shot_first_time'] == True:\n",
" return 1\n",
" return 0"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "U0pQQZPDf4oV",
"colab_type": "code",
"colab": {}
},
"source": [
"\"\"\"If shot was taken first time?\"\"\"\n",
"def shot_one_on_one(coordinate):\n",
" if coordinate['shot_one_on_one'] == True:\n",
" return 1\n",
" return 0"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "J2Qd_aEHZaja",
"colab_type": "code",
"colab": {}
},
"source": [
"main_df['Distance'] = main_df.apply(distFormula,axis = 1)\n",
"main_df['Angle'] = main_df.apply(shot_angle,axis = 1)\n",
"main_df['UnderPressure'] = main_df.apply(under_pressure,axis = 1)\n",
"main_df['ShotType'] = main_df.apply(shot_type,axis = 1)\n",
"main_df['ShotBodyPart'] = main_df.apply(shot_body_part,axis = 1)\n",
"main_df['ShotTechnique'] = main_df.apply(shot_technique,axis = 1)\n",
"main_df['ShotFirstTime'] = main_df.apply(shot_first_time,axis = 1)\n",
"main_df['ShotOneonOne']= main_df.apply(shot_one_on_one,axis = 1)"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "VbP_YO_tg694",
"colab_type": "code",
"colab": {}
},
"source": [
"goals_lst = main_df[main_df['shot_outcome_id'] == 97].index.tolist()"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "e4X-RpdOguqH",
"colab_type": "code",
"colab": {}
},
"source": [
"#if shot is a goal \n",
"main_df['isGoal'] = False\n",
"goals_lst\n",
"main_df.loc[main_df.index.isin(goals_lst),'isGoal'] = True"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "ddhlIVCHbZ-_",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 419
},
"outputId": "aa8e71b7-9573-4a33-e875-0542680136ef"
},
"source": [
"main_df[['location','Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne','isGoal']]"
],
"execution_count": 62,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>location</th>\n",
" <th>Distance</th>\n",
" <th>Angle</th>\n",
" <th>UnderPressure</th>\n",
" <th>ShotType</th>\n",
" <th>ShotBodyPart</th>\n",
" <th>ShotTechnique</th>\n",
" <th>ShotFirstTime</th>\n",
" <th>ShotOneonOne</th>\n",
" <th>isGoal</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>[104.4, 41.8]</td>\n",
" <td>16.198841</td>\n",
" <td>28.422114</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>[110.8, 35.8]</td>\n",
" <td>10.763067</td>\n",
" <td>40.465393</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>[109.9, 40.5]</td>\n",
" <td>10.873186</td>\n",
" <td>43.128076</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>[90.0, 36.2]</td>\n",
" <td>30.499043</td>\n",
" <td>14.956182</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>[97.3, 28.8]</td>\n",
" <td>25.566766</td>\n",
" <td>16.208386</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12952</th>\n",
" <td>[111.0, 27.0]</td>\n",
" <td>15.981653</td>\n",
" <td>17.102729</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12953</th>\n",
" <td>[114.0, 33.0]</td>\n",
" <td>9.619084</td>\n",
" <td>34.824489</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12954</th>\n",
" <td>[107.0, 32.0]</td>\n",
" <td>15.646638</td>\n",
" <td>25.606661</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12955</th>\n",
" <td>[97.0, 22.0]</td>\n",
" <td>29.376742</td>\n",
" <td>12.398277</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12956</th>\n",
" <td>[109.0, 52.0]</td>\n",
" <td>16.508979</td>\n",
" <td>19.464104</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>12957 rows × 10 columns</p>\n",
"</div>"
],
"text/plain": [
" location Distance Angle ... ShotFirstTime ShotOneonOne isGoal\n",
"0 [104.4, 41.8] 16.198841 28.422114 ... 1 0 False\n",
"1 [110.8, 35.8] 10.763067 40.465393 ... 0 0 False\n",
"2 [109.9, 40.5] 10.873186 43.128076 ... 0 0 False\n",
"3 [90.0, 36.2] 30.499043 14.956182 ... 0 0 False\n",
"4 [97.3, 28.8] 25.566766 16.208386 ... 0 0 False\n",
"... ... ... ... ... ... ... ...\n",
"12952 [111.0, 27.0] 15.981653 17.102729 ... 0 0 False\n",
"12953 [114.0, 33.0] 9.619084 34.824489 ... 0 0 True\n",
"12954 [107.0, 32.0] 15.646638 25.606661 ... 0 0 False\n",
"12955 [97.0, 22.0] 29.376742 12.398277 ... 0 0 False\n",
"12956 [109.0, 52.0] 16.508979 19.464104 ... 0 0 False\n",
"\n",
"[12957 rows x 10 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 62
}
]
},
2020-04-25 17:11:18 +02:00
{
"cell_type": "markdown",
"metadata": {
"id": "54NSbs9R1HQD",
"colab_type": "text"
},
"source": [
"#xG Model"
]
},
2020-04-25 16:52:24 +02:00
{
"cell_type": "code",
"metadata": {
"id": "KCl0-Opqhxx-",
"colab_type": "code",
"colab": {}
},
"source": [
"from sklearn.model_selection import train_test_split\n",
"from sklearn.linear_model import LogisticRegression\n",
"import xgboost as xgb\n",
"from sklearn import svm\n",
"from sklearn import linear_model"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Q5_VKZrBhyRi",
"colab_type": "code",
"colab": {}
},
"source": [
"xgModel = main_df[['location','Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne','isGoal']]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "WOLF5IqBh1Nx",
"colab_type": "code",
"colab": {}
},
"source": [
"X_train,X_test,y_train,y_test = train_test_split(xgModel[['location','Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne']],xgModel['isGoal'],test_size = 0.2,shuffle = True)"
],
"execution_count": 0,
"outputs": []
},
2020-04-25 17:11:18 +02:00
{
"cell_type": "markdown",
"metadata": {
"id": "mJrKwMAy1Pdl",
"colab_type": "text"
},
"source": [
"**Logistic Regression** Model"
]
},
2020-04-25 16:52:24 +02:00
{
"cell_type": "code",
"metadata": {
"id": "fwxMcSWQiCbw",
"colab_type": "code",
"colab": {}
},
"source": [
"clf = LogisticRegression(random_state=0,max_iter = 5000).fit(X_train[['Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne']], y_train)"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "v2sAXpKaiS7d",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 51
},
"outputId": "e53dfd53-f6db-45f5-a800-1c7b3bea10e4"
},
"source": [
"#model weights\n",
"clf.coef_[0]"
],
"execution_count": 99,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([-0.06605534, 0.02878253, -0.60546461, 1.03559372, 0.18762927,\n",
" 0.01151648, 0.18877916, 0.57099517])"
]
},
"metadata": {
"tags": []
},
"execution_count": 99
}
]
},
2020-04-25 17:11:18 +02:00
{
"cell_type": "markdown",
"metadata": {
"id": "DBQ7Hrsm1WNv",
"colab_type": "text"
},
"source": [
"**SGD** Model"
]
},
2020-04-25 16:52:24 +02:00
{
"cell_type": "code",
"metadata": {
"id": "02YCl85sicPO",
"colab_type": "code",
"colab": {}
},
"source": [
"xG = clf.predict_proba(X_test[['Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne']])[:,1]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "WmD0Au5iv0Lh",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 119
},
"outputId": "9f6610d6-0166-410b-a5df-10107647e772"
},
"source": [
"#SGD\n",
"sgdclf = linear_model.SGDClassifier(loss='log', alpha = 0.17)\n",
"sgdclf.fit(X_train[['Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne']], y_train)"
],
"execution_count": 77,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"SGDClassifier(alpha=0.17, average=False, class_weight=None,\n",
" early_stopping=False, epsilon=0.1, eta0=0.0, fit_intercept=True,\n",
" l1_ratio=0.15, learning_rate='optimal', loss='log', max_iter=1000,\n",
" n_iter_no_change=5, n_jobs=None, penalty='l2', power_t=0.5,\n",
" random_state=None, shuffle=True, tol=0.001,\n",
" validation_fraction=0.1, verbose=0, warm_start=False)"
]
},
"metadata": {
"tags": []
},
"execution_count": 77
}
]
},
2020-04-25 17:11:18 +02:00
{
"cell_type": "markdown",
"metadata": {
"id": "LVID9Zsn1atX",
"colab_type": "text"
},
"source": [
2020-04-25 17:13:12 +02:00
"**Predict** Shot Probability"
2020-04-25 17:11:18 +02:00
]
},
2020-04-25 16:52:24 +02:00
{
"cell_type": "code",
"metadata": {
"id": "P8yo8gQev-q8",
"colab_type": "code",
"colab": {}
},
"source": [
2020-04-25 17:11:18 +02:00
"# change model here sgcclf(SGD) or clf(LR)\n",
2020-04-25 16:52:24 +02:00
"xG = sgdclf.predict_proba(X_test[['Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne']])[:,1]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "xL2vLcVfihcb",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "2e44cbbb-3847-46f3-e5b1-ed8fc46f4620"
},
"source": [
"X_test['xG'] = xG\n",
2020-04-25 17:11:18 +02:00
"#X_test.head()"
2020-04-25 16:52:24 +02:00
],
"execution_count": 101,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>location</th>\n",
" <th>Distance</th>\n",
" <th>Angle</th>\n",
" <th>UnderPressure</th>\n",
" <th>ShotType</th>\n",
" <th>ShotBodyPart</th>\n",
" <th>ShotTechnique</th>\n",
" <th>ShotFirstTime</th>\n",
" <th>ShotOneonOne</th>\n",
" <th>xG</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2961</th>\n",
" <td>[92.2, 58.9]</td>\n",
" <td>33.779300</td>\n",
" <td>11.289656</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.035840</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10990</th>\n",
" <td>[115.2, 45.8]</td>\n",
" <td>8.019390</td>\n",
" <td>43.348531</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0.340789</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12649</th>\n",
" <td>[115.0, 41.0]</td>\n",
" <td>6.451010</td>\n",
" <td>75.963757</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.453033</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5264</th>\n",
" <td>[111.9, 32.5]</td>\n",
" <td>11.445052</td>\n",
" <td>31.472019</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.082841</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9283</th>\n",
" <td>[111.6, 37.0]</td>\n",
" <td>9.696832</td>\n",
" <td>46.594546</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.135449</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" location Distance ... ShotOneonOne xG\n",
"2961 [92.2, 58.9] 33.779300 ... 0 0.035840\n",
"10990 [115.2, 45.8] 8.019390 ... 1 0.340789\n",
"12649 [115.0, 41.0] 6.451010 ... 0 0.453033\n",
"5264 [111.9, 32.5] 11.445052 ... 0 0.082841\n",
"9283 [111.6, 37.0] 9.696832 ... 0 0.135449\n",
"\n",
"[5 rows x 10 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 101
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "q2BO-NLSijd5",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 419
},
"outputId": "241cbd08-910e-4ae5-f255-5038663cc0b3"
},
"source": [
"sortxg = X_test.sort_values(by = ['xG'],ascending=False)\n",
"sortxg"
],
"execution_count": 102,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>location</th>\n",
" <th>Distance</th>\n",
" <th>Angle</th>\n",
" <th>UnderPressure</th>\n",
" <th>ShotType</th>\n",
" <th>ShotBodyPart</th>\n",
" <th>ShotTechnique</th>\n",
" <th>ShotFirstTime</th>\n",
" <th>ShotOneonOne</th>\n",
" <th>xG</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4624</th>\n",
" <td>[119.3, 41.4]</td>\n",
" <td>4.068882</td>\n",
" <td>157.545469</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0.955584</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3818</th>\n",
" <td>[119.1, 42.6]</td>\n",
" <td>4.162706</td>\n",
" <td>139.499608</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0.927110</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6952</th>\n",
" <td>[118.4, 39.4]</td>\n",
" <td>4.313989</td>\n",
" <td>135.619868</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0.918449</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8311</th>\n",
" <td>[119.2, 37.0]</td>\n",
" <td>4.163095</td>\n",
" <td>134.820390</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0.902713</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12822</th>\n",
" <td>[119.0, 43.0]</td>\n",
" <td>4.242641</td>\n",
" <td>126.869898</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0.897920</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3937</th>\n",
" <td>[69.2, 77.6]</td>\n",
" <td>63.283107</td>\n",
" <td>5.832625</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.004453</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2834</th>\n",
" <td>[81.1, 5.9]</td>\n",
" <td>51.817864</td>\n",
" <td>6.672792</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.003497</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6385</th>\n",
" <td>[57.2, 34.0]</td>\n",
" <td>63.211517</td>\n",
" <td>7.223482</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.003241</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11776</th>\n",
" <td>[62.0, 36.0]</td>\n",
" <td>58.274562</td>\n",
" <td>7.853313</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.002498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6659</th>\n",
" <td>[51.9, 43.4]</td>\n",
" <td>68.301760</td>\n",
" <td>6.706436</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.002257</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>2592 rows × 10 columns</p>\n",
"</div>"
],
"text/plain": [
" location Distance ... ShotOneonOne xG\n",
"4624 [119.3, 41.4] 4.068882 ... 0 0.955584\n",
"3818 [119.1, 42.6] 4.162706 ... 0 0.927110\n",
"6952 [118.4, 39.4] 4.313989 ... 0 0.918449\n",
"8311 [119.2, 37.0] 4.163095 ... 1 0.902713\n",
"12822 [119.0, 43.0] 4.242641 ... 0 0.897920\n",
"... ... ... ... ... ...\n",
"3937 [69.2, 77.6] 63.283107 ... 0 0.004453\n",
"2834 [81.1, 5.9] 51.817864 ... 0 0.003497\n",
"6385 [57.2, 34.0] 63.211517 ... 0 0.003241\n",
"11776 [62.0, 36.0] 58.274562 ... 0 0.002498\n",
"6659 [51.9, 43.4] 68.301760 ... 0 0.002257\n",
"\n",
"[2592 rows x 10 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 102
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "lrUnxsmxpvPM",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 418
},
"outputId": "45ab7647-b57e-4eab-fa14-1cf8120e5851"
},
"source": [
"import StatsbombPitch as sb\n",
"sb.sb_pitch(\"#195905\",\"#faf0e6\",\"horizontal\",\"full\")\n",
"plt.gca().invert_yaxis()\n",
"for i in range(len(sortxg)):\n",
" xe = sortxg.iloc[i]['location'][0]\n",
" ye = sortxg.iloc[i]['location'][1]\n",
" \n",
" if sortxg.iloc[i]['xG'] >= 0.75:\n",
" g = plt.scatter(xe,ye,color=\"#ee3e32\",edgecolors=\"none\",zorder=10,alpha=1,s = 40 )\n",
" elif sortxg.iloc[i]['xG'] < 0.75 and sortxg.iloc[i]['xG'] >=0.5:\n",
" o = plt.scatter(xe,ye,color=\"#f68838\",edgecolors=\"none\",zorder=8,alpha=0.75,s = 30 )\n",
" elif sortxg.iloc[i]['xG'] < 0.5 and sortxg.iloc[i]['xG'] >=0.25:\n",
" 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",
2020-04-25 17:11:18 +02:00
"plt.axis('off')\n",
2020-04-25 16:52:24 +02:00
"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",
"plt.show()"
],
"execution_count": 92,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmsAAAGRCAYAAAA6rfQGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nOy9d5xlVZX2/+wTb6rUgaYbEEyIjREjjhFQQAYYM5gVRH1HfyOOYxpHdAwDI4OorwllFAO0iCgmZARBR2ZUUJGXoKAINE1Dd1e+6cT9+2Otffe5FbpyV3XX+n4+TVXde+4++5xbzX16hWcprTUEQRAEQRCElYmz3BsQBEEQBEEQpkfEmiAIgiAIwgpGxJogCIIgCMIKRsSaIAiCIAjCCkbEmiAIgiAIwgpGxJogCIIgCMIKxtujJys72qnsyTMKgiAIgiCsLJIhvUtrvX62xy9IrCmljgPwKQAugC9rrc/e3fFOBVh37B7Vh4IgCIIgCCuK7Zck98zl+HmnQZVSLoDPAjgewGYApyqlNs93PUEQBEEQBGEyC6lZeyqAP2ut79JaxwC2ADh5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6y7mIPdKtdL5/tlHPwt3/PEOEWuCIAjC6kKE2pKyosWadlzkXgAnjbsez4LKNK/YPUsxyL0+XketpwYA+P2NN+Flr3zJvPYmCIIgCIIwFStarMFxMXbw09D/l//uPBT1H4io/6B5LbcUg9z/68dX4ztbLofrenjCkx6PJz31iHntTRAEQRAAAF5IacWkB
"text/plain": [
"<Figure size 748.8x489.6 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "DzQLtbmByqBa",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 418
},
"outputId": "85b007f9-71ec-402d-88ae-543690ab4585"
},
"source": [
"import StatsbombPitch as sb\n",
"sb.sb_pitch(\"#195905\",\"#faf0e6\",\"vertical\",\"half\")\n",
"#plt.gca().invert_xaxis()\n",
"for i in range(len(sortxg)):\n",
" xe = sortxg.iloc[i]['location'][0]\n",
" ye = sortxg.iloc[i]['location'][1]\n",
" \n",
" if sortxg.iloc[i]['xG'] >= 0.75:\n",
" g = plt.scatter(ye,xe,color=\"#ee3e32\",edgecolors=\"none\",zorder=10,alpha=1,s = 40 )\n",
" elif sortxg.iloc[i]['xG'] < 0.75 and sortxg.iloc[i]['xG'] >=0.5:\n",
" o = plt.scatter(ye,xe,color=\"#f68838\",edgecolors=\"none\",zorder=8,alpha=0.75,s = 30 )\n",
" elif sortxg.iloc[i]['xG'] < 0.5 and sortxg.iloc[i]['xG'] >=0.25:\n",
" 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",
2020-04-25 17:11:18 +02:00
"plt.axis('off')\n",
2020-04-25 16:52:24 +02:00
"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",
"\n",
"#ax = plt.subplot()\n",
"\n",
"#plt.savefig('MessiValverdeEraScatter.png')\n",
"plt.show()"
],
"execution_count": 103,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAGRCAYAAADYce9/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nOy9ebRkV33f+9n7jDXeumPfnifNAyBAiBnEIDAGgzEGHCckfrGzEtuJn2OveDnxi18G2yuPF4/kZYX1TGw/QBgcbMA2BknIAgGSkBCSGkktdUutnm7f+dat6Yx7vz/2qeFO3bdbLfWg81mrV99bt+rUqVOnan/Pb/j+hNaanJycnJycnJycixd5oXcgJycnJycnJyfn9OSCLScnJycnJyfnIicXbDk5OTk5OTk5Fzm5YMvJycnJycnJucjJBVtOTk5OTk5OzkVOLthycnJycnJyci5y7Au9AwB2QWpZvNB7kZOTk5OTk5NzYYkX9JzWenz17ReFYJNFGHvXRbErOTk5OTk5OTkXjKnb4+fWu/2MKVEhxKeEEDNCiAMDt31cCPGkEOJRIcRfCiFqA3/7dSHEISHEQSHEu87P7ufk5OTk5OTkvHTZTFjrT4BPAH82cNsdwK9rrRMhxH8Bfh34NSHEdcBHgeuBbcCdQoirtNbp+d3tnJycy5mfeuNP8f6b33+hd+MF50vf+xK333v7hd6NnJycS4AzRti01t8EFlbd9nWtdZL9eh+wI/v5/cDntNah1vpZ4BDwmvO4vzk5OS8B3n/z+7lux3UXejdeUK7bcd1LQpTm5OScH85H4dj/Bvx59vN2jIDrcjy77Zz4zC99hht33fg8di3nUsZ3fACCOLjAe3L5cKkc05JXArisRVvJK3Hz/pt59L8+eqF35bRcKufMpUR+TF/aPHb0MX76D376rB/3vAS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Y5df2zqFaT6wB+FLy4yOj/N6pM0cMXzCKw337j24K1fb6aVS32L9NK5Pi3kRdInDG6GpOTs6ZyQVbTk7OuWP7RqxJK0uhglApN430v1pqrmR/xeHxpXWaG1bxSLtNsXyK11Y98ODwYsTDp1pcWyhyPAr5ZmOZu5ev6Ym1LiPK5sPNET6/jnXGgpXyExNP86agwu8s7qSqV7rMKzQnrLUWGtdFPreEZf55Y4Jy9phfbGzh/6pO8aeVuTO+lrZUPLpBfd2Ivfard8S6kF/H2XsI5v0Mlk20LYkwFXbCGO86mWgT0jT26E0Y/BZqZltxYFKzm94lCxzP7IM6j0bCOTmXKHkFak7OhcZyX9hicMs1i9/5xvbAr5jORatfjK+1YnWWNEw3F4kp24LXjve3dcOwyxHV5k/mZrhzuU6kNRW9/mu5Kdpgxh2QCvj7QoM/qk6v+dtXC3WO230xWVCCT87t4QuzV/Kry1t7Yq3LLy1vYTjd/PH0heDlxSLbHbd324Ot5pr7fW+d2148TGSUNIagmdXJNY1ISxNzexz07xO1NyeihDRiDcz5cjYUhoyNSaEG5E1EOTl5hC0np0vX5yqNIX6RauH8apZi0lmK6TynjbwyOAWz/bBlXuPzfQ63aArSBxfsNIQoMsGYNOLvjqe8Z2cBVwoOLEYcbvTvO+JJYqVpxGtF3HrNj3LVYj0vEybUWl+0e/wz21V8tjzPnBXzk60RClpyp7/Mp8sro2U/15zgDWFlw214SG6Ii3zLOnO06Bq/wK9s3UYxi17ds1znk7PTPNRq8em5GX60NoIrBPc0lvnrpdM3PjwfiragaAkWIoXaSDvHnRXdwD2kBIQRX2kEnbMw9NXKiD/bPfvPVN7pnZOzglyw5eR08StG0NhuNnfxRUjDDKahXog6H7eUpbZCKFSzVJY89+fqilowYauwabYVt
"text/plain": [
"<Figure size 748.8x489.6 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "EHBsENu7wRim",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "c0f194be-e285-4381-9485-cd5a7f2e7a7c"
},
"source": [
"#[['Distance','Angle','UnderPressure','ShotType','ShotBodyPart','ShotTechnique','ShotFirstTime','ShotOneonOne']]\n",
"clf.predict_proba(np.array([12.55,37.156,0,4,2,5,0,0]).reshape(1, -1))[:,1]"
],
"execution_count": 104,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([0.38105829])"
]
},
"metadata": {
"tags": []
},
"execution_count": 104
}
]
}
]
2020-04-25 17:13:12 +02:00
}