Description Usage Arguments Value Class Methods Details Examples
Standardize each feature of data. Three methodologies are supported:
"l2": standardize to zero-mean, unit-variance
"l1": standardize to zero-mean, unit-MAD (mean absolute deviation)
"range": standardize to unit interval range
1 | feature_standardizer(method = 'l2', tol = sqrt(.Machine$double.eps)
|
either "l2", "l1" or "range"
positive real number, scaling is not conducted if scale is below this level
FeatureStandardizer
class object
fit(x, y = NULL)
fit to x
and store the center and scale values
transform(x, y = NULL)
returns standardized x
matrix
inv_transform(x, y = NULL)
returns pre-standardized x
matrix
incr_fit(x, y = NULL)
currently not implemented
When fitted to data, the feature-wise centers and scales are stored in the object, and transformation is conducted using these center and scale values. Therefore, when applied to new data, they are not exactly standardized.
Uses aad
as the backend calculation for "l1" method
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | data(mtcars)
# zero-mean, unit-variance standardization
fs <- feature_standardizer(method='l2')
fs$fit(mtcars)
z <- fs$transform(mtcars)$x
apply(z, MARGIN=2, FUN=mean)
apply(z, MARGIN=2, FUN=sd)
w <- fs$inv_transform(z)$x
range(mtcars-w)
# zero-mean, unit-MAD (mean absolute deviation)
fs <- feature_standardizer(method='l1')
fs$fit(mtcars)
z <- fs$transform(mtcars)$x
apply(z, MARGIN=2, FUN=mean)
apply(z, MARGIN=2, FUN=lsr::aad)
w <- fs$inv_transform(z)$x
range(mtcars-w)
# standardize to unit interval
fs$set_parameters(method='range')
fs$fit(mtcars)
z <- fs$transform(mtcars)$x
apply(z, MARGIN=2, FUN=range)
w <- fs$inv_transform(z)$x
range(mtcars-w)
# incremental fit is allowed for l2 and range method
fs$set_parameters(method='l2')
fs$fit(mtcars)
fs2 <- feature_standardizer(method='l2')
fs2$incr_fit(mtcars[1:10,])
fs2$incr_fit(mtcars[11:32,])
cbind(fs$centers, fs2$centers)
cbind(fs$scales, fs2$scales)
fs$set_parameters(method='range')
fs$fit(mtcars)
fs2$set_parameters(method='range')
fs2$incr_fit(mtcars[1:14,])
fs2$incr_fit(mtcars[15:32,])
cbind(fs$centers, fs2$centers)
cbind(fs$scales, fs2$scales)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.