plot.multifor: Plot method for 'multifor' objects

View source: R/plot.multifor.R

plot.multiforR Documentation

Plot method for multifor objects

Description

Plot function for multifor objects that allows to obtain a first overview of the result of the class-focused VIM analysis. This function visualises the distribution of the class-focused VIM values together with that of the corresponding discriminatory VIM values and the estimated dependency structures of the multi-class outcome on the variables with largest class-focused VIM values. These estimated dependency structures are visualised using kernel density estimate-based plots and/or boxplots.

Usage

## S3 method for class 'multifor'
plot(x, plot_type = c("both", "density", "boxplot")[1], num_best = 5, ...)

Arguments

x

Object of class multifor.

plot_type

Plot type, one of the following: "both" (the default), "density", "boxplot". If "density", kernel density estimate-based plots are produced, if "boxplot", boxplot plots are produced, and if "both", both kernel density estimate-based plots and boxplot plots are produced. See the 'Details' section of plotMcl for details.

num_best

The number of variables with largest class-focused VIM values to plot. Default is 5.

...

Further arguments passed to or from other methods.

Details

In the plot showing the distribution of the class-focused VIM values along with that of the discriminatory VIM values, the discriminatory VIM values are normalized to make them comparable to the class-focused VIM values. This is achieved by dividing the discriminatory VIM values by their mean and multiplying it by that of the class-focused VIM values.
For details on the plots of the estimated dependency structures of the multi-class outcome on the variables, see plotMcl. The latter function allows to visualise these estimated dependency structures for arbitrary variables in the data.

Value

A ggplot2 plot.

Author(s)

Roman Hornung

References

  • Hornung, R. (2022). Diversity forests: Using split sampling to enable innovative complex split procedures in random forests. SN Computer Science 3(2):1, <\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s42979-021-00920-1")}>.

See Also

plotMcl

Examples

## Not run: 

## Load package:

library("diversityForest")



## Set seed to make results reproducible:

set.seed(1234)



## Construct random forest and calculate class-focused and discriminatory VIM values:

data(hars)
model <- multifor(dependent.variable.name = "Activity", data = hars, 
                  num.trees = 100, probability=TRUE)

# NOTE: num.trees = 100 (in the above) would be likely too small for practical 
# purposes. This small number of trees was simply used to keep the
# runtime of the example short.
# The default number of trees is num.trees = 5000 for datasets with a maximum of
# 5000 observations and num.trees = 1000 for datasets larger than that.



## By default the estimated class-specific distributions of the num_best=5
## variables with the largest class-focused VIM values are plotted:

plot(model)

## Consider only the 2 variables with the largest class-focused VIM values:

plot(model, num_best = 2)

## Show only the density plots or only the boxplots:

plot(model, plot_type = "density", num_best = 2)
plot(model, plot_type = "boxplot", num_best = 2)

## Show only the plot of the distributions of the class-focused and
## discriminatory VIM values:

plot(model, num_best = 0)


## End(Not run)


diversityForest documentation built on June 8, 2025, 1:23 p.m.