Struct vaporetto::Trainer[][src]

pub struct Trainer { /* fields omitted */ }
This is supported on crate feature train only.
Expand description

Trainer.

Examples

use std::fs::File;
use std::io::{prelude::*, BufReader, BufWriter};

use vaporetto::{Dataset, Sentence, Trainer};

let mut train_sents = vec![];
let f = BufReader::new(File::open("dataset-train.txt").unwrap());
for (i, line) in f.lines().enumerate() {
    train_sents.push(Sentence::from_tokenized(line.unwrap()).unwrap());
}

let dict: Vec<String> = vec![];
let mut dataset = Dataset::new(3, 3, 3, 3, &dict, 0).unwrap();
for (i, s) in train_sents.iter().enumerate() {
    dataset.push_sentence(s);
}

let trainer = Trainer::new(0.01, 1., 1.);
let model = trainer.train(dataset).unwrap();
let mut f = BufWriter::new(File::create("model.bin").unwrap());
model.write(&mut f).unwrap();

Implementations

Creates a new trainer.

Arguments

  • epsilon - The tolerance of the termination criterion.
  • cost - The parameter C.
  • bias - The bias term.

Returns

A new trainer.

Trains a given dataset.

Arguments

  • dataset - A dataset.

Returns

A trained model.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.