zmiana jezyka zmiennych kategorycznych
This commit is contained in:
parent
0b3e58f05e
commit
f96465ed56
@ -342,10 +342,10 @@ const Hero = () => {
|
|||||||
<select className="dropbtn"
|
<select className="dropbtn"
|
||||||
onChange={event => setBodyPart(event.target.value)}
|
onChange={event => setBodyPart(event.target.value)}
|
||||||
defaultValue={bodyPart}>
|
defaultValue={bodyPart}>
|
||||||
<option value = "prawa">Noga Prawa</option>
|
<option value = "Right Foot">Noga Prawa</option>
|
||||||
<option value = "lewa">Noga Lewa</option>
|
<option value = "Left Foot">Noga Lewa</option>
|
||||||
<option value = "glowa">Głowa</option>
|
<option value = "Head">Głowa</option>
|
||||||
<option value = "inna" >Inna</option>
|
<option value = "Other" >Inna</option>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -355,23 +355,23 @@ const Hero = () => {
|
|||||||
<form className="dropdown" id = "shootTypeList">
|
<form className="dropdown" id = "shootTypeList">
|
||||||
<select className="dropbtn" onChange={event => setTechnique(event.target.value)}
|
<select className="dropbtn" onChange={event => setTechnique(event.target.value)}
|
||||||
defaultValue = {technique}>
|
defaultValue = {technique}>
|
||||||
<option value="zwykly"> Zwykły </option>
|
<option value="Normal"> Zwykły </option>
|
||||||
<option value = "voley"> Wolej </option>
|
<option value = "Volley"> Wolej </option>
|
||||||
<option value = "pol-voley"> Półwolej </option>
|
<option value = "Half Volley"> Półwolej </option>
|
||||||
<option value = "lob"> Lob </option>
|
<option value = "Lob"> Lob </option>
|
||||||
<option value = "szczupak"> Szczupak </option>
|
<option value = "Diving Head"> Szczupak </option>
|
||||||
<option value = "z_gory"> Kopnięcie z góry </option>
|
<option value = "Overhead Kick"> Kopnięcie z góry </option>
|
||||||
<option value = "pietka"> Piętka </option>
|
<option value = "Backheel"> Piętka </option>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form className="dropdown" id = "actionTypeList" onChange={event => setActionType(event.target.value)}
|
<form className="dropdown" id = "actionTypeList" onChange={event => setActionType(event.target.value)}
|
||||||
defaultValue={technique}>
|
defaultValue={technique}>
|
||||||
<select className="dropbtn">
|
<select className="dropbtn">
|
||||||
<option value = "pozycyjny"> Atak Pozycyjny </option>
|
<option value = "Open Play"> Atak Pozycyjny </option>
|
||||||
<option value = "wolny"> Rzut Wolny </option>
|
<option value = "Free Kick"> Rzut Wolny </option>
|
||||||
<option value = "karny"> Rzut Karny </option>
|
<option value = "Penalty"> Rzut Karny </option>
|
||||||
<option value= "rozny"> Rzut Rozny </option>
|
<option value= "Corner"> Rzut Rozny </option>
|
||||||
<option value="rozpoczecie"> Rozpoczęcie </option>
|
<option value="rozpoczecie"> Rozpoczęcie </option>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
@ -379,10 +379,10 @@ const Hero = () => {
|
|||||||
onChange={event => setPossition(event.target.value)}
|
onChange={event => setPossition(event.target.value)}
|
||||||
defaultValue={shooterPossition}>
|
defaultValue={shooterPossition}>
|
||||||
<select className="dropbtn">
|
<select className="dropbtn">
|
||||||
<option value= "napastnik" > Napastnik </option>
|
<option value= "Center Forward" > Napastnik </option>
|
||||||
<option value = "bramkarz"> Bramkarz </option>
|
<option value = "Goalkeeper"> Bramkarz </option>
|
||||||
<option value = "obronca"> Obrońca </option>
|
<option value = "Left Center Back"> Obrońca </option>
|
||||||
<option value = "pomocnik"> Pomocnik </option>
|
<option value = "Right Wing"> Pomocnik </option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
|
Binary file not shown.
@ -1,15 +1,12 @@
|
|||||||
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
|
import numpy as np
|
||||||
|
|
||||||
# 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):
|
||||||
|
|
||||||
# distance_to_goalM = sqrt(( (position_x**2) + (position_y**2)))
|
# distance_to_goalM = sqrt(( (position_x**2) + (position_y**2)))
|
||||||
|
|
||||||
model = load('regresja_logistyczna.joblib')
|
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 = 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]
|
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]
|
||||||
@ -102,7 +99,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_8',
|
'x_player_opponent_Goalkeeper',
|
||||||
'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',
|
||||||
@ -139,8 +136,10 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
teamMatesList = zmienWMaciez(teamMatesList)
|
teamMatesList = zmienWMaciez(teamMatesList)
|
||||||
opponentsList = zmienWMaciez(opponentsList)
|
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
|
# Bramkarz
|
||||||
x_player_opponent_Goalkeeper = goalkeeper[0]
|
x_player_opponent_Goalkeeper = goalkeeper[0]
|
||||||
y_player_opponent_Goalkeeper = goalkeeper[1]
|
y_player_opponent_Goalkeeper = goalkeeper[1]
|
||||||
@ -151,16 +150,13 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
x_player_teammate_Goalkeeper = np.nan
|
x_player_teammate_Goalkeeper = np.nan
|
||||||
y_player_teammate_Goalkeeper = np.nan
|
y_player_teammate_Goalkeeper = np.nan
|
||||||
#Reszta Zawodnikow
|
#Reszta Zawodnikow
|
||||||
|
|
||||||
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
|
||||||
print(X_new.head)
|
|
||||||
X_new.loc[len(X_new.index)] = [minute, position_name, shot_body_part_name,
|
X_new.loc[len(X_new.index)] = [minute, position_name, shot_body_part_name,
|
||||||
shot_technique_name,shot_type_name, shot_first_time,
|
shot_technique_name,shot_type_name, shot_first_time,
|
||||||
shot_one_on_one,shot_aerial_won, shot_deflected,
|
shot_one_on_one,shot_aerial_won, shot_deflected,
|
||||||
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, opponentsList[8][0],
|
x_player_opponent_Goalkeeper,
|
||||||
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],
|
||||||
@ -180,14 +176,12 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
# Pomocnicze Funkcje
|
# Pomocnicze Funkcje
|
||||||
|
# trzeba uzupelnic
|
||||||
def sortNearestToShooter(playerList, shooter):
|
def sortNearestToShooter(playerList, shooter):
|
||||||
|
|
||||||
return playerList
|
return playerList
|
||||||
@ -204,14 +198,14 @@ def loc2angle(x, y):
|
|||||||
rads = math.pi + rads if rads < 0 else rads
|
rads = math.pi + rads if rads < 0 else rads
|
||||||
deg = math.degrees(rads)
|
deg = math.degrees(rads)
|
||||||
return deg
|
return deg
|
||||||
|
# zamiana stringa odzielonego ',' na liste
|
||||||
def konwertujDoListy(listaString):
|
def konwertujDoListy(listaString):
|
||||||
listaString = listaString.split(",")
|
listaString = listaString.split(",")
|
||||||
listaFloat = []
|
listaFloat = []
|
||||||
for elem in listaString:
|
for elem in listaString:
|
||||||
listaFloat.append(float(elem))
|
listaFloat.append(float(elem))
|
||||||
return listaFloat
|
return listaFloat
|
||||||
|
#Zamiana listy w formie [1x,1y,2x,2y,3x,3y...] do postaci maciezy [xi, yi]
|
||||||
def zmienWMaciez(lista):
|
def zmienWMaciez(lista):
|
||||||
maciez = []
|
maciez = []
|
||||||
for i in range(0,len(lista),2):
|
for i in range(0,len(lista),2):
|
||||||
|
Loading…
Reference in New Issue
Block a user