create_learner: Create a New Learner

View source: R/create_learner.R

create_learnerR Documentation

Create a New Learner

Description

Helper function to create a template for a learner, as well as the test and parameter test. For more details see the mlr3book.

Usage

create_learner(
  path = ".",
  classname,
  type,
  key = tolower(classname),
  algorithm,
  package,
  caller,
  feature_types,
  predict_types,
  properties,
  gh_name = "Unknown",
  label = toproper(algorithm)
)

Arguments

path

(character(1))
The path to a folder. This is where the files will be created. In case the folder is an R package, the learner file will be create in path/R and the test files will be created in path/tests/testthat. Otherwise all the files will be created in path.

classname

(character(1))
Suffix for R6 class name passed to LearnerType 'classname'.

type

(character(1))
See mlr3::mlr_reflections$task_types$type.

key

(character(1))
key for learner, if not provided defaults to the classname in all lower case. In combination with type it creates the learner's id.

algorithm

(character(1))
Brief description of the algorithm, like "Linear Model" or "Random Forest". Is used for the title of the help package and as the label (if no other label is provided).

package

(character(1))
Package from which the learner is implemented.

caller

character(1)
Training function called from the upstream package.

feature_types

(character())
Feature types that can be handled by the learner, see mlr3::mlr_reflections$task_feature_types.

predict_types

(character())
Prediction types that can be made by the learner, see mlr3::mlr_reflections$learner_predict_types.

properties

(character())
Properties that can be handled by the learner, see mlr3::mlr_reflections$learner_properties.

gh_name

(character(1))
Your GitHub handle, used to add you as the maintainer of the learner. Defaults to "Unknown".

label

(character(1))
Label for the learner, default is the value of the parameter algorithm.

Examples

## Not run: 
path = tempfile()
dir.create(path)
create_learner(
  path = path,
  classname = "Rpart",
  type = "classif",
  key = "rpart",
  algorithm = "Decision Tree",
  package = "rpart",
  caller = "rpart",
  feature_types = c("logical", "integer", "numeric", "factor", "ordered"),
  predict_types = c("response", "prob"),
  properties = c("importance", "missings", "multiclass", "twoclass", "weights"),
  gh_name = "RaphaelS1",
  label = "Regression and Partition Tree"
)

## End(Not run)

mlr-org/mlr3extralearners documentation built on Nov. 11, 2024, 11:11 a.m.