MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Linear Classifiers in Python

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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 dan Jalankan Kode