The scikit-learn DummyClassifier
class implements several strategies for random guessing, which can serve as a baseline for classifiers. The strategies are as follows:
stratified
: This uses the training set class distributionmost_frequent
: This predicts the most frequent classprior
: This is available in scikit-learn 0.17 and predicts by maximizing the class prioruniform
: This uses an uniform distribution to randomly sample classesconstant
: This predicts a user-specified class
As you can see, some strategies of the DummyClassifier
class always predict the same class. This can lead to warnings from some scikit-learn metrics functions. We will perform the same analysis as we did in the Computing precision, recall, and F1 score recipe, but with dummy classifiers added.