pub mod binary;
pub use binary::BinaryObjective;
pub trait Objective: Send + Sync {
fn init_score(&self, labels: &[f32]) -> f64;
fn convert_output(&self, raw_scores: &[f64], out: &mut [f64]);
fn gradients(&self, raw_scores: &[f64], labels: &[f32], grads: &mut [f32], hesss: &mut [f32]);
fn gradients_packed(&self, raw_scores: &[f64], labels: &[f32], out: &mut [[f32; 2]]) {
let n = raw_scores.len();
let mut g = vec![0f32; n];
let mut h = vec![0f32; n];
self.gradients(raw_scores, labels, &mut g, &mut h);
for i in 0..n {
out[i][0] = g[i];
out[i][1] = h[i];
}
}
}