machine learning modelby always predicting "no click on the other handeven with imbalanced dataa accurate model could in fact be quite good howeveraccuracy doesn' allow us to distinguish the constant "no clickmodel from potentially good model to illustratewe'll create : imbalanced dataset from the digits datasetby classifying the digit against the nine other classesin[ ]from sklearn datasets import load_digits digits load_digits( digits target = x_trainx_testy_trainy_test train_test_splitdigits datayrandom_state= we can use the dummyclassifier to always predict the majority class (here "not nine"to see how uninformative accuracy can bein[ ]from sklearn dummy import dummyclassifier dummy_majority dummyclassifier(strategy='most_frequent'fit(x_trainy_trainpred_most_frequent dummy_majority predict(x_testprint("unique predicted labels{}format(np unique(pred_most_frequent))print("test score{ }format(dummy_majority score(x_testy_test))out[ ]unique predicted labels[falsetest score we obtained close to accuracy without learning anything this might seem strikingbut think about it for minute imagine someone telling you their model is accurate you might think they did very good job but depending on the problemthat might be possible by just predicting one classlet' compare this against using an actual classifierin[ ]from sklearn tree import decisiontreeclassifier tree decisiontreeclassifier(max_depth= fit(x_trainy_trainpred_tree tree predict(x_testprint("test score{ }format(tree score(x_testy_test))out[ ]test score model evaluation and improvement