I'm trying to learn how to use kknn and am working through the iris example in the documentation.
Meanwhile, my homework requires me to apply kknn to a dataset and iteratively supply k values and test to find the best one.
While supplying a value for k is an option for the function, the iris example produces a solution without a k value being supplied:
iris.kknn <- kknn(Species~., iris.learn, iris.valid, distance = 1,
kernel = "triangular")
How do we determine from the resulting kknn object what k value was used to produce the results? Does it use an arbitrary default value, or does it somehow optimise to pick a best value for k?