How to automatically create Base Line Estimators using scikit learn.

For any machine learning problem, say a classifier in this case, it’s always handy to create quickly a base line classifier against which we can compare our new models. You don’t want to spend a lot of time creating these base line classifiers; you would rather spend that time in building and validating new features for your final model. In this post we will see how we can rapidly create base line classifier using scikit learn package for any dataset.

 

Input data set

Let us use iris dataset for demonstration purpose.

# Load Libraries import numpy as np  from sklearn import datasets   # Let us use Iris dataset iris = datasets.load_iris() x = iris.data y = iris.target  

DummyClassifier

Scikit provides the class DummyClassifier to help us create our base line model rapidly. Module sklearn.dummy has the DummyClassifier class. Its api interfaces are very similar to any other model in scikit learn, use the fit function to build the model and predict function to perform classification.

from sklearn.dummy import DummyClassifier dummy = DummyClassifier(strategy='stratified', random_state = 100, constant = None) dummy.fit(x, y)   

To finish reading, please visit source site