October 2018
Intermediate to advanced
172 pages
4h 6m
English
In this plot, we compare the cross-validated accuracy scores of multiple models by making use of box plots. In order to do so, we use the following code:
from sklearn import model_selection#List of modelsmodels = [('k-NN', knn_classifier), ('LR', logistic_regression)]#Initializing empty lists in order to store the resultscv_scores = []model_name_list = []for name, model in models: #5-fold cross validation cv_5 = model_selection.KFold(n_splits= 5, random_state= 50) # Evaluating the accuracy scores cv_score = model_selection.cross_val_score(model, X_test, y_test, cv = cv_5, scoring= 'accuracy') cv_scores.append(cv_score) model_name_list.append(name) # Plotting the cross-validated box plot fig = plt.figure()fig.suptitle('Boxplot ...Read now
Unlock full access