Crates.io | perceptron |
lib.rs | perceptron |
version | 0.1.1 |
source | src |
created_at | 2020-02-18 18:06:18.612736 |
updated_at | 2020-02-18 18:13:10.791236 |
description | A super fast online learning library using perceptron |
homepage | |
repository | |
max_upload_size | |
id | 210385 |
size | 7,460 |
Super fast online learning using perceptron. It allows you to train your model as you go, and use an ensemble to make accurate predictions.
Preceptron is a relatively simple and fast machine learning algorithm. It has
no hyper parameters (no need to tune),
good generalization properties using ensemble and
overall good classification accuracy.
use perceptron::*;
fn and_works() {
let examples = vec!((vec!(-1.0, 1.0), false), (vec!(-1.0, -1.0), false), (vec!(1.0, -1.0), false), (vec!(1.0, 1.0), true));
let perceptron = (1..100).fold(Perceptron::new(2),
|pepoch, _epoch| examples.iter().fold(pepoch,
|pexample, example| pexample.train(example.0.clone(), example.1).unwrap()));
println!("{:?}", perceptron);
assert_eq!(perceptron.predict(examples[0].0.clone()), examples[0].1);
assert_eq!(perceptron.predict(examples[1].0.clone()), examples[1].1);
assert_eq!(perceptron.predict(examples[2].0.clone()), examples[2].1);
assert_eq!(perceptron.predict(examples[3].0.clone()), examples[3].1);
}