Get startedGet started for free

Visualizing decision boundaries

In this exercise, you'll visualize the decision boundaries of various classifier types.

A subset of scikit-learn's built-in wine dataset is already loaded into X, along with binary labels in y.

This exercise is part of the course

Linear Classifiers in Python

View Course

Exercise instructions

  • Create the following classifier objects with default hyperparameters: LogisticRegression, LinearSVC, SVC, KNeighborsClassifier.
  • Fit each of the classifiers on the provided data using a for loop.
  • Call the plot_4_classifers() function (similar to the code here), passing in X, y, and a list containing the four classifiers.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC, LinearSVC
from sklearn.neighbors import KNeighborsClassifier

# Define the classifiers
classifiers = [____]

# Fit the classifiers
for c in ____:
    ____

# Plot the classifiers
plot_4_classifiers(X, y, classifiers)
plt.show()
Edit and Run Code