/distRforest

R implementation for random forests with distribution-based loss functions

Primary LanguageRGNU General Public License v3.0GPL-3.0

The distRforest package

This package contains an R implementation for random forests with distribution-based loss functions.

Overview

The distRforest package is based on the rpart package and extends its functionality. The rpart package implements classification trees, standard regression trees (with a squared error loss function), Poisson regression trees (with the Poisson deviance as a loss function) and exponential scaling for survival data. The following features are added in distRforest:

  1. Develop regression trees with the gamma and log-normal deviance as loss functions for long-tailed data.
  2. Build a random forest consisting of individual rpart trees in the ensemble.

This package is mainly intented for users who want to develop a random forest on count data (via the Poisson distribution) or on long-tailed data (via the gamma or log-normal distribution). A random forest implementation that supports those distributions is lacking from the R universe, but they play a vital role in certain sectors. An example is the insurance industry, where claim counts and amounts need to be modelled and predicted for several general insurance products. If the goal of the user is to develop a random forest on a classification, standard regression or survival problem, then there are more efficient, scalable and complete random forest implementations available in the R universe.

Installation

To install distRforest from GitHub you will need devtools:

install.packages('devtools')
devtools::install_github('henckr/distRforest')

Harmony between distRforest and rpart

Note that the basic function to create a decision tree is still called rpart(...) in the distRforest package. If you have both the rpart and distRforest packages loaded in your R session, it is best to explicitly call the function via distRforest::rpart(...) to make sure you can access the extra functionality.

Disclaimer

This is an extension of the rpart package, which is on CRAN, and has the original source code on GitHub. By no means is this meant to be a completely new R package or a replacement for rpart. This is merely an extension of the rpart package for specific use-cases. The original functionality stays valid and copyright belongs to the authors Terry Therneau, Beth Atkinson and Brian Ripley. All the changes and add-ons to the original source code are listed here.