Struct rustlearn::linear_models::sgdclassifier::Hyperparameters
[−]
[src]
pub struct Hyperparameters { // some fields omitted }
Hyperparameters for a SGDClassifier
model.
Methods
impl Hyperparameters
[src]
fn new(dim: usize) -> Hyperparameters
Creates new Hyperparameters.
Examples
use rustlearn::prelude::*; use rustlearn::linear_models::sgdclassifier::Hyperparameters; let mut model = Hyperparameters::new(4) .learning_rate(1.0) .l2_penalty(0.5) .l1_penalty(0.0) .build();
fn learning_rate(&mut self, learning_rate: f32) -> &mut Hyperparameters
Set the initial learning rate.
During fitting, the learning rate decreases more for parameters which have have received larger gradient updates. This maintains more stable estimates for common features while allowing fast learning for rare features.
fn l2_penalty(&mut self, l2_penalty: f32) -> &mut Hyperparameters
Set the L2 penalty.
fn l1_penalty(&mut self, l1_penalty: f32) -> &mut Hyperparameters
Set the L1 penalty.
Coefficient sparsity is achieved by truncating at zero whenever a coefficient update would change its sign.
fn build(&self) -> SGDClassifier
Build a two-class model.
fn one_vs_rest(&self) -> OneVsRestWrapper<SGDClassifier>
Build a one-vs-rest multiclass model.