Skip to contents

Model-based recursive partitioning algorithm. Calls partykit::mob() from mob.

Dictionary

This Learner can be instantiated via the dictionary mlr_learners or with the associated sugar function lrn():

mlr_learners$get("classif.mob")
lrn("classif.mob")

Meta Information

  • Task type: “classif”

  • Predict Types: “response”, “prob”

  • Feature Types: “logical”, “integer”, “numeric”, “character”, “factor”, “ordered”

  • Required Packages: mlr3, mlr3extralearners, partykit, sandwich, coin

Parameters

IdTypeDefaultLevelsRange
rhsuntyped--
fituntyped--
offsetuntyped--
clusteruntyped--
alphanumeric0.05\([0, 1]\)
bonferronilogicalTRUETRUE, FALSE-
minsizeinteger-\([1, \infty)\)
minsplitinteger-\([1, \infty)\)
minbucketinteger-\([1, \infty)\)
maxdepthintegerInf\([0, \infty)\)
mtryintegerInf\([0, \infty)\)
trimnumeric0.1\([0, \infty)\)
breaktieslogicalFALSETRUE, FALSE-
parmuntyped--
dfsplitinteger-\([0, \infty)\)
pruneuntyped--
restartlogicalTRUETRUE, FALSE-
verboselogicalFALSETRUE, FALSE-
caseweightslogicalTRUETRUE, FALSE-
ytypecharactervectorvector, matrix, data.frame-
xtypecharactermatrixvector, matrix, data.frame-
terminaluntyped"object"-
inneruntyped"object"-
modellogicalTRUETRUE, FALSE-
numsplitcharacterleftleft, center-
catsplitcharacterbinarybinary, multiway-
vcovcharacteropgopg, info, sandwich-
ordinalcharacterchisqchisq, max, L2-
nrepinteger10000\([0, \infty)\)
applyfununtyped--
coresintegerNULL\((-\infty, \infty)\)
additionaluntyped--
predict_fununtyped--

References

Hothorn T, Zeileis A (2015). “partykit: A Modular Toolkit for Recursive Partytioning in R.” Journal of Machine Learning Research, 16(118), 3905-3909. http://jmlr.org/papers/v16/hothorn15a.html.

Hothorn T, Hornik K, Zeileis A (2006). “Unbiased Recursive Partitioning: A Conditional Inference Framework.” Journal of Computational and Graphical Statistics, 15(3), 651--674. doi:10.1198/106186006x133933 , https://doi.org/10.1198/106186006x133933.

See also

Author

sumny

Super classes

mlr3::Learner -> mlr3::LearnerClassif -> LearnerClassifMob

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

LearnerClassifMob$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3)
logit_ = function(y, x, start = NULL, weights = NULL, offset = NULL, ...) {
  glm(y ~ 1, family = binomial, start = start, ...)
}
learner = LearnerClassifMob$new()
learner$param_set$values$rhs = "."
learner$param_set$values$fit = logit_
learner$param_set$values$additional = list(maxit = 100)
learner$feature_types = c("logical", "integer", "numeric", "factor", "ordered")
learner$properties = c("twoclass", "weights")

predict_fun = function(object, newdata, task, .type) {
  p = unname(predict(object, newdata = newdata, type = "response"))
  levs = task$levels(task$target_names)[[1L]]

  if (.type == "response") {
    ifelse(p < 0.5, levs[1L], levs[2L])
  } else {
    prob_vector_to_matrix(p, levs)
  }
}
task = tsk("breast_cancer")
learner$param_set$values$predict_fun = predict_fun
ids = partition(task)
learner$train(task, row_ids = ids$train)
learner$predict(task, row_ids = ids$test)
#> <PredictionClassif> for 226 observations:
#>     row_ids     truth  response
#>           1    benign    benign
#>           2    benign malignant
#>          10    benign    benign
#> ---                            
#>         643 malignant malignant
#>         654 malignant malignant
#>         683 malignant malignant