Get e2tree on CRAN or GitHub.
Dependencies installed automatically: Rcpp, dplyr. Recommended: randomForest or ranger, rpart.plot, partykit.
Classification in 5 steps.
Derives the co-occurrence dissimilarity matrix from the Random Forest. Performance-critical computation is implemented in C++ via Rcpp; supports optional parallel execution.
| Argument | Type | Description |
|---|---|---|
| ensemble | rf / ranger | A fitted Random Forest model. Supports objects from randomForest and ranger. |
| data | data.frame | The training dataset used to fit the ensemble. |
| label | character | Name of the response variable column. |
| parallel | list | active: logical; enable parallel computation. no_cores: number of cores (NULL = auto-detect). |
Returns: A symmetric numeric matrix of dimensions n × n with values in [0, 1]. Zero diagonal. Can be passed directly to e2tree().
Grows a single decision tree guided by the ensemble's dissimilarity structure. Returns an object of class e2tree.
| Argument | Type | Description |
|---|---|---|
| formula | formula | Standard R formula specifying the response and predictors, e.g. Species ~ . |
| data | data.frame | Training dataset. Must match the data used to compute D. |
| D | matrix | Dissimilarity matrix produced by createDisMatrix(). |
| ensemble | rf / ranger | The original ensemble model. Used to extract terminal node assignments. |
| setting | list | Stopping rules: impTotal (min impurity), maxDec (min decrease), n (min observations), level (max depth). |
Predicts responses for new observations by routing them through the e2tree's split rules.
| Argument | Type | Description |
|---|---|---|
| object | e2tree | A fitted e2tree model. |
| newdata | data.frame | New data to predict. Must contain the same predictor columns. |
Also available: fitted(object) returns training predictions, residuals(object) returns training residuals.
Assesses structural fidelity between the e2tree and the original ensemble by comparing their proximity matrices.
Returns: An eValidation object. Use measures() for concordance metrics, proximity() for the heatmap matrix, and plot() for visualisation.
Computes global variable importance from the e2tree's split structure, weighted by the impurity decrease at each split.
Returns: A list with $vimp (numeric named vector) and $g_imp (a ggplot2 importance plot).
Computes Local Observation Importance — observation-level attribution scores indicating which observations most strongly drive each split.
Returns: An loi (or loi_perm) object with print(), summary(), and plot() methods.
Standard interface for e2tree objects.
| Class | Methods |
|---|---|
| e2tree | print, summary, plot, predict, fitted, residuals, as.rpart, as.party, nodes, e2splits |
| eValidation | print, summary, plot, measures, proximity |
| loi | print, summary, plot |
| loi_perm | print, summary, plot |
Convert to rpart and partykit.
e2tree objects can be converted to two widely-used R tree formats, unlocking the full ecosystem of tree visualization and inspection tools.