commit
91aabc249e
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.tree import DecisionTreeClassifier
|
||||
from sklearn.metrics import accuracy_score
|
||||
from sklearn import metrics
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
|
||||
dataframe = pd.read_csv("archive/data.csv")
|
||||
|
||||
# Change bool values to int (0/1)
|
||||
dataframe = dataframe.rename(columns={'Winner': 'Blue_Corner_Win'})
|
||||
dataframe['Blue_Corner_Win'] = (dataframe['Blue_Corner_Win'] == 'Blue').astype(int)
|
||||
dataframe['title_bout'] = dataframe['title_bout'].astype(int)
|
||||
|
||||
# Select datas for Yi (blue corner win ?) and columns for stat
|
||||
Yi = dataframe[["Blue_Corner_Win"]]
|
||||
colonnes = ['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']
|
||||
|
||||
Xi = dataframe[colonnes]
|
||||
|
||||
Xtrain, Xtest, ytrain, ytest = train_test_split(Xi, Yi,test_size=0.20, random_state=42)
|
||||
print(Xtrain.shape)
|
||||
print(Xtest.shape)
|
||||
|
||||
Arbre_decision = DecisionTreeClassifier(random_state=0, max_depth=20)
|
||||
clf = Arbre_decision.fit(Xi, Yi)
|
||||
|
||||
ypredit = clf.predict(Xtest)
|
||||
accuracy_score(ytest, ypredit)
|
||||
matriceConfusion=metrics.confusion_matrix(ytest, ypredit)
|
||||
|
||||
incorrect=matriceConfusion[0][1] + matriceConfusion[1][0]
|
||||
total = matriceConfusion.sum()
|
||||
|
||||
print("\nNumber of incorrect classifications: " + str(incorrect))
|
||||
print("Number of classifications total: " + str(total))
|
||||
|
||||
print("Percent: "+ str((total-incorrect)/total*100))
|
Loading…
Reference in new issue