Module Hub Beta

ML.FOREST.ADD

key tree path ((NUMERIC|CATEGORIC) attr val | LEAF val) [...]

This commands adds one or more nodes to the tree in the forest that’s stored under key. Trees are identified by numeric ids, treeid, that must begin at 0 and incremented by exactly 1 for each new tree.

Each of the nodes is described by its path and definition. The path argument is the path from the tree’s root to the node. A valid path always starts with the period character (.), which denotes the root. Optionally, the root may be followed by left or right branches , denoted by the characters l and r, respectively. For example, the path “.lr” refers to the right child of the root’s left child.

A node in the decision tree can either be a splitter or a terminal leaf. Splitter nodes are either numerical or categorical, and are added using the NUMERIC or CATEGORIC keywords. Splitter nodes also require specifying the examined attribute (attr) as well as the value (val) used in the comparison made during the branching decision. val is expected to be a double-precision floating point value for numerical splitters, and a string for categorical splitter nodes.

The leaves are created with the LEAF keyword and only require specifying their double-precision floating point value (val).

Return Value

Simple string reply

Examples

redis> ML.FOREST.ADD myforst 0 . NUMERIC 1 0.1 .l LEAF 1 .r LEAF 0
OK
redis> ML.FOREST.ADD myforst 1 . NUMERIC 1 0.1 .l LEAF 1 .r LEAF 0
OK
redis> ML.FOREST.ADD myforst 2 . NUMERIC 1 0.1 .l LEAF 0 .r LEAF 1
OK
redis> ML.FOREST.RUN myforst 1:0.01 CLASSIFICATION
“1”
redis> ML.FOREST.RUN myforst 1:0.2 CLASSIFICATION
“0”

© 2017 Redis Labs, Inc. All rights reserved.