Permalink
Find file
3ec9dc9 Oct 25, 2012
12 lines (10 sloc) 345 Bytes
! Copyright (C) 2012 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays kernel math.statistics math.vectors sequences
sequences.extras ;
IN: machine-learning.one-hot
: one-hot ( indices features -- array )
[ 1 ] 2dip
[ length ] map
[ cum-sum0 v+ ]
[ nip sum 0 <array> ] 2bi [ set-nths ] keep ;