Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

mlr3: Machine Learning in R - next generation

License

NotificationsYou must be signed in to change notification settings

mlr-org/mlr3

Package website:release |dev

Efficient, object-oriented programming on the building blocks of machinelearning. Successor ofmlr.

r-cmd-checkDOICRAN StatusMattermost

Resources (for users and developers)

Installation

Install the last release from CRAN:

install.packages("mlr3")

Install the development version from GitHub:

# install.packages("pak")pak::pak("mlr-org/mlr3")

If you want to get started withmlr3, we recommend installing themlr3verse meta-package which installsmlr3 and some of the most important extension packages:

install.packages("mlr3verse")

Example

Constructing Learners and Tasks

library(mlr3)# create learning tasktask_penguins= as_task_classif(species~.,data=palmerpenguins::penguins)task_penguins
#### ── <TaskClassif> (344x8) ───────────────────────────────────────────────────────## • Target: species## • Target classes: Adelie (44%), Gentoo (36%), Chinstrap (20%)## • Properties: multiclass## • Features (7):##   • int (3): body_mass_g, flipper_length_mm, year##   • dbl (2): bill_depth_mm, bill_length_mm##   • fct (2): island, sex
# load learner and set hyperparameterlearner= lrn("classif.rpart",cp=.01)

Basic train + predict

# train/test splitsplit= partition(task_penguins,ratio=0.67)# train the modellearner$train(task_penguins,split$train_set)# predict dataprediction=learner$predict(task_penguins,split$test_set)# calculate performanceprediction$confusion
##            truth## response    Adelie Chinstrap Gentoo##   Adelie       146         5      0##   Chinstrap      6        63      1##   Gentoo         0         0    123
measure= msr("classif.acc")prediction$score(measure)
## classif.acc##   0.9651163

Resample

# 3-fold cross validationresampling= rsmp("cv",folds=3L)# run experimentsrr= resample(task_penguins,learner,resampling)# access resultsrr$score(measure)[, .(task_id,learner_id,iteration,classif.acc)]
##                     task_id    learner_id iteration classif.acc## 1: palmerpenguins::penguins classif.rpart         1   0.8956522## 2: palmerpenguins::penguins classif.rpart         2   0.9478261## 3: palmerpenguins::penguins classif.rpart         3   0.9649123
rr$aggregate(measure)
## classif.acc##   0.9361302

Extension Packages

Consult thewiki forshort descriptions and links to the respective repositories.

For beginners, we strongly recommend to install and load themlr3verse package for a better userexperience.

Why a rewrite?

mlr was first released toCRAN in 2013. Its core designand architecture date back even further. The addition of many featureshas led to afeaturecreep which makesmlr hard to maintain and hard toextend. We also think that while mlr was nicely extensible in some parts(learners, measures, etc.), other parts were less easy to extend fromthe outside. Also, many helpful R libraries did not exist at the timemlr was created, and their inclusionwould result in non-trivial API changes.

Design principles

  • Only the basic building blocks for machine learning are implemented inthis package.
  • Focus on computation here. No visualization or other stuff. That cango in extra packages.
  • Overcome the limitations of R’sS3classes with the help ofR6.
  • EmbraceR6 for a cleanOO-design, object state-changes and reference semantics. This might beless “traditional R”, but seems to fitmlr nicely.
  • Embracedata.tablefor fast and convenient data frame computations.
  • Combinedata.table andR6, for this we will make heavy use of listcolumns in data.tables.
  • Defensive programming and type safety. All user input is checked withcheckmate. Returntypes are documented, and mechanisms popular in base R which“simplify” the result unpredictably (e.g.,sapply() ordropargument in[.data.frame) are avoided.
  • Be light on dependencies.mlr3 requires the following packages atruntime:
    • parallelly:Helper functions for parallelization. No extra recursivedependencies.
    • future.apply:Resampling and benchmarking is parallelized with thefuture abstractioninterfacing many parallel backends.
    • backports: Ensuresbackward compatibility with older R releases. Developed by membersof themlr team. No recursive dependencies.
    • checkmate: Fastargument checks. Developed by members of themlr team. No extrarecursive dependencies.
    • mlr3misc:Miscellaneous functions used in multiple mlr3extensionpackages. Developed by themlr team.
    • paradox:Descriptions for parameters and parameter sets. Developed by themlr team. No extra recursive dependencies.
    • R6: Reference classobjects. No recursive dependencies.
    • data.table:Extension of R’sdata.frame. No recursive dependencies.
    • digest (viamlr3misc): Hash digests. No recursive dependencies.
    • uuid: Create uniquestring identifiers. No recursive dependencies.
    • lgr: Logging facility.No extra recursive dependencies.
    • mlr3measures:Performance measures. No extra recursive dependencies.
    • mlbench: Acollection of machine learning data sets. No dependencies.
    • palmerpenguins:A classification data set about penguins, used on examples andprovided as a toy task. No dependencies.
  • Reflections:Objects are queryable for properties and capabilities, allowing you toprogram on them.
  • Additional functionality that comes with extra dependencies:
    • To capture output, warnings and exceptions,evaluate andcallr can be used.

Contributing to mlr3

This R package is licensed under theLGPL-3. If youencounter problems using this software (lack of documentation,misleading or wrong documentation, unexpected behavior, bugs, …) or justwant to suggest features, please open an issue in theissuetracker. Pull requests arewelcome and will be included at the discretion of the maintainers.

Please consult thewiki for astyle guide, aroxygen guide andapull requestguide.

Citing mlr3

If you use mlr3, please cite ourJOSSarticle:

@Article{mlr3,  title = {{mlr3}: A modern object-oriented machine learning framework in {R}},  author = {Michel Lang and Martin Binder and Jakob Richter and Patrick Schratz and Florian Pfisterer and Stefan Coors and Quay Au and Giuseppe Casalicchio and Lars Kotthoff and Bernd Bischl},  journal = {Journal of Open Source Software},  year = {2019},  month = {dec},  doi = {10.21105/joss.01903},  url = {https://joss.theoj.org/papers/10.21105/joss.01903},}

About

mlr3: Machine Learning in R - next generation

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Contributors31

Languages


[8]ページ先頭

©2009-2025 Movatter.jp