MyNixOS website logo
Description

Extending 'mlr3' to Functional Data Analysis.

Extends the 'mlr3' ecosystem to functional analysis by adding support for irregular and regular functional data as defined in the 'tf' package. The package provides 'PipeOps' for preprocessing functional columns and for extracting scalar features, thereby allowing standard machine learning algorithms to be applied afterwards. Available operations include simple functional features such as the mean or maximum, smoothing, interpolation, flattening, and functional 'PCA'.

mlr3fda

Package website: release | dev

Extending mlr3 to functional data.

RCMDCheck CRANstatus StackOverflow Mattermost

Installation

Install the last release from CRAN:

install.packages("mlr3fda")

Install the development version from GitHub:

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

What is mlr3fda?

The goal of mlr3fda is to extend mlr3 to functional data. This is achieved by adding support for functional feature types and providing preprocessing PipeOps that operates on functional columns. For representing functional data, the tfd_reg and tfd_irreg datatypes from the tf package are used and are available after loading mlr3fda:

library(mlr3fda)
mlr_reflections$task_feature_types[c("tfr", "tfi")]
#>         tfr         tfi 
#>   "tfd_reg" "tfd_irreg"

These datatypes can be used to represent regular and irregular functional data respectively. Currently, Learners that directly operate on functional data are not available, so it is necessary to first extract scalar features from the functional columns.

Quickstart

Here we will start with the predefined dti (Diffusion Tensor Imaging) task, see tsk("dti")$help() for more details. Besides scalar columns, this task also contains two functional columns cca and rcst.

task = tsk("dti")
task
#> <TaskRegr:dti> (340 x 4): Diffusion Tensor Imaging (DTI)
#> * Target: pasat
#> * Properties: groups
#> * Features (3):
#>   - tfi (2): cca, rcst
#>   - fct (1): sex
#> * Groups: subject_id

To train a model on this task we first need to extract scalar features from the functions. We illustrate this below by extracting the mean value.

po_fmean = po("fda.extract", features = "mean")

task_fmean = po_fmean$train(list(task))[[1L]]
task_fmean$head()
#>    pasat    sex  cca_mean rcst_mean
#> 1:    31 female 0.4493332 0.4968519
#> 2:    31 female 0.4441292 0.4810724
#> 3:    29 female 0.4257795 0.5102722
#> 4:    34 female 0.4418538 0.5453188
#> 5:    37 female 0.4700994 0.5471177
#> 6:    40 female 0.4873356 0.4969408

This can be combined with a Lerner into a GraphLearner that first extracts features and then trains a model.

# split data into train and test set
ids = partition(task, stratify = FALSE)

# define a Graph and convert it to a GraphLearner
graph = po("fda.extract", features = "mean", drop = TRUE) %>>%
  po("learner", learner = lrn("regr.rpart"))

glrn = as_learner(graph)

# train the graph learner on the train set
glrn$train(task, row_ids = ids$train)

# make predictions on the test set
glrn$predict(task, row_ids = ids$test)
#> <PredictionRegr> for 111 observations:
#>     row_ids truth response
#>          11    48 49.99174
#>          12    40 49.99174
#>          13    43 52.42105
#> ---                       
#>         324    57 52.42105
#>         325    57 41.30769
#>         326    60 49.99174

Implemented PipeOps

KeyLabelPackagesTags
fda.corCross-Correlation of Functional Datatffda, data transform
fda.extractExtracts Simple Features from Functional Columnstffda, data transform
fda.flattenFlattens Functional Columnstffda, data transform
fda.fpcaFunctional Principal Component Analysistffda, data transform
fda.interpolInterpolate Functional Columnstffda, data transform
fda.scalerangeLinearly Transform the Domain of Functional Data.tffda, data transform
fda.smoothSmoothing Functional Columnstf, statsfda, data transform

Bugs, Questions, Feedback

mlr3fda is a free and open source software project that encourages participation and feedback. If you have any issues, questions, suggestions or feedback, please do not hesitate to open an “issue” about it on the GitHub page!

In case of problems / bugs, it is often helpful if you provide a “minimum working example” that showcases the behaviour (but don’t worry about this if the bug is obvious).

Please understand that the resources of the project are limited: response may sometimes be delayed by a few days, and some feature suggestions may be rejected if they are deemed too tangential to the vision behind the project.

Acknowledgements

The development of this R-package was supported by Roche Diagonstics R&D.

Metadata

Version

0.2.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows