Trains a Project-Pursuit oblique decision tree.
pptr.RdThis function trains a Project-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.
If lambda = 0, the model is trained using Linear Discriminant Analysis (LDA). If lambda > 0, the model is trained using Penalized Discriminant Analysis (PDA).
Usage
pptr(
formula = NULL,
data = NULL,
x = NULL,
y = NULL,
lambda = 0,
seed = NULL,
pp = NULL,
sr = NULL
)Arguments
- formula
A formula of the form
y ~ x1 + x2 + ..., whereyis a vector of labels andx1,x2, ... are the features.- 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.
- lambda
A regularization parameter. If
lambda = 0, the model is trained using Linear Discriminant Analysis (LDA). Iflambda > 0, the model is trained using Penalized Discriminant Analysis (PDA). Cannot be used together withpp.- seed
An optional integer seed for reproducibility. If
NULL(default), a seed is drawn from R's RNG, soset.seed()controls reproducibility. If an integer is provided, that value is used directly.- pp
A projection pursuit strategy object created by
pp_pda. Cannot be used together withlambda.- sr
A split rule strategy object created by
sr_mean_of_means(default).
See also
predict.pptr, formula.pptr, summary.pptr, print.pptr, save_json, load_json, pp_tree for parsnip integration, pp_pda, sr_mean_of_means, vignette("introduction") for a tutorial
Examples
# Example 1: formula interface with the `iris` dataset
pptr(Type ~ ., data = iris)
#>
#> Project-Pursuit Oblique Decision Tree:
#> If ([ 0.01 0.04 -0.04 -0.01 ] * x) < 0.06660754:
#> If ([ 0.04 0.07 -0.09 -0.15 ] * x) < -0.2075133:
#> Predict: virginica
#> Else:
#> Predict: versicolor
#> Else:
#> Predict: setosa
#>
# Example 2: formula interface with the `iris` dataset with regularization
pptr(Type ~ ., data = iris, lambda = 0.5)
#>
#> Project-Pursuit Oblique Decision Tree:
#> If ([ 0 -0.04 0.03 0.03 ] * x) < 0.01580044:
#> Predict: setosa
#> Else:
#> If ([ 0 0.03 -0.06 -0.15 ] * x) < -0.4503323:
#> Predict: virginica
#> Else:
#> Predict: versicolor
#>
# Example 3: matrix interface with the `iris` dataset
pptr(x = iris[, 1:4], y = iris[, 5])
#> If ([ 0.01 0.04 -0.04 -0.01 ] * x) < 0.06660754:
#> If ([ 0.04 0.07 -0.09 -0.15 ] * x) < -0.2075133:
#> Predict: virginica
#> Else:
#> Predict: versicolor
#> Else:
#> Predict: setosa
#>
# Example 4: matrix interface with the `iris` dataset with regularization
pptr(x = iris[, 1:4], y = iris[, 5], lambda = 0.5)
#> If ([ 0 -0.04 0.03 0.03 ] * x) < 0.01580044:
#> Predict: setosa
#> Else:
#> If ([ 0 0.03 -0.06 -0.15 ] * x) < -0.4503323:
#> Predict: virginica
#> Else:
#> Predict: versicolor
#>
# Example 5: formula interface with the `crabs` dataset
pptr(Type ~ ., data = crabs)
#>
#> Project-Pursuit Oblique Decision Tree:
#> If ([ 0 0 0 0 0 0 0 ] * x) < 0.004743028:
#> Predict: B
#> Else:
#> Predict: O
#>
# Example 6: formula interface with the `crabs` dataset with regularization
pptr(Type ~ ., data = crabs, lambda = 0.5)
#>
#> Project-Pursuit Oblique Decision Tree:
#> If ([ 0 0 0.01 0 0 0 0.01 ] * x) < 0.324472:
#> Predict: B
#> Else:
#> Predict: O
#>