Create a data.frame containing functional features from a normal data.frame.
Source:R/makeFunctionalData.R
makeFunctionalData.Rd
To work with functional features, those features need to be
stored as a matrix
column in the data.frame, so mlr
can automatically
recognize them as functional features.
This function allows for an easy conversion from a data.frame with numeric columns
to the required format. If the data already contains matrix columns, they are left as-is
if not specified otherwise in fd.features
. See Examples
for the structure
of the generated output.
Arguments
- data
(data.frame)
A data.frame that contains the functional features as numeric columns.- fd.features
(list)
Named list containinginteger
column indices orcharacter
column names. Each element defines a functional feature, in the given order of the indices or column names. The name of the list element defines the name of the functional feature. All selected columns have to correspond to numeric data.frame entries. The default isNULL
, which means all numeric features are considered to be a single functional “fd1”.- exclude.cols
(character | integer)
Column names or indices to exclude from conversion to functionals, even if they are in included infd.features
. Default is not to exclude anything.
Value
(data.frame).
Examples
# data.frame where columns 1:6 and 8:10 belong to a functional feature
d1 = data.frame(matrix(rnorm(100), nrow = 10), "target" = seq_len(10))
# Transform to functional data
d2 = makeFunctionalData(d1, fd.features = list("fd1" = 1:6, "fd2" = 8:10))
# Create a regression task
makeRegrTask(data = d2, target = "target")
#> Supervised task: d2
#> Type: regr
#> Target: target
#> Observations: 10
#> Features:
#> numerics factors ordered functionals
#> 1 0 0 2
#> Missings: FALSE
#> Has weights: FALSE
#> Has blocking: FALSE
#> Has coordinates: FALSE