-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDT_classifier.py
executable file
·39 lines (34 loc) · 1.27 KB
/
DT_classifier.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sqlite3
import pandas as pd
import sys
database = './data/database.sqlite'
conn = sqlite3.connect(database)
cur = conn.cursor()
player_field_pos = {}
result = cur.execute("SELECT DISTINCT P.player_api_id, pxy.x, pxy.y from Player_xy pxy, Player P, Player_Attributes pa WHERE P.player_api_id = pxy.id and pa.player_api_id = P.player_api_id and P.birthday < \'1995-01-01 00:00:00\' and pa.date > \'2013-06-30\';")
for player in result:
x = player[1]
y = player[2]
if y == 1: # Goal Keeper
player_class = 1
elif y > 1 and y < 5: # Defense
player_class = 3
elif y >= 5 and y <= 6: # Defensive-mid
player_class = 3
elif y == 7:
if x >= 4 and x <= 6: # Defensive-mid
player_class = 3
elif x == 7: # Midfielder
player_class = 2
else: # Attacking-mid
player_class = 2
elif y >= 8 and y <= 9: # Attacking-mid
player_class = 2
elif y >= 10:
if x < 4 or x >= 7: # Attacking-mid
player_class = 2
else: # Attack
player_class = 0
player_field_pos[player[0]] = player_class
def get_field_position(player_id):
return player_field_pos[player_id]