DummyClassifier

noun

say it: “DUM-ee KLAS-uh-fy-er” /ˈdʌmi ˈklæsəˌfaɪər/

A scikit-learn model that always predicts in a fixed, simple way, such as choosing the most common category, used as a baseline.

What is DummyClassifier?

DummyClassifier is a scikit-learn model that ignores the features and guesses by a simple rule: the most common class by default (strategy="most_frequent"). It gives the baseline score a real classifier has to beat, which matters most when one class is rare.

from sklearn.dummy import DummyClassifier
amounts = [[12], [40], [7], [900]]
fraud = [0, 0, 0, 1]
dummy = DummyClassifier().fit(amounts, fraud)
print(dummy.predict([[5000]]))        # [0]: always the most common answer
print(dummy.score(amounts, fraud))    # 0.75

In a sentence

  • “Her model beat the DummyClassifier by only one point.”
  • “The DummyClassifier said 'not spam' every time and was still 90% accurate.”

Level: Journeyman · More Python terms at this level

Updated