unwarp: Backtransform from transformed ('warped') to original feature...

View source: R/warp-unwarp.R

unwarpR Documentation

Backtransform from transformed ('warped') to original feature space

Description

These methods apply the inverse transformation T^{-1} to data in transformed space - e.g. a feature vector in principal components space back to the original feature space, in the case of a PCA transformation.

Usage

unwarp(x, ...)

Arguments

x

The object to be backtransformed, for example a data frame or a warped_df object.

...

Additional arguments to be passed to the unwarp() method.

Value

A data frame with features in the original feature space.

See Also

warp() for the forward transformation, and pca_warper() for an example of a simple warper function based on the principal components transformation.

Examples

### Create principal components warper for Maipo data set:
xvars <- c(paste("ndvi0", 1:8, sep = ""), paste("ndwi0", 1:8, sep = ""),
           paste("b", outer(1:8,2:7,paste,sep = ""), sep = ""))
fo <- as.formula(paste("class ~", paste(xvars, collapse=" +" )))
d <- maipofields

wrp <- pca_warper(d, xvars = xvars, yvar = "class")
plot(wrp)
round(wrp$pca$rotation[,1:3], digits = 2)
summary(wrp)

# Create a data frame with transformed data:
wd <- warp(d, warper = wrp)
summary(wd)

# Backtransform it, should be identical to d:
d2 <- unwarp(wd, warper = wrp)
all.equal(d, d2[,colnames(d)])
# Default tolerance works for this data set, but you may have to use
# e.g. tol = 10^(-6) for less well conditioned data sets and
# transformations.

alexanderbrenning/wiml documentation built on Sept. 29, 2023, 4:45 a.m.