Skip to contents

RandomForest Model for Searching Similar Cases

RandomForest Model for Searching Similar Cases

Details

This class uses the proximity or depth matrix of the RandomForest algorithm as a similarity matrix of training and query observations. By default all cases with at least one missing values are dropped from learning, calculating the distance matrix and searching for similar cases.

For survival endpoints, ranger stores the cumulative hazard at every distinct event time in every leaf. On large data sets this makes the forest slow to fit and large in memory (with 3000 cases and 500 trees, about 15 minutes and 6 GB). The distances and the survival predictions of this package do not use these curves, so pass a time grid, e.g. RFModel$new(Surv(time, status) ~ ., data, time.interest = 100).

References

Englund, C. and Verikas, A. (2012). A novel approach to estimate proximity in a random forest: An exploratory study. Expert Systems with Applications, 39(17), 13046–13050. doi:10.1016/j.eswa.2012.05.094

Super class

CaseBasedReasoning::CBRBase -> RFModel

Public fields

model

the statistical model

model_params

model arguments

dist_method

Distance method

proximity_type

Proximity type for dist_method = "Proximity": "original", "oob" or "rfgap" (see proximity_distance).

Methods

Inherited methods


Method print()

Prints information of the initialized object

Usage

RFModel$print()


Method new()

Initialize a RandomForest object for searching similar cases.

Usage

RFModel$new(formula, data, ...)

Arguments

formula

Object of class formula or character describing the model fit.

data

Training data of class data.frame

...

ranger RandomForest arguments. write.forest is always set to TRUE; verbose defaults to FALSE. For large survival data, set time.interest (see Details).


Method fit()

Fit the RandomForest

Usage

RFModel$fit()


Method set_distance_method()

Set the distance method. Available are Proximity and Depth

Usage

RFModel$set_distance_method(method = "Depth", proximity_type = "original")

Arguments

method

Distance calculation method (default: Depth)

proximity_type

Proximity type for method = "Proximity": "original" (default), "oob" or "rfgap". The latter two use the forest's in-bag counts; for a query given to get_similar_cases() or calc_distance_matrix() the query is treated as new data, without a query (calc_distance_matrix()) the in-sample, out-of-bag version is computed.


Method clone()

The objects of this class are cloneable with this method.

Usage

RFModel$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.