Randomer Forest

R-RerF (aka Randomer Forest (RerF) or Random Projection Forests) is an algorithm developed by Tomita (2016) which is similar to Random Forest - Random Combination (Forest-RC) developed by Breiman (2001) . Random Forests create axis-parallel, or orthogonal trees. That is, the feature space is recursively split along directions parallel to the axes of the feature space. Thus, in cases in which the classes seem inseparable along any single dimension, Random Forests may be suboptimal. To address this, Breiman also proposed and characterized Forest-RC, which uses linear combinations of coordinates rather than individual coordinates, to split along. This package, 'rerf', implements RerF which is similar to Forest-RC. The difference between the two algorithms is where the random linear combinations occur: Forest-RC combines features at the per tree level whereas RerF takes linear combinations of coordinates at every node in the tree.

• Randomer Forest

• Usage

• R: `R` building blocks for user interface code. Internally called by user interface.

• man: Package documentation

• src: C++ functions called from within R

• tests: testthat tests

Description

R-RerF (aka Randomer Forest (RerF), or Random Projection Forests) is a generalization of the Random Forest (RF) algorithm. RF partitions the input (feature) space via a series of recursive binary hyperplanes. Hyperplanes are constrained to be axis-aligned. In other words, each partition is a test of the form Xi > t, where t is a threshold and Xi is one of p inputs (features) {X1, …, Xp}. The best axis-aligned split is found by sampling a random subset of the p inputs and choosing the one that best partitions the observed data according to some specified split criterion. RerF relaxes the constraint that the splitting hyperplanes must be axis-aligned. That is, each partition in RerF is a test of the form w1X1 + … + wpXp > t. The orientations of hyperplanes are sampled randomly via a user-specified distribution on the coefficients wi, although an empirically validated default distribution is provided. Currently only classification is supported. Regression and unsupervised learning will be supported in the future.

Tested on

• Mac OSX: 10.11 (El Capitan), 10.12 (Sierra), 10.13 (High Sierra)
• Linux: Ubuntu 16.04 and 17.10, CentOS 6
• Windows: 10

Hardware Requirements

Any machine with >= 2 GB RAM

Software Dependencies

• `R (>= 3.3.0)`
• `R` packages:
• `dummies`
• `compiler`
• `RcppArmadillo`
• `RcppZiggurat`
• `parallel`

Installation

From within R-

Development Version from Github:

First install the `devtools` package if not currently installed. From within R-

Next install `rerf` from github. From within R-

Usage

Runtime for the following examples should be < 1 sec on any machine.

Create a forest:

To create a forest the minimum data needed is an n by d input matrix (X) and an n length vector of corresponding class labels (Y). Rows correspond to samples and columns correspond to features.

Expected output

`forest` is a trained forest which is needed for all other rerf functions. Additional parameters and more complex examples of training a forest can be found using the help function (`?RerF`)

Making predictions and determining error rate:

In the example below, trainIdx is used to subset the iris dataset in order to make a training set and a testing set.

Expected output

If a testing set is not available the error rate of a forest can be determined based on the samples held out-of-bag while training (out-of-bag samples are randomly chosen for each tree in the forest).

Expected output

Compute similarities:

Computes pairwise similarities between observations. The similarity between two points is defined as the fraction of trees such that two points fall into the same leaf node (i.e. two samples are similar if they consistently show up in the same leaf node). This function produces an n by n symmetric similarity matrix.

Expected output

Compute tree strengths and correlations:

Computes estimates of tree strength and correlation according to the definitions in Breiman’s 2001 Random Forests paper.

Expected output

Compute feature (projection) importance (DEV version only):

Computes the Gini importance for all of the unique projections used to split the data. The returned value is a list with members imp and features. The member imp is a numeric vector of feature importances sorted in decreasing order. The member features is a list the same length as imp of vectors specifying the split projections corresponding to the values in imp. The projections are represented by the vector such that the odd numbered indices indicate the canonical feature indices and the even numbered indices indicate the linear coefficients. For example a vector (1,-1,4,1,5,-1) is the projection -X1 + X4 - X5. Note: it is highly advised to run this only when the splitting features (projections) have unweighted coefficients, such as for the default setting or for RF.

Expected output

Train Structured RerF (S-RerF) for image classification:

S-RerF samples and evaluates a set of random features at each split node, where each feature is defined as a random linear combination of intensities of pixels contained in a contiguous patch within an image. Thus, the generated features exploit local structure inherent in images.

To be able to run this example quickly we will consider training and testing on the digits `3` and `5`. You can try a differernt subset of digits by changing `numsub` in the code chunk below.

Expected output

Unsupervised classification (U-RerF)

Using the Iris dataset we will show how to use the unsupervised verison.

News

Changes in 2.0.3:

• The `PrintTree` function has been added to aid in viewing the cut-points, features, and other statistics in a particular tree of a forest.

• Urerf now supports using the Bayesian information criterion (BIC) from the `mclust` package for determining the best split.

• Feature importance calculations now correctly handle features whose weight vectors parametrize the same line. Also, when the projection weights are continuous we tabulate how many times a unique combination of features was used, ignoring the weights.

• An issue where the `split.cpp` function split the data `A` into `{A, {}}` has been resolved by computing equivalence within some factor of machine precision instead of exactly.

Changes in 2.0.2:

• The option `rho` in the RerF function has been re-named to `sparsity` to match with the algorithm explanation.

• The default parameters sent to the RandMat* functions now properly account for categorical columns.

• The defaults have changed for the following parameters:

• `min.parent = 1`
• `max.depth = 0`
• `stratify = TRUE`
• Predictions are made based on the average of posteriors rather than average of the predictions.

• The included RandMat* functions have been re-structured for ease of use with their own examples and documentation. This should make it easier to create and include a user defined function to use as an input option.

• We are now using `testthat` for all of our function tests moving forward.

• Housekeeping: Updated the README and changed maintainers.

Reference manual

install.packages("rerf")

2.0.4 by Jesse Patsolic, 2 years ago

https://github.com/neurodata/R-RerF

Report a bug at https://github.com/neurodata/R-RerF/issues

Browse source code at https://github.com/cran/rerf

Authors: Jesse Patsolic [ctb, cre] , Benjamin Falk [ctb] , Jaewon Chung [ctb] , James Browne [aut] , Tyler Tomita [aut] , Joshua Vogelstein [ths]

Documentation:   PDF Manual

Imports parallel, RcppZiggurat, utils, stats, dummies, mclust

Depends on Rcpp

Suggests roxygen2, testthat