0
from mlxtend.plotting import plot_decision_regions

def knn_comparision(data, k):
    X = data[['x1','x2']].values
    y = data['y'].astype(int).values
    clf = neighbors.KNeighborsClassifier(n_neighbors=k)
    clf.fit(X, y)

    # Plotting decision regions
    plot_decision_regions(X, y, clf=clf, legend=2)

What are the parameters 'clf' and 'legend' in plot_decision_regions?

Shaurya Sheth
  • 185
  • 2
  • 11

1 Answers1

1

clf is the classifier object being returned from neighbors.KNeighborsClassifier, which is likely coming from sklearn.

BigBen linked the documentation already for the plot_decision_regions function, which explains what they do.

Owen Shen
  • 26
  • 2