Function train

Source
pub fn train<F: Fn(&[f64]) -> f64>(
    settings: TrainingSettings,
    weights: &[f64],
    f: F,
) -> Result<Fit, Fit>
Expand description

Trains to fit a vector of weights on a black-box function returning error.

Returns Ok if acceptable accuracy error was achieved. Returns Err if exceeding max iterations or score was unchanged for twice the reset interval.

Examples found in repository?
examples/test.rs (line 20)
9fn main() {
10    let settings = TrainingSettings {
11        accuracy_error: 0.0,
12        step: 0.00000000000000000000001,
13        max_iterations: 1000000000000,
14        error_predictions: 3,
15        reset_interval: 40200,
16        elasticity: 1.55,
17        debug: true,
18    };
19    let weights = [6.283185176129033];
20    println!("{:?}", train(settings, &weights, lin));
21}
More examples
Hide additional examples
examples/cos_sin.rs (line 20)
9fn main() {
10    let settings = TrainingSettings {
11        accuracy_error: 0.0,
12        step: 0.000000000000000000000001,
13        max_iterations: 1000000000000,
14        error_predictions: 3,
15        reset_interval: 40200 / 10,
16        elasticity: 1.55,
17        debug: true,
18    };
19    let weights = [-1.5707963183243376];
20    println!("{:?}", train(settings, &weights, lin));
21}
examples/xsin.rs (line 20)
9fn main() {
10    let settings = TrainingSettings {
11        accuracy_error: 0.0,
12        step: 0.000000000001,
13        max_iterations: 1000000000000,
14        error_predictions: 3,
15        reset_interval: 40200 / 10,
16        elasticity: 1.55,
17        debug: true,
18    };
19    let weights = [0.12345683657383492, 9.876541862947374];
20    println!("{:?}", train(settings, &weights, lin));
21}
examples/lin.rs (line 20)
9fn main() {
10    let settings = TrainingSettings {
11        accuracy_error: 0.0,
12        step: 0.0000000000000000000000000001,
13        max_iterations: 1000000000000,
14        error_predictions: 3,
15        reset_interval: 40200,
16        elasticity: 1.55,
17        debug: true,
18    };
19    let weights = [0.12345678970668006, -9.876543207050862];
20    println!("{:?}", train(settings, &weights, lin));
21}
examples/quad.rs (line 20)
9fn main() {
10    let settings = TrainingSettings {
11        accuracy_error: 0.0,
12        step: 0.0000000000000000000000000001,
13        max_iterations: 1000000000000,
14        error_predictions: 3,
15        reset_interval: 40200,
16        elasticity: 1.55,
17        debug: true,
18    };
19    let weights = [0.12345666679385302, -9.876543156097174, 0.12345678422789191];
20    println!("{:?}", train(settings, &weights, lin));
21}