pub trait BinaryClassificationObjective: Objective {
// Required methods
fn predict_classes(&self, probabilities: &[f64], threshold: f64) -> Vec<f64>;
fn accuracy(
&self,
y_true: &[f64],
y_pred_proba: &[f64],
threshold: f64,
) -> ObjectiveResult<f64>;
fn binary_cross_entropy(
&self,
y_true: &[f64],
y_pred_proba: &[f64],
) -> ObjectiveResult<f64>;
}Expand description
Extended trait for binary classification objectives.
This trait extends the base Objective trait with methods specific to
binary classification, such as probability-to-class conversion and accuracy
metrics.
§Type Conversions
- Raw predictions are log-odds (any real number)
- Transformed predictions are probabilities in (0, 1)
- Class predictions are 0.0 or 1.0 based on threshold
Required Methods§
Sourcefn accuracy(
&self,
y_true: &[f64],
y_pred_proba: &[f64],
threshold: f64,
) -> ObjectiveResult<f64>
fn accuracy( &self, y_true: &[f64], y_pred_proba: &[f64], threshold: f64, ) -> ObjectiveResult<f64>
Sourcefn binary_cross_entropy(
&self,
y_true: &[f64],
y_pred_proba: &[f64],
) -> ObjectiveResult<f64>
fn binary_cross_entropy( &self, y_true: &[f64], y_pred_proba: &[f64], ) -> ObjectiveResult<f64>
Computes binary cross-entropy loss.
This is the same as Objective::loss but operates on probabilities
instead of raw predictions.