pub trait LossFunction:
Debug
+ Send
+ Sync {
// Required methods
fn loss(
&self,
y_true: &Array1<Float>,
y_pred: &Array1<Float>,
) -> Result<Float>;
fn loss_derivative(
&self,
y_true: &Array1<Float>,
y_pred: &Array1<Float>,
) -> Result<Array1<Float>>;
fn name(&self) -> &'static str;
// Provided methods
fn loss_and_derivative(
&self,
y_true: &Array1<Float>,
y_pred: &Array1<Float>,
) -> Result<(Float, Array1<Float>)> { ... }
fn is_classification(&self) -> bool { ... }
}Expand description
Trait for loss functions that measure prediction error
Required Methods§
Sourcefn loss(&self, y_true: &Array1<Float>, y_pred: &Array1<Float>) -> Result<Float>
fn loss(&self, y_true: &Array1<Float>, y_pred: &Array1<Float>) -> Result<Float>
Compute the loss value for predictions
Provided Methods§
Sourcefn loss_and_derivative(
&self,
y_true: &Array1<Float>,
y_pred: &Array1<Float>,
) -> Result<(Float, Array1<Float>)>
fn loss_and_derivative( &self, y_true: &Array1<Float>, y_pred: &Array1<Float>, ) -> Result<(Float, Array1<Float>)>
Compute both loss and derivative (often more efficient)
Sourcefn is_classification(&self) -> bool
fn is_classification(&self) -> bool
Check if this is a classification loss (vs regression)