Merge pull request #13 from morenol/lmm/knn

Allow KNN with k=1
This commit is contained in:
VolodymyrOrlov
2020-10-16 11:21:37 -07:00
committed by GitHub
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -41,6 +41,9 @@ impl<'a, T: PartialOrd + Debug> HeapSelection<T> {
pub fn heapify(&mut self) {
let n = self.heap.len();
if n <= 1 {
return;
}
for i in (0..=(n / 2 - 1)).rev() {
self.sift_down(i, n - 1);
}
+2 -2
View File
@@ -116,9 +116,9 @@ impl<T: RealNumber, D: Distance<Vec<T>, T>> KNNRegressor<T, D> {
)));
}
if parameters.k <= 1 {
if parameters.k < 1 {
return Err(Failed::fit(&format!(
"k should be > 1, k=[{}]",
"k should be > 0, k=[{}]",
parameters.k
)));
}