Paste: Perceptron algorithm so far

Author: eipipuz
Mode: factor
Date: Fri, 4 Feb 2011 08:39:19
Plain Text |
USING: accessors alien.c-types arrays classes.struct fry kernel
    math math.vectors sequences ;
IN: perceptron

TUPLE: weighted-perceptron
    { perceptron array } { weight integer initial: 1 } ;
: <weighted-perceptron> ( perception -- weighted-perceptron )
    1 weighted-perceptron boa ;

: test-perceptron ( instance weighted-perceptron -- vote )
    [ perceptron>> ] [ weight>> ] bi [ v. sgn ] dip * ;

: predict ( weighted-perceptrons instance -- ? ) 
    '[ _ test-perceptron + ] 0 swap reduce sgn 1 eq? ;

New Annotation

Summary:
Author:
Mode:
Body: