2
$\begingroup$

I've been running a classifier on my data with the 'NearestNeighbors' method. I've learned that I can specify the number of neighbours used with the following command:

 Classify[data, Method -> {"NearestNeighbors", "NeighborsNumber" -> X}]

However, I can't seem to find anywhere how many neighbours the classifier uses when I don't specify the number with the NeighborsNumber option. As a result, I'm not exactly sure what the "default" classifier is doing.

Does anyone have any insight into this? Any help would be much appreciated.

Thanks!

$\endgroup$

1 Answer 1

5
$\begingroup$

It probably picks an appropriate value by some (internal) heuristics. Use Information to get the parameters that were used for a particular case.

c = Classify[{1, 2, 3, 4} -> {1, 1, 2, 2}, Method -> "NearestNeighbors"];

Information[c, "MethodOption"]

(* Method -> {"NearestNeighbors", "NeighborsNumber" -> 1, 
  "DistributionSmoothing" -> 0.5, "NearestMethod" -> "KDtree"} *)
$\endgroup$
1
  • $\begingroup$ This works perfectly. I was aware that one could ask for lots of information from the classifying function, but didn't know about the method option in particular. Thanks! $\endgroup$
    – LNah
    Commented Feb 15, 2022 at 23:48

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.