[][src]Trait liblinear::LibLinearCrossValidator

pub trait LibLinearCrossValidator: HasLibLinearProblem + HasLibLinearParameter {
    fn cross_validation(&self, folds: i32) -> Result<Vec<f64>, ModelError>;
fn find_optimal_constraints_violation_cost(
        &self,
        folds: i32,
        search_range: (f64, f64)
    ) -> Result<(f64, f64), ModelError>; }

Represents a linear model that can be used for validation.

Required methods

fn cross_validation(&self, folds: i32) -> Result<Vec<f64>, ModelError>

Performs k-folds cross-validation and returns the predicted labels.

Number of folds must be >= 2.

fn find_optimal_constraints_violation_cost(
    &self,
    folds: i32,
    search_range: (f64, f64)
) -> Result<(f64, f64), ModelError>

Performs k-folds cross-validation to find the best cost value (parameter C) within the closed search range (start_C, end_C) and returns a tuple of the following values:

  • The best cost value.
  • The accuracy of the best cost value.

Cross validation is conducted many times under the following values of C:

  • start_C
  • 2 * start_C
  • 4 * start_C
  • 8 * start_C, and so on

...and finds the best one with the highest cross validation accuracy. The procedure stops when the models of all folds become stable or the cost reaches end_C.

If start_C is <= 0, an appropriately small value is automatically calculated and used instead.

Loading content...

Implementors

Loading content...