Merge branch 'modServera' of https://git.wmi.amu.edu.pl/s478993/fantastyczne_gole into modServera

This commit is contained in:
Maciej Chmielarz 2024-01-09 00:40:06 +01:00
commit fc85d2f8f6
6 changed files with 40 additions and 38 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -342,10 +342,10 @@ const Hero = () => {
<select className="dropbtn"
onChange={event => setBodyPart(event.target.value)}
defaultValue={bodyPart}>
<option value = "prawa">Noga Prawa</option>
<option value = "lewa">Noga Lewa</option>
<option value = "glowa">Głowa</option>
<option value = "inna" >Inna</option>
<option value = "Right Foot">Noga Prawa</option>
<option value = "Left Foot">Noga Lewa</option>
<option value = "Head">Głowa</option>
<option value = "Other" >Inna</option>
</select>
</form>
@ -355,23 +355,23 @@ const Hero = () => {
<form className="dropdown" id = "shootTypeList">
<select className="dropbtn" onChange={event => setTechnique(event.target.value)}
defaultValue = {technique}>
<option value="zwykly"> Zwykły </option>
<option value = "voley"> Wolej </option>
<option value = "pol-voley"> Półwolej </option>
<option value = "lob"> Lob </option>
<option value = "szczupak"> Szczupak </option>
<option value = "z_gory"> Kopnięcie z góry </option>
<option value = "pietka"> Piętka </option>
<option value="Normal"> Zwykły </option>
<option value = "Volley"> Wolej </option>
<option value = "Half Volley"> Półwolej </option>
<option value = "Lob"> Lob </option>
<option value = "Diving Head"> Szczupak </option>
<option value = "Overhead Kick"> Kopnięcie z góry </option>
<option value = "Backheel"> Piętka </option>
</select>
</form>
<form className="dropdown" id = "actionTypeList" onChange={event => setActionType(event.target.value)}
defaultValue={technique}>
<select className="dropbtn">
<option value = "pozycyjny"> Atak Pozycyjny </option>
<option value = "wolny"> Rzut Wolny </option>
<option value = "karny"> Rzut Karny </option>
<option value= "rozny"> Rzut Rozny </option>
<option value = "Open Play"> Atak Pozycyjny </option>
<option value = "Free Kick"> Rzut Wolny </option>
<option value = "Penalty"> Rzut Karny </option>
<option value= "Corner"> Rzut Rozny </option>
<option value="rozpoczecie"> Rozpoczęcie </option>
</select>
</form>
@ -379,10 +379,10 @@ const Hero = () => {
onChange={event => setPossition(event.target.value)}
defaultValue={shooterPossition}>
<select className="dropbtn">
<option value= "napastnik" > Napastnik </option>
<option value = "bramkarz"> Bramkarz </option>
<option value = "obronca"> Obrońca </option>
<option value = "pomocnik"> Pomocnik </option>
<option value= "Center Forward" > Napastnik </option>
<option value = "Goalkeeper"> Bramkarz </option>
<option value = "Left Center Back"> Obrońca </option>
<option value = "Right Wing"> Pomocnik </option>
</select>
</form>

View File

@ -5,10 +5,8 @@ import math
import numpy as np
# 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):
# distance_to_goalM = sqrt(( (position_x**2) + (position_y**2)))
def LogisticRegression_predict_proba(position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead):
# distance_to_goalM = sqrt(( (position_x**2) + (position_y**2)))
model = load('regresja_logistyczna.joblib')
X_new = pd.DataFrame(columns=['position_x', 'position_y', 'distance_to_goalM', 'angle','match_minute', 'Number_Intervening_Opponents','Number_Intervening_Teammates', 'isFoot', 'isHead'])
X_new.loc[len(X_new.index)] = [position_x, position_y, distance_to_goalM, angle, match_minute, Number_Intervening_Opponents, Number_Intervening_Teammates, isFoot, isHead]
@ -132,7 +130,7 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
'shot_open_goal','shot_follows_dribble', 'shot_redirect',
'x1', 'y1','number_of_players_opponents',
'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_4','x_player_opponent_5', 'x_player_opponent_6',
'x_player_teammate_2','x_player_opponent_9', 'x_player_opponent_10',
@ -169,8 +167,10 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
teamMatesList = zmienWMaciez(teamMatesList)
opponentsList = zmienWMaciez(opponentsList)
number_of_players_opponents = len(teamMatesList)
number_of_players_teammates = len(opponentsList)
# DO ROZBUDOWY
number_of_players_opponents = 3
number_of_players_teammates = 3
# Bramkarz
x_player_opponent_Goalkeeper = goalkeeper[0]
y_player_opponent_Goalkeeper = goalkeeper[1]
@ -178,19 +178,16 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
shot_one_on_one = True if number_of_players_opponents == 1 else False
# TeamMate goalkeppe
x_player_teammate_Goalkeeper = None
y_player_teammate_Goalkeeper = None
x_player_teammate_Goalkeeper = np.nan
y_player_teammate_Goalkeeper = np.nan
#Reszta Zawodnikow
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
print(X_new.head)
X_new.loc[len(X_new.index)] = [minute, position_name, shot_body_part_name,
shot_technique_name,shot_type_name, shot_first_time,
shot_one_on_one,shot_aerial_won, shot_deflected,
shot_open_goal,shot_follows_dribble, shot_redirect,
shooter[0], shooter[1],number_of_players_opponents,
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[3][0], opponentsList[4][0], opponentsList[5][0],
opponentsList[6][0], opponentsList[7][0], teamMatesList[8][0],
@ -209,11 +206,16 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
teamMatesList[8][1], teamMatesList[9][1],
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
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)
# Pomocnicze Funkcje
# trzeba uzupelnic
def sortNearestToShooter(playerList, shooter):
return playerList
@ -230,14 +232,14 @@ def loc2angle(x, y):
rads = math.pi + rads if rads < 0 else rads
deg = math.degrees(rads)
return deg
# zamiana stringa odzielonego ',' na liste
def konwertujDoListy(listaString):
listaString = listaString.split(",")
listaFloat = []
for elem in listaString:
listaFloat.append(float(elem))
return listaFloat
#Zamiana listy w formie [1x,1y,2x,2y,3x,3y...] do postaci maciezy [xi, yi]
def zmienWMaciez(lista):
maciez = []
for i in range(0,len(lista),2):
@ -245,5 +247,5 @@ def zmienWMaciez(lista):
maciez.append(player)
if(len(maciez) < 10):
for i in range(len(maciez),11,1):
maciez.append([None,None])
return maciez
maciez.append([np.nan,np.nan])
return maciez

View File

@ -50,7 +50,7 @@ def get_model():
print("bramkarz: " + str(goalkepper) )
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_aerial_won = False, shot_deflected = False, shot_open_goal = False,
shot_follows_dribble = False, shot_redirect = False, shot_kick_off = False, goalkeeper= goalkepper