BinaryClassificationObjective

Trait BinaryClassificationObjective 

Source
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§

Source

fn predict_classes(&self, probabilities: &[f64], threshold: f64) -> Vec<f64>

Converts predicted probabilities to class labels (0.0 or 1.0).

§Parameters
  • probabilities: Slice of probability values in [0, 1]
  • threshold: Decision threshold (default: 0.5)
§Returns

Vector of class predictions (0.0 or 1.0)

§Panics

Panics if threshold is not in [0, 1]

Source

fn accuracy( &self, y_true: &[f64], y_pred_proba: &[f64], threshold: f64, ) -> ObjectiveResult<f64>

Computes classification accuracy.

§Parameters
  • y_true: True binary labels (0.0 or 1.0)
  • y_pred_proba: Predicted probabilities
  • threshold: Decision threshold for classification
§Returns

Accuracy score in [0, 1]

Source

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.

Implementors§