0
$\begingroup$

I'm using Sklearn's KNN to build a classifier and was wondering if there is any way to visualize the decision tree that the algorithm builds. Maybe something of this fashion

enter image description here

$\endgroup$
1

2 Answers 2

1
$\begingroup$

$k$-NN does not build a decision tree to classify a new instance, it looks at the class of the most similar examples (the nearest neighbours) in the training set. So, in short, no you cannot get a decision tree from $k$-NN. You can build a decision tree for your dataset directly by using scikit-learn's DecisionTreeClassifier instead if you need a decision tree.

$\endgroup$
1
  • $\begingroup$ Ok, thank you. This explains a lot! I had this constant confusion that the K-nn is supposed to build a decision tree, but now I get it $\endgroup$
    – nikolaevra
    Commented Apr 4, 2018 at 14:23
1
$\begingroup$

You can obtain dendrograms in other algorithms of clustering, concretely hierarchical clustering. May be you talk about that, it's not a decision, but have a similar appearance.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.