DSF_Scale: Scale a Data Stream

View source: R/DSF_Scale.R

DSF_ScaleR Documentation

Scale a Data Stream

Description

Make an unscaled data stream into a scaled data stream.

Usage

DSF_Scale(dsd = NULL, dim = NULL, center = TRUE, scale = TRUE, n = 100L)

Arguments

dsd

A object of class DSD that will be scaled.

dim

integer vector or names of dimensions that should be scaled? Default is all.

center, scale

logical or a numeric vector of length equal to the number of columns (selected with dim) used for centering/scaling (see function scale).

n

The number of points used by scale_stream() to creating the centering/scaling

Details

If center and scale are not vectors with scaling factors, then scale_stream() estimates the values for centering and scaling (see scale in base) using n points from the stream and the stream is reset if reset = TRUE and the DSD object supports resetting.

Value

An object of class DSF_Scale (subclass of DSF and DSD).

Deprecated

DSD_ScaleStream is deprecated. Use DSF_Scale instead.

Author(s)

Michael Hahsler

See Also

scale in base

Other DSF: DSF(), DSF_Convolve(), DSF_Downsample(), DSF_ExponentialMA(), DSF_FeatureSelection(), DSF_Func(), DSF_dplyr()

Examples

stream <- DSD_Gaussians(k = 3, d = 2)
get_points(stream, 3)

# scale with manually calculated scaling factors
points <- get_points(stream, n = 100, info = FALSE)
center <- colMeans(points)
scale <- apply(points, MARGIN = 2, sd)

scaledStream <- stream %>%  DSF_Scale(dim = c(1L, 2L), center = center, scale = scale)
colMeans(get_points(scaledStream, n = 100, info = FALSE))
apply(get_points(scaledStream, n = 100, info = FALSE), MARGIN = 2, sd)

# let DSF_Scale calculate the scaling factors from the first n points of the stream
scaledStream <- stream %>% DSF_Scale(dim = c(1L, 2L), n = 100)
colMeans(get_points(scaledStream, n = 100, info = FALSE))
apply(get_points(scaledStream, n = 100, info = FALSE), MARGIN = 2, sd)

## scale only X2
scaledStream <- stream %>% DSF_Scale(dim = "X2", n = 100)
colMeans(get_points(scaledStream, n = 100, info = FALSE))
apply(get_points(scaledStream, n = 100, info = FALSE), MARGIN = 2, sd)

mhahsler/stream documentation built on April 24, 2024, 10:10 p.m.