constant predictor this could indicate either that something is wrong with how we used decisiontreeclassifieror that accuracy is in fact not good measure here for comparison purposeslet' evaluate two more classifierslogisticregression and the default dummyclassifierwhich makes random predictions but produces classes with the same proportions as in the training setin[ ]from sklearn linear_model import logisticregression dummy dummyclassifier(fit(x_trainy_trainpred_dummy dummy predict(x_testprint("dummy score{ }format(dummy score(x_testy_test))logreg logisticregression( = fit(x_trainy_trainpred_logreg logreg predict(x_testprint("logreg score{ }format(logreg score(x_testy_test))out[ ]dummy score logreg score the dummy classifier that produces random output is clearly the worst of the lot (according to accuracy)while logisticregression produces very good results howevereven the random classifier yields over accuracy this makes it very hard to judge which of these results is actually helpful the problem here is that accuracy is an inadequate measure for quantifying predictive performance in this imbalanced setting for the rest of this we will explore alternative metrics that provide better guidance in selecting models in particularwe would like to have metrics that tell us how much better model is than making "most frequentpredictions or random predictionsas they are computed in pred_most_frequent and pred_dummy if we use metric to assess our modelsit should definitely be able to weed out these nonsense predictions confusion matrices one of the most comprehensive ways to represent the result of evaluating binary classification is using confusion matrices let' inspect the predictions of logisticregres sion from the previous section using the confusion_matrix function we already stored the predictions on the test set in pred_logregevaluation metrics and scoring