A simple Dictionary storing objects of class Task. Each task has an associated help page, see mlr_tasks_[id].

Methods

  • get(key, ...)
    (character(1), ...) -> any
    Retrieves object with key key from the dictionary.

  • mget(keys, ...)
    (character(), ...) -> named list()
    Retrieves objects with keys keys from the dictionary, returns them in a list named with keys.

  • has(keys)
    character() -> logical()
    Returns a logical vector with TRUE at its i-th position, if the i-th key exists.

  • keys(pattern)
    character(1) -> character()
    Returns all keys which comply to the regular expression pattern.

  • add(key, value)
    (character(1), any) -> self
    Adds object value to the dictionary with key key, potentially overwriting a previously stored value.

  • remove(key)
    character() -> self
    Removes object with key key from the dictionary.

S3 methods

See also

Examples

as.data.table(mlr_tasks)
#> key task_type measures nrow ncol lgl int dbl chr fct ord #> 1: bh regr regr.mse 506 19 0 3 13 0 2 0 #> 2: iris classif classif.mmce 150 5 0 0 4 0 0 0 #> 3: mtcars regr regr.mse 32 11 0 0 10 0 0 0 #> 4: pima classif classif.mmce 768 9 0 0 8 0 0 0 #> 5: sonar classif classif.mmce 208 61 0 0 60 0 0 0 #> 6: spam classif classif.mmce 4601 58 0 0 57 0 0 0 #> 7: wine classif classif.mmce 178 14 0 2 11 0 0 0 #> 8: zoo classif classif.mmce 101 17 15 1 0 0 0 0
mlr_tasks$get("iris")
#> <TaskClassif:iris> (150 x 5) #> Target: Species #> Features (4): #> * dbl (4): Petal.Length, Petal.Width, Sepal.Length, Sepal.Width #> #> Public: backend, cbind(), class_n, class_names, clone(), col_info, #> col_roles, data_formats, data(), droplevels(), feature_names, #> feature_types, filter(), formula(), groups, hash, head(), id, #> levels(), measures, missings(), ncol, negative, nrow, positive, #> properties, rbind(), replace_features(), row_ids, row_roles, #> select(), set_col_role(), set_row_role(), target_names, task_type, #> truth(), weights
head(mlr_tasks$get("iris")$data())
#> Species Petal.Length Petal.Width Sepal.Length Sepal.Width #> 1: setosa 1.4 0.2 5.1 3.5 #> 2: setosa 1.4 0.2 4.9 3.0 #> 3: setosa 1.3 0.2 4.7 3.2 #> 4: setosa 1.5 0.2 4.6 3.1 #> 5: setosa 1.4 0.2 5.0 3.6 #> 6: setosa 1.7 0.4 5.4 3.9
# Add a new task, based on a subset of iris: data = iris data$Species = factor(ifelse(data$Species == "setosa", "1", "0")) task = TaskClassif$new("iris.binary", data, target = "Species", positive = "1") # add to dictionary mlr_tasks$add("iris.binary", task) # list available tasks mlr_tasks$keys()
#> [1] "bh" "iris" "iris.binary" "mtcars" "pima" #> [6] "sonar" "spam" "wine" "zoo"
# retrieve from dictionary mlr_tasks$get("iris.binary")
#> <TaskClassif:iris.binary> (150 x 5) #> Target: Species #> Features (4): #> * dbl (4): Petal.Length, Petal.Width, Sepal.Length, Sepal.Width #> #> Public: backend, cbind(), class_n, class_names, clone(), col_info, #> col_roles, data_formats, data(), droplevels(), feature_names, #> feature_types, filter(), formula(), groups, hash, head(), id, #> levels(), measures, missings(), ncol, negative, nrow, positive, #> properties, rbind(), replace_features(), row_ids, row_roles, #> select(), set_col_role(), set_row_role(), target_names, task_type, #> truth(), weights
# remove task again mlr_tasks$remove("iris.binary")