SuffStats: Create a SuffStats Object

Description Usage Arguments Format Details Value Fields Methods Author(s) Examples

Description

SuffStats is a class of R6. It has provide some important statistics(fields or functions) inside the element of every (leaf) node in an ORT object.

Usage

1
SuffStats$new(numClasses = 0)

Arguments

numClasses

A nonnegative integer indicates how many classes when solve a classifation problem. Default 0 for regression. If numClasses > 0, then do classifation.

Format

R6Class object.

Details

Note that SuffStats may only be seen in leaf nodes of an ORT tree. See details in description of each field or method.

Value

Object of R6Class, Object of SuffStats.

Fields

node.n

Number of samples under current node. Default 0.

classify

TRUE for classification and FALSE for Regression.

node.counts

If classification, counts of each y value in current node.

node.sum

Sum of the y value in current node.

node.square.sum

Sum of the y's square in current node.

Methods

update(y)

When a sample comes in current node, update ORT with the sample's y value.

  • y - The y value of a sample.

reset()

Reset all fields to NULL. Currently not used.

isLeaf()

TRUE if current node is a leaf node otherwise FALSE.

pred()

Return the prediction of current leaf node. Will return an integer for classification or an numeric for regression.

impurity()

Return the impurity of current node. Computed via information entropy.

Author(s)

Quan Gu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# classification
sa <- SuffStats$new(numClasses = 3)
sa$update(2);sa$update(1);sa$update(2)
sa$pred()
sa$node.counts
sa$node.n
sa$impurity()

# Regression
sb <- SuffStats$new(numClasses = 0)
sb$update(1);sb$update(2);sb$update(3)
sb$pred()
sb$node.sum;sb$node.square.sum
sb$impurity()

ZJUguquan/OnlineRandomForest documentation built on May 20, 2019, 2:57 p.m.