Learn R Programming

stream (version 2.0.7)

DSF_Scale: Scale a Data Stream

Description

Converts an unscaled data stream into a scaled data stream.

Usage

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

Value

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

Arguments

dsd

An object of class DSD to scale.

dim

Integer indices or names of the dimensions to scale. The default is all dimensions.

center, scale

Logical values or numeric vectors of scaling factors, each with one value per selected column (see scale).

n

Number of points used to estimate centering and scaling values.

Deprecated

DSD_ScaleStream is deprecated. Use DSF_Scale instead.

Author

Michael Hahsler

Details

If center or scale is logical, DSF_Scale() estimates the corresponding values from n points in the stream using scale in base. Estimating these values advances the stream by n points.

See Also

scale in base

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

Examples

Run this code
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)

Run the code above in your browser using DataLab