some work
This commit is contained in:
parent
4cbed48308
commit
0b3e58f05e
Binary file not shown.
@ -1,7 +1,9 @@
|
|||||||
from joblib import load
|
from joblib import load
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
|
import numpy as np
|
||||||
import math
|
import math
|
||||||
|
from sklearn.preprocessing import LabelEncoder
|
||||||
|
|
||||||
# Funkcja zwraca prawdopodobieństwo zdobycia gola
|
# Funkcja zwraca prawdopodobieństwo zdobycia gola
|
||||||
def LogisticRegression_predict_proba(position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead):
|
def LogisticRegression_predict_proba(position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead):
|
||||||
@ -100,7 +102,7 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
'shot_open_goal','shot_follows_dribble', 'shot_redirect',
|
'shot_open_goal','shot_follows_dribble', 'shot_redirect',
|
||||||
'x1', 'y1','number_of_players_opponents',
|
'x1', 'y1','number_of_players_opponents',
|
||||||
'number_of_players_teammates','angle', 'distance',
|
'number_of_players_teammates','angle', 'distance',
|
||||||
'x_player_opponent_Goalkeeper',
|
'x_player_opponent_Goalkeeper', 'x_player_opponent_8',
|
||||||
'x_player_opponent_1', 'x_player_opponent_2','x_player_opponent_3',
|
'x_player_opponent_1', 'x_player_opponent_2','x_player_opponent_3',
|
||||||
'x_player_opponent_4','x_player_opponent_5', 'x_player_opponent_6',
|
'x_player_opponent_4','x_player_opponent_5', 'x_player_opponent_6',
|
||||||
'x_player_teammate_2','x_player_opponent_9', 'x_player_opponent_10',
|
'x_player_teammate_2','x_player_opponent_9', 'x_player_opponent_10',
|
||||||
@ -146,8 +148,8 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
shot_one_on_one = True if number_of_players_opponents == 1 else False
|
shot_one_on_one = True if number_of_players_opponents == 1 else False
|
||||||
# TeamMate goalkeppe
|
# TeamMate goalkeppe
|
||||||
|
|
||||||
x_player_teammate_Goalkeeper = None
|
x_player_teammate_Goalkeeper = np.nan
|
||||||
y_player_teammate_Goalkeeper = None
|
y_player_teammate_Goalkeeper = np.nan
|
||||||
#Reszta Zawodnikow
|
#Reszta Zawodnikow
|
||||||
|
|
||||||
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
||||||
@ -158,7 +160,7 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
shot_open_goal,shot_follows_dribble, shot_redirect,
|
shot_open_goal,shot_follows_dribble, shot_redirect,
|
||||||
shooter[0], shooter[1],number_of_players_opponents,
|
shooter[0], shooter[1],number_of_players_opponents,
|
||||||
number_of_players_teammates,angle, distance,
|
number_of_players_teammates,angle, distance,
|
||||||
x_player_opponent_Goalkeeper,
|
x_player_opponent_Goalkeeper, opponentsList[8][0],
|
||||||
opponentsList[0][0], opponentsList[1][0], opponentsList[2][0],
|
opponentsList[0][0], opponentsList[1][0], opponentsList[2][0],
|
||||||
opponentsList[3][0], opponentsList[4][0], opponentsList[5][0],
|
opponentsList[3][0], opponentsList[4][0], opponentsList[5][0],
|
||||||
opponentsList[6][0], opponentsList[7][0], teamMatesList[8][0],
|
opponentsList[6][0], opponentsList[7][0], teamMatesList[8][0],
|
||||||
@ -178,6 +180,10 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
|
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
|
||||||
shot_kick_off]
|
shot_kick_off]
|
||||||
|
|
||||||
|
categorical_columns = ['position_name', 'shot_technique_name', 'shot_type_name', 'number_of_players_opponents', 'number_of_players_teammates', 'shot_body_part_name'] # list all your object columns here
|
||||||
|
# X_new = pd.get_dummies(X_new, columns=categorical_columns)
|
||||||
|
X_new[categorical_columns] = X_new[categorical_columns].astype('category')
|
||||||
|
|
||||||
return model.predict_proba(X_new)[0][1].round(2)
|
return model.predict_proba(X_new)[0][1].round(2)
|
||||||
|
|
||||||
|
|
||||||
@ -213,5 +219,5 @@ def zmienWMaciez(lista):
|
|||||||
maciez.append(player)
|
maciez.append(player)
|
||||||
if(len(maciez) < 10):
|
if(len(maciez) < 10):
|
||||||
for i in range(len(maciez),11,1):
|
for i in range(len(maciez),11,1):
|
||||||
maciez.append([None,None])
|
maciez.append([np.nan,np.nan])
|
||||||
return maciez
|
return maciez
|
@ -50,7 +50,7 @@ def get_model():
|
|||||||
print("bramkarz: " + str(goalkepper) )
|
print("bramkarz: " + str(goalkepper) )
|
||||||
|
|
||||||
response = xgboost_predict_proba_v2(shooter = shooter,
|
response = xgboost_predict_proba_v2(shooter = shooter,
|
||||||
opponentsList = opponentsList, teamMatesList = teamMatesList ,minute = 20, position_name = position_name, shot_body_part_name = body_part, shot_technique_name = technique,
|
opponentsList = opponentsList, teamMatesList = teamMatesList, minute = 20, position_name = position_name, shot_body_part_name = body_part, shot_technique_name = technique,
|
||||||
shot_type_name = acionType, shot_first_time = False,
|
shot_type_name = acionType, shot_first_time = False,
|
||||||
shot_aerial_won = False, shot_deflected = False, shot_open_goal = False,
|
shot_aerial_won = False, shot_deflected = False, shot_open_goal = False,
|
||||||
shot_follows_dribble = False, shot_redirect = False, shot_kick_off = False, goalkeeper= goalkepper
|
shot_follows_dribble = False, shot_redirect = False, shot_kick_off = False, goalkeeper= goalkepper
|
||||||
|
Loading…
Reference in New Issue
Block a user