Implement abstract method to convert a slice to a BaseVector, Implement RealNumberVector over BaseVector instead of over Vec<T>

This commit is contained in:
Luis Moreno
2020-11-11 20:53:50 -04:00
parent 82464f41e4
commit 900078cb04
3 changed files with 22 additions and 9 deletions
+1 -4
View File
@@ -58,10 +58,7 @@ impl<T: RealNumber, M: Matrix<T>, D: NBDistribution<T, M>> BaseNaiveBayes<T, M,
*prediction
})
.collect::<Vec<T>>();
let mut y_hat = M::RowVector::zeros(rows);
for (i, prediction) in predictions.iter().enumerate().take(rows) {
y_hat.set(i, *prediction);
}
let y_hat = M::RowVector::from_slice(&predictions);
Ok(y_hat)
}
}