JavaScript
x
11
11
1
from mlxtend.plotting import plot_decision_regions
2
3
def knn_comparision(data, k):
4
X = data[['x1','x2']].values
5
y = data['y'].astype(int).values
6
clf = neighbors.KNeighborsClassifier(n_neighbors=k)
7
clf.fit(X, y)
8
9
# Plotting decision regions
10
plot_decision_regions(X, y, clf=clf, legend=2)
11
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.