K-nn 在 R 中使用欧氏距离预测数据的 class

K-nn to predict the class of the data using Euclidean distance in R

我想在学习集上应用 k-nn 以使用欧氏距离预测数据的 class。

我发现实施此方法有些困难

您可以尝试 class 包中的 knn() 功能。它使用的是欧氏距离。

您可以查看其文档了解更多详情:

https://stat.ethz.ch/R-manual/R-devel/library/class/html/knn.html