This error occurs when the number of neighbors selected in the KNN algorithm is greater than the number of samples in the test set. In this case, the error message indicates that there are only 2 samples in the test set, but the algorithm is trying to find 3 neighbors.

To fix this error, you can reduce the number of neighbors selected (e.g. set K to 1 or 2), or increase the size of the test set to have more samples.

KNN Algorithm Error: 'ValueError: Expected n_neighbors <= n_samples'

原文地址: https://www.cveoy.top/t/topic/lEhT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录