small data and model improvement
This commit is contained in:
parent
412dd57577
commit
1b42cd208b
Binary file not shown.
@ -15,7 +15,7 @@ def LogisticRegression_predict_proba(position_x, position_y, distance_to_goalM,
|
|||||||
#xgBoost
|
#xgBoost
|
||||||
def xgboost_predict_proba(minute=0, position_name='Center Forward', shot_body_part_name='Right Foot',
|
def xgboost_predict_proba(minute=0, position_name='Center Forward', shot_body_part_name='Right Foot',
|
||||||
shot_technique_name='Normal', shot_type_name='Open Play', shot_first_time=False,
|
shot_technique_name='Normal', shot_type_name='Open Play', shot_first_time=False,
|
||||||
shot_one_on_one=False, shot_aerial_won=False, shot_deflected=False,
|
shot_one_on_one=False, shot_aerial_won=False,
|
||||||
shot_open_goal=False, shot_follows_dribble=False, shot_redirect=False, x1=0.0, y1=0.0,
|
shot_open_goal=False, shot_follows_dribble=False, shot_redirect=False, x1=0.0, y1=0.0,
|
||||||
number_of_players_opponents=0, number_of_players_teammates=0,
|
number_of_players_opponents=0, number_of_players_teammates=0,
|
||||||
angle=0.0, distance=0.0, x_player_opponent_Goalkeeper=np.nan,
|
angle=0.0, distance=0.0, x_player_opponent_Goalkeeper=np.nan,
|
||||||
@ -34,13 +34,13 @@ def xgboost_predict_proba(minute=0, position_name='Center Forward', shot_body_pa
|
|||||||
y_player_teammate_4=np.nan, y_player_teammate_5=np.nan, y_player_teammate_6=np.nan,
|
y_player_teammate_4=np.nan, y_player_teammate_5=np.nan, y_player_teammate_6=np.nan,
|
||||||
y_player_teammate_7=np.nan, y_player_teammate_8=np.nan, y_player_teammate_9=np.nan,
|
y_player_teammate_7=np.nan, y_player_teammate_8=np.nan, y_player_teammate_9=np.nan,
|
||||||
y_player_teammate_10=np.nan, x_player_opponent_7=np.nan, y_player_opponent_7=np.nan,
|
y_player_teammate_10=np.nan, x_player_opponent_7=np.nan, y_player_opponent_7=np.nan,
|
||||||
x_player_teammate_Goalkeeper=np.nan, y_player_teammate_Goalkeeper=np.nan, shot_kick_off=False):
|
x_player_teammate_Goalkeeper=np.nan, y_player_teammate_Goalkeeper=np.nan):
|
||||||
|
|
||||||
model = load('xgboost.joblib')
|
model = load('xgboost.joblib')
|
||||||
|
|
||||||
X_new = pd.DataFrame(columns=['minute', 'position_name', 'shot_body_part_name', 'shot_technique_name',
|
X_new = pd.DataFrame(columns=['minute', 'position_name', 'shot_body_part_name', 'shot_technique_name',
|
||||||
'shot_type_name', 'shot_first_time', 'shot_one_on_one',
|
'shot_type_name', 'shot_first_time', 'shot_one_on_one',
|
||||||
'shot_aerial_won', 'shot_deflected', 'shot_open_goal',
|
'shot_aerial_won', 'shot_open_goal',
|
||||||
'shot_follows_dribble', 'shot_redirect', 'x1', 'y1',
|
'shot_follows_dribble', 'shot_redirect', 'x1', 'y1',
|
||||||
'number_of_players_opponents', 'number_of_players_teammates',
|
'number_of_players_opponents', 'number_of_players_teammates',
|
||||||
'angle', 'distance', 'x_player_opponent_Goalkeeper',
|
'angle', 'distance', 'x_player_opponent_Goalkeeper',
|
||||||
@ -59,12 +59,11 @@ def xgboost_predict_proba(minute=0, position_name='Center Forward', shot_body_pa
|
|||||||
'y_player_teammate_4', 'y_player_teammate_5', 'y_player_teammate_6',
|
'y_player_teammate_4', 'y_player_teammate_5', 'y_player_teammate_6',
|
||||||
'y_player_teammate_7', 'y_player_teammate_8', 'y_player_teammate_9',
|
'y_player_teammate_7', 'y_player_teammate_8', 'y_player_teammate_9',
|
||||||
'y_player_teammate_10', 'x_player_opponent_7', 'y_player_opponent_7',
|
'y_player_teammate_10', 'x_player_opponent_7', 'y_player_opponent_7',
|
||||||
'x_player_teammate_Goalkeeper', 'y_player_teammate_Goalkeeper',
|
'x_player_teammate_Goalkeeper', 'y_player_teammate_Goalkeeper'])
|
||||||
'shot_kick_off'])
|
|
||||||
|
|
||||||
X_new.loc[len(X_new.index)] = [minute, position_name, shot_body_part_name, shot_technique_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_one_on_one,
|
shot_type_name, shot_first_time, shot_one_on_one,
|
||||||
shot_aerial_won, shot_deflected, shot_open_goal,
|
shot_aerial_won, shot_open_goal,
|
||||||
shot_follows_dribble, shot_redirect, x1, y1,
|
shot_follows_dribble, shot_redirect, x1, y1,
|
||||||
number_of_players_opponents, number_of_players_teammates,
|
number_of_players_opponents, number_of_players_teammates,
|
||||||
angle, distance, x_player_opponent_Goalkeeper,
|
angle, distance, x_player_opponent_Goalkeeper,
|
||||||
@ -83,8 +82,7 @@ def xgboost_predict_proba(minute=0, position_name='Center Forward', shot_body_pa
|
|||||||
y_player_teammate_4, y_player_teammate_5, y_player_teammate_6,
|
y_player_teammate_4, y_player_teammate_5, y_player_teammate_6,
|
||||||
y_player_teammate_7, y_player_teammate_8, y_player_teammate_9,
|
y_player_teammate_7, y_player_teammate_8, y_player_teammate_9,
|
||||||
y_player_teammate_10, x_player_opponent_7, y_player_opponent_7,
|
y_player_teammate_10, x_player_opponent_7, y_player_opponent_7,
|
||||||
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
|
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper]
|
||||||
shot_kick_off]
|
|
||||||
|
|
||||||
X_new[['position_name',
|
X_new[['position_name',
|
||||||
'shot_technique_name',
|
'shot_technique_name',
|
||||||
@ -103,30 +101,26 @@ def xgboost_predict_proba(minute=0, position_name='Center Forward', shot_body_pa
|
|||||||
X_new[['shot_first_time',
|
X_new[['shot_first_time',
|
||||||
'shot_one_on_one',
|
'shot_one_on_one',
|
||||||
'shot_aerial_won',
|
'shot_aerial_won',
|
||||||
'shot_deflected',
|
|
||||||
'shot_open_goal',
|
'shot_open_goal',
|
||||||
'shot_follows_dribble',
|
'shot_follows_dribble',
|
||||||
'shot_redirect',
|
'shot_redirect']] = X_new[['shot_first_time',
|
||||||
'shot_kick_off']] = X_new[['shot_first_time',
|
|
||||||
'shot_one_on_one',
|
'shot_one_on_one',
|
||||||
'shot_aerial_won',
|
'shot_aerial_won',
|
||||||
'shot_deflected',
|
|
||||||
'shot_open_goal',
|
'shot_open_goal',
|
||||||
'shot_follows_dribble',
|
'shot_follows_dribble',
|
||||||
'shot_redirect',
|
'shot_redirect']].astype(bool)
|
||||||
'shot_kick_off']].astype(bool)
|
|
||||||
|
|
||||||
return model.predict_proba(X_new)[0][1].round(3)
|
return model.predict_proba(X_new)[0][1].round(3)
|
||||||
|
|
||||||
#XgBoost_2
|
#XgBoost_2
|
||||||
|
|
||||||
def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, minute,position_name,shot_body_part_name,
|
def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, minute,position_name,shot_body_part_name,
|
||||||
shot_technique_name,shot_type_name,shot_first_time,shot_aerial_won,shot_deflected,shot_open_goal,
|
shot_technique_name,shot_type_name,shot_first_time,shot_aerial_won,shot_open_goal,
|
||||||
shot_follows_dribble,shot_redirect, shot_kick_off):
|
shot_follows_dribble,shot_redirect):
|
||||||
model = load('xgboost.joblib')
|
model = load('xgboost.joblib')
|
||||||
X_new = pd.DataFrame(columns=['minute', 'position_name', 'shot_body_part_name',
|
X_new = pd.DataFrame(columns=['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_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',
|
||||||
@ -146,8 +140,7 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
'y_player_teammate_4', 'y_player_teammate_5', 'y_player_teammate_6',
|
'y_player_teammate_4', 'y_player_teammate_5', 'y_player_teammate_6',
|
||||||
'y_player_teammate_7', 'y_player_teammate_8', 'y_player_teammate_9',
|
'y_player_teammate_7', 'y_player_teammate_8', 'y_player_teammate_9',
|
||||||
'y_player_teammate_10', 'x_player_opponent_7', 'y_player_opponent_7',
|
'y_player_teammate_10', 'x_player_opponent_7', 'y_player_opponent_7',
|
||||||
'x_player_teammate_Goalkeeper', 'y_player_teammate_Goalkeeper',
|
'x_player_teammate_Goalkeeper', 'y_player_teammate_Goalkeeper'])
|
||||||
'shot_kick_off'])
|
|
||||||
|
|
||||||
|
|
||||||
shooter = konwertujDoListy(shooter)
|
shooter = konwertujDoListy(shooter)
|
||||||
@ -183,7 +176,7 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
#Reszta Zawodnikow
|
#Reszta Zawodnikow
|
||||||
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_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,
|
||||||
@ -204,8 +197,7 @@ def xgboost_predict_proba_v2(shooter,goalkeeper,teamMatesList,opponentsList, min
|
|||||||
teamMatesList[0][1],teamMatesList[1][1], teamMatesList[2][1],
|
teamMatesList[0][1],teamMatesList[1][1], teamMatesList[2][1],
|
||||||
teamMatesList[4][1],teamMatesList[5][1], teamMatesList[6][1], teamMatesList[7][1],
|
teamMatesList[4][1],teamMatesList[5][1], teamMatesList[6][1], teamMatesList[7][1],
|
||||||
teamMatesList[8][1], teamMatesList[9][1],
|
teamMatesList[8][1], teamMatesList[9][1],
|
||||||
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
|
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
|
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 = pd.get_dummies(X_new, columns=categorical_columns)
|
||||||
|
@ -164,11 +164,9 @@ def get_model():
|
|||||||
shot_first_time=shot_first_time,
|
shot_first_time=shot_first_time,
|
||||||
shot_one_on_one=shot_one_on_one,
|
shot_one_on_one=shot_one_on_one,
|
||||||
shot_aerial_won=shot_aerial_won,
|
shot_aerial_won=shot_aerial_won,
|
||||||
shot_deflected=False,
|
|
||||||
shot_open_goal=shot_open_goal,
|
shot_open_goal=shot_open_goal,
|
||||||
shot_follows_dribble=shot_follows_dribble,
|
shot_follows_dribble=shot_follows_dribble,
|
||||||
shot_redirect=shot_redirect,
|
shot_redirect=shot_redirect,
|
||||||
shot_kick_off=False,
|
|
||||||
x1=shooter_x, y1=shooter_y,
|
x1=shooter_x, y1=shooter_y,
|
||||||
number_of_players_opponents=number_of_players_opponents,
|
number_of_players_opponents=number_of_players_opponents,
|
||||||
number_of_players_teammates=number_of_players_teammates,
|
number_of_players_teammates=number_of_players_teammates,
|
||||||
|
Binary file not shown.
76686
data/final_data.csv
76686
data/final_data.csv
File diff suppressed because it is too large
Load Diff
38343
notebooks/final_data.csv
Normal file
38343
notebooks/final_data.csv
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user