Add bugs lol xd ptdr ratio axel

master
luevard 1 year ago
parent 006770bf43
commit fdfe3df4fc

@ -36,9 +36,45 @@ Actuellement à l'UFC, nous possédons 4 dans le top 15 mondial de l'UFC.
[Benoit Saint Denis](https://www.ufc.com/athlete/mariya-agapova-0) - Top 12 dans la catégorie Poids Léger Homme, il est en série de 3 victoires très impréssionantes et va combattre début avril contre le Top 3 [Dustin Poirier](https://www.ufc.com/athlete/dustin-poirier) qui est une légende du MMA [Benoit Saint Denis](https://www.ufc.com/athlete/mariya-agapova-0) - Top 12 dans la catégorie Poids Léger Homme, il est en série de 3 victoires très impréssionantes et va combattre début avril contre le Top 3 [Dustin Poirier](https://www.ufc.com/athlete/dustin-poirier) qui est une légende du MMA
# Que retenir du dataset ? ## Que retenir du dataset ?
Le dataset contient 140 colonnes, il faut donc trier afin de récupérer seulement les informations importantes
**B_avg_BODY_landed** : Nombre moyen de coups au corps réussis par le combattant du coin bleu
**B_avg_HEAD_landed** : Nombre moyen de coups à la tête réussis par le combattant du coin bleu
**B_avg_TD_att** : Nombre moyen de tentatives de takedown par le combattant du coin bleu
**B_avg_TOTAL_STR_landed** : Nombre moyen total de coups réussis par le combattant du coin bleu
**B_avg_opp_BODY_att** : Nombre moyen de tentatives de coups au corps par les adversaires contre le combattant du coin bleu
**B_avg_opp_HEAD_landed** : Nombre moyen de coups à la tête réussis par les adversaires contre le combattant du coin bleu
**B_avg_opp_LEG_landed** : Nombre moyen de coups à la jambe réussis par les adversaires contre le combattant du coin bleu
**B_avg_opp_SIG_STR_att** : Nombre moyen de tentatives de coups significatifs par les adversaires contre le combattant du coin bleu
**B_avg_opp_TOTAL_STR_att** : Nombre moyen total de tentatives de coups par les adversaires contre le combattant du coin bleu
**R_avg_TD_att** : Nombre moyen de tentatives de takedown par le combattant du coin rouge
**R_avg_opp_GROUND_att** : Nombre moyen de tentatives de coups au sol par les adversaires contre le combattant du coin rouge
**R_avg_opp_SIG_STR_landed** : Nombre moyen de coups significatifs réussis par les adversaires contre le combattant du coin rouge
**B_age** : Âge du combattant du coin bleu
**R_age** : Âge du combattant du coin rouge
# Comment lancer le projet ?
Pour lancer le projet, il faut simple exécuter la commande : python3 server.py.
Par contre le model met un peu de temps à charger, 2 minutes environs.
Ensuite, une interface web est disponible à l'adresse http://127.0.0.1:5000/ .
# LISTE DES VISUALISATIONS A PREVOIR # LISTE DES VISUALISATIONS A PREVOIR
@ -54,6 +90,3 @@ Actuellement à l'UFC, nous possédons 4 dans le top 15 mondial de l'UFC.
**Variation des performances avec l'âge** : Vérifier s'il existe une corrélation entre l'âge des combattants et leur succès dans l'UFC **Variation des performances avec l'âge** : Vérifier s'il existe une corrélation entre l'âge des combattants et leur succès dans l'UFC
![LE DARON À ZAK](https://upload.wikimedia.org/wikipedia/commons/e/ec/Dana_White_-_London_2015_%28cropped%29.jpg)
# DANA CACA WHITE

@ -4,6 +4,11 @@ from test import * # Assurez-vous d'avoir un fichier predict.py avec votre fonc
app = Flask(__name__) app = Flask(__name__)
colonnes = ['B_fighter','R_fighter','title_bout','B_avg_BODY_landed', 'B_avg_HEAD_landed', 'B_avg_TD_att', 'B_avg_TOTAL_STR_landed',
'B_avg_opp_BODY_att', 'B_avg_opp_HEAD_landed', 'B_avg_opp_LEG_landed',
'B_avg_opp_SIG_STR_att', 'B_avg_opp_TOTAL_STR_att', 'R_avg_TD_att', 'R_avg_opp_GROUND_att',
'R_avg_opp_SIG_STR_landed', 'B_age', 'R_age','date','Winner','weight_class','B_Stance','R_Stance']
# Charger le DataFrame une seule fois pour économiser des ressources # Charger le DataFrame une seule fois pour économiser des ressources
df = pd.read_csv('archive/data.csv') # Assurez-vous de spécifier le bon chemin vers votre fichier de données df = pd.read_csv('archive/data.csv') # Assurez-vous de spécifier le bon chemin vers votre fichier de données
@ -65,6 +70,8 @@ sns.heatmap(corr_matrix, annot=True)
# Last year when data fight was not full and correct # Last year when data fight was not full and correct
fighters = list_fighters(df,'2015-01-01') fighters = list_fighters(df,'2015-01-01')
df = df[colonnes]
# Get all fight of every fighters # Get all fight of every fighters
df_train = build_df_all_but_last(df, fighters) df_train = build_df_all_but_last(df, fighters)
@ -141,7 +148,7 @@ def make_prediction():
result = "" result = ""
if prediction_proba is not None: if prediction_proba is not None:
result = f"The predicted probability of {blue_fighter} winning is {round(prediction_proba[0][0] * 100, 2)}% and the predicted probability of {red_fighter} winning is {round(prediction_proba[0][1] * 100, 2)}%" result = f"The predicted probability of {blue_fighter} winning is {round(prediction_proba[0][0] * 100, 2)}% and the predicted probability of {red_fighter} winning is {round(prediction_proba[0][1] * 100, 2)}%"
return render_template('result.html', result=result) return render_template('result.html', result=result)
if __name__ == '__main__': if __name__ == '__main__':

@ -74,6 +74,7 @@ def build_df(df, fighters, i):
def build_df_all_but_last(df, fighters): def build_df_all_but_last(df, fighters):
cols = [col for col in df] cols = [col for col in df]
print(len(cols))
df_fights=pd.DataFrame(columns=cols) df_fights=pd.DataFrame(columns=cols)
for f in range(len(fighters)): for f in range(len(fighters)):
i=0 i=0
@ -96,45 +97,50 @@ def build_df_all_but_last(df, fighters):
return df_fights return df_fights
def predict(df, pipeline, blue_fighter, red_fighter, weightclass, rounds, title_bout=False): def predict(df, pipeline, blue_fighter, red_fighter, weightclass, rounds, title_bout=False):
try: #We build two dataframes, one for each figther
#We build two dataframes, one for each figther f1 = df[(df['R_fighter'] == blue_fighter) | (df['B_fighter'] == blue_fighter)].copy()
f1 = df[(df['R_fighter'] == blue_fighter) | (df['B_fighter'] == blue_fighter)].copy() f1.reset_index(drop=True, inplace=True)
f1.reset_index(drop=True, inplace=True) f1 = f1[:1]
f1 = f1[:1] f2 = df[(df['R_fighter'] == red_fighter) | (df['B_fighter'] == red_fighter)].copy()
f2 = df[(df['R_fighter'] == red_fighter) | (df['B_fighter'] == red_fighter)].copy() f2.reset_index(drop=True, inplace=True)
f2.reset_index(drop=True, inplace=True) f2 = f2[:1]
f2 = f2[:1]
# if the fighter was red/blue corner on his last fight, we filter columns to only keep his statistics (and not the other fighter) print("OK 1")
# then we rename columns according to the color of the corner in the parameters using re.sub()
if (f1.loc[0, ['R_fighter']].values[0]) == blue_fighter: # if the fighter was red/blue corner on his last fight, we filter columns to only keep his statistics (and not the other fighter)
result1 = f1.filter(regex='^R', axis=1).copy() #here we keep the red corner stats # then we rename columns according to the color of the corner in the parameters using re.sub()
result1.rename(columns = lambda x: re.sub('^R','B', x), inplace=True) #we rename it with "B_" prefix because he's in the blue_corner if (f1.loc[0, ['R_fighter']].values[0]) == blue_fighter:
else: result1 = f1.filter(regex='^R', axis=1).copy() #here we keep the red corner stats
result1 = f1.filter(regex='^B', axis=1).copy() result1.rename(columns = lambda x: re.sub('^R','B', x), inplace=True) #we rename it with "B_" prefix because he's in the blue_corner
if (f2.loc[0, ['R_fighter']].values[0]) == red_fighter: else:
result2 = f2.filter(regex='^R', axis=1).copy() result1 = f1.filter(regex='^B', axis=1).copy()
else: if (f2.loc[0, ['R_fighter']].values[0]) == red_fighter:
result2 = f2.filter(regex='^B', axis=1).copy() result2 = f2.filter(regex='^R', axis=1).copy()
result2.rename(columns = lambda x: re.sub('^B','R', x), inplace=True) else:
result2 = f2.filter(regex='^B', axis=1).copy()
fight = pd.concat([result1, result2], axis = 1) # we concatenate the red and blue fighter dataframes (in columns) result2.rename(columns = lambda x: re.sub('^B','R', x), inplace=True)
fight.drop(['R_fighter','B_fighter'], axis = 1, inplace = True) # we remove fighter names
fight.insert(0, 'title_bout', title_bout) # we add tittle_bout, weight class and number of rounds data to the dataframe print("OK 2")
fight.insert(1, 'weight_class', weightclass)
fight.insert(2, 'no_of_rounds', rounds) fight = pd.concat([result1, result2], axis = 1) # we concatenate the red and blue fighter dataframes (in columns)
fight['title_bout'] = fight['title_bout'].map({True: 1, False: 0}) fight.drop(['R_fighter','B_fighter'], axis = 1, inplace = True) # we remove fighter names
fight.insert(0, 'title_bout', title_bout) # we add tittle_bout, weight class and number of rounds data to the dataframe
pred = pipeline.predict(fight) fight.insert(1, 'weight_class', weightclass)
proba = pipeline.predict_proba(fight) fight.insert(2, 'no_of_rounds', rounds)
if (pred == 1.0): fight['title_bout'] = fight['title_bout'].map({True: 1, False: 0})
print("The predicted winner is", red_fighter, 'with a probability of', round(proba[0][1] * 100, 2), "%")
else: print("OK 3")
print("The predicted winner is", blue_fighter, 'with a probability of ', round(proba[0][0] * 100, 2), "%")
return proba pred = pipeline.predict(fight)
except: proba = pipeline.predict_proba(fight)
print("One of fighter doesn't exist in the dataframe")
return print("OK 4")
if (pred == 1.0):
print("The predicted winner is", red_fighter, 'with a probability of', round(proba[0][1] * 100, 2), "%")
else:
print("The predicted winner is", blue_fighter, 'with a probability of ', round(proba[0][0] * 100, 2), "%")
return proba
#predict(df, model, 'Kamaru Usman', 'Colby Covington', 'Welterweight', 3, True) #predict(df, model, 'Kamaru Usman', 'Colby Covington', 'Welterweight', 3, True)

Loading…
Cancel
Save