| Title: | 'parsnip' Engines and Wrappers for Ordinal Classification Models |
| Version: | 0.2.0 |
| Description: | Bindings, methods, and tuners for using ordinal classification models with the 'parsnip' and 'dials' packages. These include the regularized elastic net ordinal regression of Wurm, Hanlon, and Rathouz (2021) <doi:10.18637/jss.v099.i06> in 'ordinalNet', the ordinal classification trees of Galimberti, Soffritti, and Di Maso (2012) <doi:10.18637/jss.v047.i10> in 'rpartScore', and the latent variable ordinal forests of Hornung (2020) <doi:10.1007/s00357-018-9302-x> in 'ordinalForest'. |
| License: | MIT + file LICENSE |
| Depends: | R (≥ 4.1), parsnip (≥ 1.6.1) |
| Imports: | cli, dials (≥ 1.4.5), purrr, rlang (≥ 1.1.4), scales (≥ 1.3.0), tibble, tidyr |
| Suggests: | dplyr, MASS, ordinal, ordinalNet, rms (≥ 6.8-0), glmnetcr, VGAM (≥ 1.1-9), rpartScore, ordinalForest, orf, QSARdata, spelling, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| URL: | https://corybrunson.github.io/ordered/ |
| BugReports: | https://github.com/corybrunson/ordered/issues |
| Config/Needs/website: | rmarkdown |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-11-17 13:55:08 UTC; jasoncorybrunson |
| Author: | Max Kuhn |
| Maintainer: | Jason Cory Brunson <cornelioid@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-17 17:30:02 UTC |
ordered: parsnip Engines for Ordinal Regression Models
Description
ordered provides engines for ordinal regression models for the parsnip package. The models may have cumulative, sequential, or adjacent-category structure, and in future these may be disaggregated into separate model types. A vignette will provide thorough illustrations of ordered functionality. See below for examples of fitting ordinal regression models with ordered.
Author(s)
Maintainer: Jason Cory Brunson cornelioid@gmail.com (ORCID)
Authors:
Jason Cory Brunson cornelioid@gmail.com (ORCID)
Max Kuhn max@posit.co (ORCID)
Other contributors:
Posit Software PBC [copyright holder]
See Also
Useful links:
Examples
if (rlang::is_installed("MASS")) {
# Weighted sample
set.seed(561246)
house_sub <- MASS::housing %>%
dplyr::sample_n(size = 120, replace = TRUE, weight = Freq) %>%
subset(select = -Freq)
train_inds <- sample(120, 80)
house_train <- house_sub[train_inds, ]
house_test <- house_sub[-train_inds, ]
# Cumulative-link proportional-odds probit regression model
fit_cpop <- ordinal_reg() %>%
set_engine("polr") %>%
set_args(ordinal_link = "probit") %>%
fit(Sat ~ Infl + Type + Cont, data = house_train)
predict(fit_cpop, house_test, type = "prob")
if (rlang::is_installed("ordinalForest")) {
# Ordinal forest
fit_orf <- rand_forest(mode = "classification") %>%
set_engine("ordinalForest") %>%
set_args(nsets = 50, trees = 100, perffunction = "probability") %>%
fit(Sat ~ Infl + Type + Cont, data = house_train)
predict(fit_orf, house_test, type = "prob")
}
}
Fit wrappers for VGAM
Description
These wrappers reorganize arguments into proper calls to VGAM::vglm() and
VGAM::vgam(), which specialize to several families of ordinal regression
models. The standardized argument values used by parsnip::ordinal_reg() and
parsnip::gen_additive_mod() are matched and converted to the values native
to VGAM within the wrappers.
Usage
VGAM_vglm_wrapper(
formula,
data,
family = "cumulative",
link = "logitlink",
parallel = FALSE,
Thresh = NULL,
...,
call = rlang::caller_env()
)
VGAM_vgam_wrapper(
formula,
data,
family = "cumulative",
link = "logitlink",
parallel = FALSE,
Thresh = NULL,
...,
call = rlang::caller_env()
)
values_ordinal_link_VGAM
values_threshold_structure_VGAM
Arguments
formula |
The formula to pass. |
data |
The data frame to pass. |
family |
The odds link function; either a standardized dial value
( |
link |
The ordinal link function; either a standardized dial value (e.g.
|
parallel |
Logical; whether predictor effects are shared across
thresholds. It corresponds to the standardized |
Thresh |
Character; the threshold constraint pattern. It corresponds to
the standardized |
... |
Additional arguments to pass. |
Details
The vector values_ordinal_link_VGAM extends the default ordinal_link
options encoded in dials::values_ordinal_link to those accepted by
VGAM::vglm() and VGAM::vgam().
The vector values_threshold_structure_VGAM extends the default
threshold_structure options encoded in
dials::values_threshold_structure to those accepted by VGAM::vglm()
and VGAM::vgam().
vgam prediction with s() terms requires a VGAM version later than 1.1-9.
ordered does not yet support the sm.os() and sm.ps() smoother terms
available to VGAM::vgam(), which VGAM recommends instead of s() for
certain models; see VGAM::vgam() (WARNING section).
Note that VGAM::vglm() and VGAM::vgam() treat the rows of data
as the units of observation: Compressed data with one row per predictor
set will be understood as having a multinomial-valued outcome; only
expanded data with one row per case will be understood as having a
single-valued ordinal outcome. (This divide cannot be bridged by passing a
column of counts to the weights argument.) These wrappers require a
single ordinal outcome column and therefore do not accept the convenient
cbind(y1, y2, ...) ~ x1 + x2 + ... encoding commonly used in VGAM.
Value
An object of S3 parent class VGAM and primary classes vglm or
vgam as returned by VGAM::vglm() and VGAM::vgam().
Examples
values_ordinal_link_VGAM
dials::ordinal_link(values = values_ordinal_link_VGAM)
values_threshold_structure_VGAM
dials::threshold_structure(values = values_threshold_structure_VGAM)
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
if (utils::packageVersion("VGAM") == package_version("1.1.9")) {#VGAM=1.1-9
# fit wrapper for linear model
( fit_orig <- VGAM::vglm(
Sat ~ Type + Infl + Cont,
family = VGAM::sratio(
link = "probitlink", parallel = TRUE, threshold = "symmetric0"
),
data = house_data
) )
( fit_wrap <- VGAM_vglm_wrapper(
Sat ~ Type + Infl + Cont,
family = "sratio",
link = "probitlink", parallel = TRUE, Thresh = "symmetric_zero",
data = house_data
) )
# fit wrapper for additive model
( fit_orig <- VGAM::vgam(
Sat ~ Type + Infl + Cont,
family = VGAM::cratio(
link = "clogloglink", parallel = TRUE, threshold = "symmetric0",
),
data = house_data
) )
( fit_wrap <- VGAM_vgam_wrapper(
Sat ~ Type + Infl + Cont,
family = "cratio",
link = "cloglog", parallel = TRUE, Thresh = "symmetric0",
data = house_data
) )
}#VGAM=1.1-9
if (utils::packageVersion("VGAM") > package_version("1.1.9")) {#VGAM>1.1-9
# fit wrapper for linear model
( fit_orig <- VGAM::vglm(
Sat ~ Type + Infl + Cont,
family = VGAM::sratio(
link = "probitlink", parallel = TRUE, Thresh = "symm0"
),
data = house_data
) )
( fit_wrap <- VGAM_vglm_wrapper(
Sat ~ Type + Infl + Cont,
family = "sratio",
link = "probitlink", parallel = TRUE, Thresh = "symmetric_zero",
data = house_data
) )
# fit wrapper for additive model
( fit_orig <- VGAM::vgam(
Sat ~ Type + Infl + Cont,
family = VGAM::cratio(
link = "clogloglink", parallel = TRUE, Thresh = "symm0",
),
data = house_data
) )
( fit_wrap <- VGAM_vgam_wrapper(
Sat ~ Type + Infl + Cont,
family = "cratio",
link = "cloglog", parallel = TRUE, Thresh = "symm0",
data = house_data
) )
}#VGAM>1.1-9
Dials for ordinal engine parameters
Description
The vector values_ordinal_link_clm extends the default ordinal_link
options encoded in dials::values_ordinal_link to those accepted by
ordinal::clm().
Usage
values_ordinal_link_clm
Details
The threshold_structure dial is defined in the dials package.
See ?dials::threshold_structure for details.
Value
An object of S3 parent class param and primary class qual_param;
see dials::new_qual_param().
Examples
values_ordinal_link_clm
dials::ordinal_link(values = values_ordinal_link_clm)
dials::threshold_structure(values = dials::values_threshold_structure)
Fit wrapper for ordinal::clm()
Description
Fit clm(), translating parallel_reg into the nominal formula. This is
done here rather than in parsnip::translate() because the formula can only
be split once data is known, and because the standard translation
(make_form_call()) overwrites any location formula that translate() sets.
Usage
clm_wrapper(
formula,
data,
weights = NULL,
parallel_reg = NULL,
link = NULL,
threshold = NULL,
...,
call = rlang::caller_env()
)
Arguments
formula |
The formula to pass. |
data |
The data frame to pass. |
weights |
An optional vector of case weights to pass. |
parallel_reg |
Logical; whether predictor effects are shared across
thresholds. When |
... |
Additional arguments to pass. |
call |
The execution environment of a currently running function. |
Value
An object of class clm as returned by ordinal::clm().
Examples
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
# arguments are translated
( fit_orig <- ordinal::clm(
Sat ~ Type + Cont, data = house_data,
link = "logit", threshold = "symmetric2"
) )
( fit_wrap <- clm_wrapper(
Sat ~ Type + Cont, data = house_data,
link = "logistic", threshold = "symmetric_zero"
) )
# relax the parallel regression assumption
( fit_orig <- ordinal::clm(
Sat ~ 1, data = house_data,
nominal = ~ Infl + Cont
) )
( fit_wrap <- clm_wrapper(
Sat ~ Infl + Cont, data = house_data,
parallel_reg = FALSE
) )
Dials for ordinalForest engine parameters
Description
These parameters are auxiliary to random forest models that use the
"ordinalForest" engine. They correspond to tuning parameters that would be
specified using set_engine("ordinalForest", ...).
Usage
naive_scores(values = c(FALSE, TRUE))
num_scores(range = c(100L, 2000L), trans = NULL)
num_score_perms(range = c(100L, 500L), trans = NULL)
num_score_trees(range = c(10L, 200L), trans = NULL)
num_scores_best(range = c(2L, 20L), trans = NULL)
ord_metric(values = values_ord_metric)
values_ord_metric
Arguments
values |
A character string of possible values. |
range |
A two-element vector holding the defaults for the smallest and largest possible values, respectively. If a transformation is specified, these values should be in the transformed units. |
trans |
A |
Details
The vector values_ord_metric provides options to the ord_metric dial.
These functions generate parameters for parsnip::rand_forest()
models using the "ordinalForest" engine. See ?ordinalForest::ordfor()
for more details on the original parameters. These parameters are
engine-specific, not general to decision tree models, so are provided here
rather than in dials.
-
naive_scores(): Whether to construct only a "naive" ordinal forest using the scores1,2,3,\ldotsfor the ordinal values; tunesnaive. -
num_scores(): The number of score sets tried prior to optimization; tunesnsets. -
num_score_perms(): The number of permutations of the class width ordering to try for each score set tried (after the first); tunesnpermtrial. -
num_score_trees(): The number of trees in the score set–specific forests; tunesntreeperdiv. -
num_scores_best(): The number of top-performing score sets used to calculate the optimized score set; tunesnbest. -
ord_metric(): The performance function used to evaluate score set–specific forests; tunesperffunction. See also?ordinalForest::perff.
Value
An object of S3 parent class param and primary class qual_param
or quant_param; see dials::new_qual_param() and
[dials::new_quant_param().
See Also
Examples
naive_scores()
num_scores()
num_score_perms()
num_score_trees()
num_scores_best()
values_ord_metric
ord_metric()
Fit wrapper for ordinalForest
Description
A wrapper is needed since they have a non-standard model interface that requires the data set and the column name (character string) for the outcome.
Usage
ordinalForest_wrapper(x, y, ...)
Arguments
x |
The predictor data. |
y |
The outcome factor. |
... |
Additional arguments to pass. |
Value
An object of S3 class ordfor as returned by
ordinalForest::ordfor().
Examples
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
# subsample to reduce runtime
house_data <- house_data[sample(nrow(house_data), nrow(house_data) / 10), ]
# fit wrapper
# (using inadvisedly few score sets and trees to reduce runtime)
( fit_orig <- ordinalForest::ordfor(
depvar = "Sat",
data = house_data,
nsets = 25, ntreefinal = 100
) )
( fit_wrap <- ordinalForest_wrapper(
x = subset(house_data, select = -Sat),
y = house_data$Sat,
nsets = 25, ntreefinal = 100
) )
Dials for ordinalNet engine parameters
Description
These parameters are auxiliary to ordinal regression models that use the
"ordinalNet" engine. They correspond to tuning parameters that would be
specified using set_engine("ordinalNet", ...).
Usage
parallel_penalty_factor(
range = c(-Inf, Inf),
trans = scales::transform_log10()
)
Arguments
range |
A two-element vector holding the defaults for the smallest and largest possible values, respectively. If a transformation is specified, these values should be in the transformed units. |
trans |
A |
Details
These functions generate parameters for parsnip::ordinal_reg()
models using the "ordinalNet" engine. See ?ordinalNet::ordinalNet() for
more details on the original parameters. These parameters are
engine-specific, not general to ordinal regression models, so are provided
here rather than in dials.
-
parallel_penalty_factor(): A nonnegative numeric factor that scales the penalty on all parallel terms; tunesparallelPenaltyFactor. Only used whenparallelTerms = TRUE.
Value
An object of S3 parent class param and primary class
quant_param; see dials::new_quant_param().
See Also
Examples
parallel_penalty_factor()
Fit and predict wrappers for ordinalNet
Description
The fit wrapper restructures case weights and reorganizes arguments into a
call to ordinalNet::ordinalNet(). The prediction wrapper interpolates
between fitted penalties to enable submodel prediction at specified
penalties.
Usage
ordinalNet_wrapper(
x,
y,
weights = NULL,
family = "cumulative",
link = "logit",
parallel_reg = NULL,
parallelTerms = TRUE,
nonparallelTerms = FALSE,
parallelPenaltyFactor = 1,
...,
call = rlang::caller_env()
)
predict_ordinalNet_wrapper(
object,
newx,
type,
lambda,
criteria = c("aic", "bic")
)
## S3 method for class ''_ordinalNet''
predict(
object,
new_data,
type = NULL,
opts = list(),
penalty = NULL,
multi = FALSE,
...
)
## S3 method for class ''_ordinalNet''
multi_predict(
object,
new_data,
type = NULL,
opts = list(),
penalty = NULL,
...
)
## S3 method for class ''_ordinalNet''
predict_raw(object, new_data, opts = list(), ...)
## S3 method for class ''_ordinalNet''
predict_classprob(object, new_data, ...)
## S3 method for class ''_ordinalNet''
predict_class(object, new_data, ...)
Arguments
x |
The predictor data. |
y |
The outcome vector. |
weights |
An optional numeric vector of case weights. When provided, the outcome is restructured into a multinomial matrix of weighted indicators. |
family |
The odds link function; either a standardized dial value
( |
link |
The ordinal link function; either a standardized dial value (e.g.
|
parallel_reg |
Logical; whether predictors share effects across
thresholds. When |
parallelTerms |
Logical; whether to use parallel terms. |
nonparallelTerms |
Logical; whether to use non-parallel terms. |
parallelPenaltyFactor |
Numeric; scale factor applied to the penalty on parallel terms. Errs when used without parallel terms. |
... |
Additional arguments to pass. |
penalty |
A numeric vector of penalty values. |
Value
An object of S3 class ordinalNet as returned by
ordinalNet::ordinalNet(), or a vector or matrix of predictions as
returned by ordinalNet::predict.ordinalNet().
Examples
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
house_matrix <- model.matrix(
Sat ~ Type + Infl + Cont + 0,
data = house_data,
contrasts.arg = lapply(house_data[, 2:4], contrasts, contrasts = FALSE)
)
pen_vec <- 10 ^ seq(-2.5, -.5, 1)
# fit wrapper
( fit_orig <- ordinalNet::ordinalNet(
house_matrix, y = house_data$Sat,
family = "sratio", link = "logit",
lambdaVals = pen_vec
) )
( fit_wrap <- ordinalNet_wrapper(
house_matrix, y = house_data$Sat,
family = "sratio", link = "logit",
lambdaVals = pen_vec
) )
fit_tidy <-
ordinal_reg(ordinal_link = "logistic", odds_link = "stopping_ratio") %>%
set_engine("ordinalNet") %>%
set_args(path_values = pen_vec, penalty = 1) %>%
fit(formula = Sat ~ Type + Infl + Cont + 0, data = house_data)
fit_tidy$fit
# predict wrapper
predict(
fit_orig,
newx = head(house_matrix),
whichLambda = 2,
type = "response"
)
predict_ordinalNet_wrapper(
fit_tidy$fit,
newx = head(house_matrix),
type = "prob",
lambda = pen_vec[2]
)
predict_ordinalNet_wrapper(
fit_tidy$fit,
newx = head(house_matrix),
type = "prob",
lambda = .01
)
Dials for orf engine parameters
Description
These parameters are auxiliary to random forest models that use the
"orf" engine. They correspond to tuning parameters that would be
specified using set_engine("orf", ...).
Usage
sample_fraction(range = c(0.1, 1), trans = NULL)
honesty(values = c(TRUE, FALSE))
honesty_fraction(range = c(0.1, 0.9), trans = NULL)
Arguments
range |
A two-element vector holding the defaults for the smallest and largest possible values, respectively. If a transformation is specified, these values should be in the transformed units. |
trans |
A |
values |
A logical vector of possible values. See |
Details
These functions generate parameters for parsnip::rand_forest()
models using the "orf" engine. See ?orf::orf() for more details on
the original parameters. These parameters are engine-specific, not general
to random forest models, so are provided here rather than in dials.
-
sample_fraction(): The fraction of observations to be subsampled; tunessample.fraction. -
honesty(): Whether to use honest splitting (sample splitting); tuneshonesty. -
honesty_fraction(): The fraction of observations reserved for the honest (estimation) sample; tuneshonesty.fraction.
Value
An object of S3 parent class param and primary class qual_param
or quant_param; see dials::new_qual_param() and
dials::new_quant_param().
See Also
Examples
sample_fraction()
honesty()
honesty_fraction()
Fit wrapper for orf
Description
The orf package uses a non-standard interface that requires the predictor
matrix X and the outcome vector Y as separate arguments, with Y as a
numeric vector. This wrapper converts the parsnip-standard data.frame (X)
and factor (Y) to the required formats before calling orf::orf().
Usage
orf_wrapper(X, Y, ...)
Arguments
X |
The predictor data (data.frame). |
Y |
The outcome factor. |
... |
Additional arguments to pass. |
Value
An object of S3 class orf as returned by orf::orf().
Examples
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
house_data <- house_data[sample(nrow(house_data), 50), ]
# encode factors as dummy variables before passing to wrapper
X_mat <- model.matrix(~ Infl + Type + Cont - 1, data = house_data)
# fit wrapper
( fit_wrap <- orf_wrapper(
X = X_mat,
Y = house_data$Sat,
num.trees = 10
) )
Predict wrappers for glmnetcr
Description
Select predictions at a specific penalty value or a vector of penalty values. For penalties between path values, linearly interpolate between the probability matrices at the neighboring steps. For penalties outside the path range, use the path endpoints.
Usage
predict_glmnetcr_wrapper(
object,
newx,
type,
lambda,
criteria = c("bic", "aic")
)
multi_predict_glmnetcr_wrapper(object, newx, type, lambda)
## S3 method for class ''_glmnetcr''
predict(
object,
new_data,
type = NULL,
opts = list(),
penalty = NULL,
multi = FALSE,
...
)
## S3 method for class ''_glmnetcr''
predict_class(object, new_data, ...)
## S3 method for class ''_glmnetcr''
predict_classprob(object, new_data, ...)
## S3 method for class ''_glmnetcr''
multi_predict(
object,
new_data,
type = NULL,
opts = list(),
penalty = NULL,
...
)
Arguments
object |
A |
newx |
A predictor matrix. |
type |
Either |
lambda |
A penalty value or vector at which to predict. If |
criteria |
The criterion by which to select |
penalty |
A numeric vector of penalty values. Overrides the default
penalty. If |
Value
predict_glmnetcr_wrapper() returns a character vector of class
predictions or a matrix of class probabilities.
multi_predict_glmnetcr_wrapper() returns a numeric array with one slice
per penalty value for class probabilities, or a character matrix with one
column per penalty value for class predictions.
Both outputs mimic those of glmnetcr::predict.glmnetcr().
Examples
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
house_matrix <- model.matrix(
Sat ~ Type + Infl + Cont + 0,
data = house_data,
contrasts.arg = lapply(house_data[, 2:4], contrasts, contrasts = FALSE)
)
pen_vec <- 10 ^ seq(-1, -2, -.25)
fit <- glmnetcr::glmnetcr(
house_matrix, y = house_data$Sat,
lambda = pen_vec
)
# predictions (may disagree if `lambda` is not on the path `fit$lambda`)
set.seed(34091)
house_submatrix <- house_matrix[sample(nrow(house_matrix), 6), ]
# single, probability
predict(
fit,
newx = house_submatrix
)$probs[, , which.min(abs(fit$lambda - .02))]
predict_glmnetcr_wrapper(
fit,
newx = house_submatrix,
type = "prob",
lambda = .02
)
# single, class
predict(
fit,
newx = house_submatrix
)$class[, which.min(abs(fit$lambda - .02))]
predict_glmnetcr_wrapper(
fit,
newx = house_submatrix,
type = "class",
lambda = .02
)
# multiple, probabilities
predict(
fit,
newx = house_submatrix
)$probs
multi_predict_glmnetcr_wrapper(
fit,
newx = house_submatrix,
type = "prob",
lambda = c(.2, .02, .002)
)
# multiple, class
predict(
fit,
newx = house_submatrix
)$class
multi_predict_glmnetcr_wrapper(
fit,
newx = house_submatrix,
type = "class",
lambda = c(.2, .02, .002)
)
Fit and predict wrappers for lrm and orm
Description
rms::orm() did not support case weights or penalty before version 7.0-0.
The fit wrapper errs or warns informatively when either is requested from an
older version. Both rms::lrm() and rms::orm() use rms::predictrms()
internally, which does not accept tibble inputs. The predict wrapper ensures
that newdata is converted to a plain data frame before the S3 method is
dispatched.
Usage
rms_orm_wrapper(formula, data, weights = NULL, ..., call = rlang::caller_env())
predict_lrm_wrapper(object, newdata, type, ...)
Arguments
formula |
The formula to pass. |
data |
The data frame to pass. |
weights |
An optional vector of case weights to pass. |
... |
Additional arguments passed to the underlying method. |
call |
The execution environment of a currently running function. |
object |
A fitted model object of class |
newdata |
A data frame or tibble of predictors. |
type |
The prediction type, passed to the underlying method. |
Value
rms_orm_wrapper() returns an object of class orm as returned by
rms::orm(). predict_lrm_wrapper() returns the result of
stats::predict() dispatched on object.
Examples
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
# fit wrapper
( fit_orig <- rms::orm(Sat ~ Infl + Type + Cont, data = house_data) )
( fit_wrap <- rms_orm_wrapper(
Sat ~ Infl + Type + Cont, data = house_data
) )
# predict wrapper
( fit <- rms::lrm(Sat ~ Infl + Type + Cont, data = house_data) )
predict(
fit,
newdata = head(house_data, 3),
type = "fitted.ind"
)
# tibble input is converted internally
predict_lrm_wrapper(
fit,
newdata = tibble::as_tibble(head(house_data, 3)),
type = "fitted.ind"
)
Dials for rpartScore engine parameters
Description
These parameters are auxiliary to decision tree models that use the
"rpartScore" engine. They correspond to tuning parameters that would be
specified using set_engine("rpartScore", ...).
Usage
split_func(values = c("abs", "quad"))
prune_func(values = c("mr", "mc"))
Arguments
values |
A character string of possible values. |
Details
split_func and prune_func are dials for split and prune,
respectively. See ?rpartScore::rpartScore for more details on the
original parameters. These parameters are engine-specific, not general to
decision tree models, so are provided here rather than in dials.
Value
An object of S3 parent class param and primary class qual_param;
see dials::new_qual_param().
See Also
Examples
split_func()
prune_func()
Fit wrapper for rpartScore
Description
A wrapper is used because the model interface requires the response variable
to be numeric rather than ordered or factor; the wrapper edits the input
data accordingly.
Usage
rpartScore_wrapper(formula, data, ...)
Arguments
formula |
The formula to pass. |
data |
The data frame to pass. |
... |
Additional arguments to pass. |
Value
An object of S3 class rpart as returned by
rpartScore::rpartScore().
Examples
house_data <-
MASS::housing[rep(seq(nrow(MASS::housing)), MASS::housing$Freq), -5]
# subsample to reduce runtime
house_data <- house_data[sample(nrow(house_data), nrow(house_data) / 5), ]
# fit wrapper
( fit_orig <- rpartScore::rpartScore(
formula = Sat ~ Infl + Type + Cont,
data = transform(house_data, Sat = as.integer(Sat))
) )
( fit_wrap <- rpartScore_wrapper(
formula = Sat ~ Infl + Type + Cont,
data = house_data
) )