machine-learning.one-hot: Start a machine learning library with a feature from scikit-learn.
parent
01227b3331
commit
3ec9dc94da
|
@ -0,0 +1 @@
|
||||||
|
Doug Coleman
|
|
@ -0,0 +1,13 @@
|
||||||
|
! Copyright (C) 2012 Doug Coleman.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: tools.test machine-learning.one-hot ;
|
||||||
|
IN: machine-learning.one-hot.tests
|
||||||
|
|
||||||
|
CONSTANT: test-data {
|
||||||
|
{ "male" "female" }
|
||||||
|
{ "from Europe" "from US" "from Asia" }
|
||||||
|
{ "uses Firefox" "uses Chrome" "uses Safari" "uses Internet Explorer" }
|
||||||
|
}
|
||||||
|
|
||||||
|
{ { 1 0 0 1 0 0 0 0 1 } }
|
||||||
|
[ { 0 1 3 } test-data one-hot ] unit-test
|
|
@ -0,0 +1,11 @@
|
||||||
|
! 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 ;
|
Loading…
Reference in New Issue