[][src]Crate perceptron

Super fast online learning using perceptron It allows you to train your model as you go, and use an ensemble of models 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);