| pprf | R Documentation |
This function trains a Random Forest of Projection-Pursuit oblique decision tree using either a formula and data frame interface or a matrix-based interface. When using the formula interface, specify the model formula and the data frame containing the variables. For the matrix-based interface, provide matrices for the features and labels directly.
The number of trees is controlled by the size parameter. Each tree is trained on a stratified bootstrap sample drawn from the data.
The number of variables to consider at each split is controlled by the n_vars parameter.
If lambda = 0, the model is trained using Linear Discriminant Analysis (LDA). If lambda > 0, the model is trained using Penalized Discriminant Analysis (PDA).
pprf(
formula = NULL,
data = NULL,
x = NULL,
y = NULL,
mode = NULL,
size = 100,
lambda = 0.5,
n_vars = NULL,
p_vars = NULL,
seed = NULL,
max_retries = 3L,
threads = NULL,
pp = NULL,
vars = NULL,
cutpoint = NULL,
stop = NULL,
binarize = NULL,
grouping = NULL,
leaf = NULL
)
formula |
A formula of the form |
data |
A data frame containing the variables in the formula. |
x |
A matrix containing the features for each observation. |
y |
A matrix containing the labels for each observation. |
mode |
Training mode: either |
size |
The number of trees in the forest (default: 100). |
lambda |
A regularization parameter (default: 0.5). If |
n_vars |
The number of variables to consider at each split (integer). These are chosen uniformly in each split. By default, half of the variables are used ( |
p_vars |
The proportion of variables to consider at each split (number between 0 and 1, exclusive). For example, |
seed |
An optional integer seed for reproducibility. If |
max_retries |
Maximum number of retries for degenerate trees (default: 3). When a bootstrap sample yields a singular covariance matrix, the tree is retrained with a different seed up to this many times. |
threads |
The number of threads to use. The default is the number of cores available. |
pp |
A projection pursuit strategy object created by |
vars |
A variable selection strategy object created by |
cutpoint |
A split cutpoint strategy object created by |
stop |
A stopping rule object. Default depends on mode:
|
binarize |
A binarization strategy object. Default depends on mode:
|
grouping |
A grouping strategy object. Default depends on mode:
|
leaf |
A leaf strategy object. Default depends on mode:
|
Mode is taken from the mode argument when explicit, and otherwise auto-detected from 'y' (factor/character → classification, numeric → regression). Pass mode = "classification" to force classification on integer labels (e.g. binary 0/1), or mode = "regression" to assert intent on numeric responses.
OOB error, OOB predictions, permuted variable importance, and weighted variable importance are computed lazily on first access via the accessor functions ('oob_error()', 'oob_predictions()', 'permuted_importance()', 'weighted_importance()'). Training itself is fast because these OOB-based computations are deferred.
A pprf model. Its S3 class vector is
c("pprf_classification", "pprf", "ppmodel") or
c("pprf_regression", "pprf", "ppmodel") depending on the mode.
predict.pprf_classification, predict.pprf_regression, formula.ppmodel, oob_error, save_json, load_json, pp_rand_forest for parsnip integration, vignette("introduction") for a tutorial
# Example 1: formula interface with the `iris` dataset
pprf(Species ~ ., data = iris)
# Example 2: formula interface with the `iris` dataset with regularization
pprf(Species ~ ., data = iris, lambda = 0.5)
# Example 3: matrix interface with the `iris` dataset
pprf(x = iris[, 1:4], y = iris[, 5])
# Example 4: matrix interface with the `iris` dataset with regularization
pprf(x = iris[, 1:4], y = iris[, 5], lambda = 0.5)
# Example 5: formula interface with the `crabs` dataset
pprf(Type ~ ., data = crabs)
# Example 6: formula interface with the `crabs` dataset with regularization
pprf(Type ~ ., data = crabs, lambda = 0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.