Compare commits

...

2 Commits

View File

@ -13,31 +13,31 @@ def LogisticRegression_predict_proba(position_x, position_y, distance_to_goalM,
return model.predict_proba(X_new)[0][1].round(2)
#xgBoost
def xgboost_predict_proba(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, x1, y1,
number_of_players_opponents, number_of_players_teammates,
angle, distance, x_player_opponent_Goalkeeper,
x_player_opponent_8, x_player_opponent_1, x_player_opponent_2,
x_player_opponent_3, x_player_teammate_1, 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_opponent_11,
x_player_teammate_3, x_player_teammate_4, x_player_teammate_5,
x_player_teammate_6, x_player_teammate_7, x_player_teammate_8,
x_player_teammate_9, x_player_teammate_10,
y_player_opponent_Goalkeeper, y_player_opponent_8,
y_player_opponent_1, y_player_opponent_2, y_player_opponent_3,
y_player_teammate_1, y_player_opponent_4, y_player_opponent_5,
y_player_opponent_6, y_player_teammate_2, y_player_opponent_9,
y_player_opponent_10, y_player_opponent_11, y_player_teammate_3,
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_10, x_player_opponent_7, y_player_opponent_7,
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
shot_kick_off):
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_one_on_one=False, shot_aerial_won=False, shot_deflected=False,
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,
angle=0.0, distance=0.0, x_player_opponent_Goalkeeper=np.nan,
x_player_opponent_8=np.nan, x_player_opponent_1=np.nan, x_player_opponent_2=np.nan,
x_player_opponent_3=np.nan, x_player_teammate_1=np.nan, x_player_opponent_4=np.nan,
x_player_opponent_5=np.nan, x_player_opponent_6=np.nan, x_player_teammate_2=np.nan,
x_player_opponent_9=np.nan, x_player_opponent_10=np.nan, x_player_opponent_11=np.nan,
x_player_teammate_3=np.nan, x_player_teammate_4=np.nan, x_player_teammate_5=np.nan,
x_player_teammate_6=np.nan, x_player_teammate_7=np.nan, x_player_teammate_8=np.nan,
y_player_opponent_Goalkeeper=np.nan, y_player_opponent_8=np.nan,
x_player_teammate_9=np.nan, x_player_teammate_10=np.nan,
y_player_opponent_1=np.nan, y_player_opponent_2=np.nan, y_player_opponent_3=np.nan,
y_player_teammate_1=np.nan, y_player_opponent_4=np.nan, y_player_opponent_5=np.nan,
y_player_opponent_6=np.nan, y_player_teammate_2=np.nan, y_player_opponent_9=np.nan,
y_player_opponent_10=np.nan, y_player_opponent_11=np.nan, y_player_teammate_3=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_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):
model = load('xgboost.joblib')
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_aerial_won', 'shot_deflected', 'shot_open_goal',
@ -85,7 +85,38 @@ def xgboost_predict_proba(minute, position_name, shot_body_part_name, shot_techn
y_player_teammate_10, x_player_opponent_7, y_player_opponent_7,
x_player_teammate_Goalkeeper, y_player_teammate_Goalkeeper,
shot_kick_off]
return model.predict_proba(X_new)[0][1].round(2)
X_new[['position_name',
'shot_technique_name',
'shot_type_name',
'number_of_players_opponents',
'number_of_players_teammates',
'shot_body_part_name']] = X_new[['position_name',
'shot_technique_name',
'shot_type_name',
'number_of_players_opponents',
'number_of_players_teammates',
'shot_body_part_name']].astype('category')
X_new['minute'] = X_new['minute'].astype(int)
X_new[['shot_first_time',
'shot_one_on_one',
'shot_aerial_won',
'shot_deflected',
'shot_open_goal',
'shot_follows_dribble',
'shot_redirect',
'shot_kick_off']] = X_new[['shot_first_time',
'shot_one_on_one',
'shot_aerial_won',
'shot_deflected',
'shot_open_goal',
'shot_follows_dribble',
'shot_redirect',
'shot_kick_off']].astype(bool)
return model.predict_proba(X_new)[0][1].round(3)
#XgBoost_2