Implement cosine similarity and cosinepair (#327)

* Implement cosine similarity and cosinepair
This commit is contained in:
Lorenzo
2025-09-27 11:08:57 +01:00
committed by GitHub
parent 4841791b7e
commit 09be4681cf
9 changed files with 1018 additions and 12 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ impl Objective {
pub fn gradient<TY: Number, Y: Array1<TY>>(&self, y_true: &Y, y_pred: &Vec<f64>) -> Vec<f64> {
match self {
Objective::MeanSquaredError => zip(y_true.iterator(0), y_pred)
.map(|(true_val, pred_val)| (*pred_val - true_val.to_f64().unwrap()))
.map(|(true_val, pred_val)| *pred_val - true_val.to_f64().unwrap())
.collect(),
}
}