A dummy classifier is a type of classifier which does not generate any insight about the data and classifies the given data using only simple rules. The classifier’s behavior is completely independent of the training data as the trends in the training data are completely ignored and instead uses one of the strategies to predict the class label.
It is used only as a simple baseline for the other classifiers i.e. any other classifier is expected to perform better on the given dataset. It is especially useful for datasets where are sure of a class imbalance. It is based on the philosophy that any analytic approach for a classification problem should be better than a random guessing approach.
Below are a few strategies used by the dummy classifier to predict a class label –
- Most Frequent: The classifier always predicts the most frequent class label in the training data.
- Stratified: It generates predictions by respecting the class distribution of the training data. It is different from the “most frequent” strategy as it instead associates a probability with each data point of being the most frequent class label.
- Uniform: It generates predictions uniformly at random.
- Constant: The classifier always predicts a constant label and is primarily used when classifying non-majority class labels.
Now, let’s see the implementation of dummy classifiers using the sklearn library –
Step 1: Importing the required Libraries
Step 2: Reading the Dataset
Step 3: Training the dummy model
Step 4: Analyzing our results
Step 5: Training the KNN model
On comparing the scores of the KNN classifier with the dummy classifier, we come to the conclusion that the KNN classifier is, in fact, a good classifier for the given data.
- Naive Bayes Classifiers
- Passive Aggressive Classifiers
- Python | Decision Tree Regression using sklearn
- Python | Linear Regression using sklearn
- ML | Implementation of KNN classifier using Sklearn
- Implementing DBSCAN algorithm using Sklearn
- Implementing Agglomerative Clustering using Sklearn
- ML | Implementing L1 and L2 regularization using Sklearn
- ML | OPTICS Clustering Implementing using Sklearn
- ML | Ridge Regressor using sklearn
- ML | Voting Classifier using Sklearn
- ML | sklearn.linear_model.LinearRegression() in Python
- Sklearn | Feature Extraction with TF-IDF
- How to use datasets.fetch_mldata() in sklearn - Python?
- Python | Create video using multiple images using OpenCV
- Python | Create a stopwatch using clock object in kivy using .kv file
- Circular (Oval like) button using canvas in kivy (using .kv file)
- Image resizing using Seam carving using OpenCV in Python
- Send mail from your Gmail account using Python
- Cartooning an Image using OpenCV - Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.