Create Baseline Classification Model


# Load libraries
from sklearn.datasets import load_iris
from sklearn.dummy import DummyClassifier
from sklearn.model_selection import train_test_split

Load Iris Flower Dataset

# Load data
iris = load_iris()

# Create target vector and feature matrix
X, y =,

Split Data Into Training And Test Set

# Split into training and test set
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

Create Dummy Regression Always Predicts The Mean Value Of Target

# Create dummy classifer
dummy = DummyClassifier(strategy='uniform', random_state=1)

# "Train" model, y_train)
DummyClassifier(constant=None, random_state=1, strategy='uniform')

Evaluate Performance Metric

# Get accuracy score
dummy.score(X_test, y_test)