Skip to content
Advertisement

What is clf and legend in ‘plot_decision_regions’?

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?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement