perceptron

Crates.ioperceptron
lib.rsperceptron
version0.1.1
sourcesrc
created_at2020-02-18 18:06:18.612736
updated_at2020-02-18 18:13:10.791236
descriptionA super fast online learning library using perceptron
homepage
repository
max_upload_size
id210385
size7,460
Eliyahu Kiperwasser (elikip)

documentation

README

Super fast online learning using perceptron. It allows you to train your model as you go, and use an ensemble to make accurate predictions.

Background

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.

Usage

   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);
   }
Commit count: 0

cargo fmt