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
# 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
@ -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
![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__)
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
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
fighters = list_fighters(df,'2015-01-01')
df = df[colonnes]
# Get all fight of every fighters
df_train = build_df_all_but_last(df, fighters)

@ -74,6 +74,7 @@ def build_df(df, fighters, i):
def build_df_all_but_last(df, fighters):
cols = [col for col in df]
print(len(cols))
df_fights=pd.DataFrame(columns=cols)
for f in range(len(fighters)):
i=0
@ -96,45 +97,50 @@ def build_df_all_but_last(df, fighters):
return df_fights
def predict(df, pipeline, blue_fighter, red_fighter, weightclass, rounds, title_bout=False):
try:
#We build two dataframes, one for each figther
f1 = df[(df['R_fighter'] == blue_fighter) | (df['B_fighter'] == blue_fighter)].copy()
f1.reset_index(drop=True, inplace=True)
f1 = f1[:1]
f2 = df[(df['R_fighter'] == red_fighter) | (df['B_fighter'] == red_fighter)].copy()
f2.reset_index(drop=True, inplace=True)
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)
# 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:
result1 = f1.filter(regex='^R', axis=1).copy() #here we keep the red corner stats
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
else:
result1 = f1.filter(regex='^B', axis=1).copy()
if (f2.loc[0, ['R_fighter']].values[0]) == red_fighter:
result2 = f2.filter(regex='^R', axis=1).copy()
else:
result2 = f2.filter(regex='^B', axis=1).copy()
result2.rename(columns = lambda x: re.sub('^B','R', x), inplace=True)
fight = pd.concat([result1, result2], axis = 1) # we concatenate the red and blue fighter dataframes (in columns)
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
fight.insert(1, 'weight_class', weightclass)
fight.insert(2, 'no_of_rounds', rounds)
fight['title_bout'] = fight['title_bout'].map({True: 1, False: 0})
pred = pipeline.predict(fight)
proba = pipeline.predict_proba(fight)
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
except:
print("One of fighter doesn't exist in the dataframe")
return
#We build two dataframes, one for each figther
f1 = df[(df['R_fighter'] == blue_fighter) | (df['B_fighter'] == blue_fighter)].copy()
f1.reset_index(drop=True, inplace=True)
f1 = f1[:1]
f2 = df[(df['R_fighter'] == red_fighter) | (df['B_fighter'] == red_fighter)].copy()
f2.reset_index(drop=True, inplace=True)
f2 = f2[:1]
print("OK 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)
# 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:
result1 = f1.filter(regex='^R', axis=1).copy() #here we keep the red corner stats
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
else:
result1 = f1.filter(regex='^B', axis=1).copy()
if (f2.loc[0, ['R_fighter']].values[0]) == red_fighter:
result2 = f2.filter(regex='^R', axis=1).copy()
else:
result2 = f2.filter(regex='^B', axis=1).copy()
result2.rename(columns = lambda x: re.sub('^B','R', x), inplace=True)
print("OK 2")
fight = pd.concat([result1, result2], axis = 1) # we concatenate the red and blue fighter dataframes (in columns)
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
fight.insert(1, 'weight_class', weightclass)
fight.insert(2, 'no_of_rounds', rounds)
fight['title_bout'] = fight['title_bout'].map({True: 1, False: 0})
print("OK 3")
pred = pipeline.predict(fight)
proba = pipeline.predict_proba(fight)
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)

Loading…
Cancel
Save