normalize_vec: Normalize to Range (0, 1)

View source: R/vec-normalize.R

normalize_vecR Documentation

Normalize to Range (0, 1)

Description

Normalization is commonly used to center and scale numeric features to prevent one from dominating in algorithms that require data to be on the same scale.

Usage

normalize_vec(x, min = NULL, max = NULL, silent = FALSE)

normalize_inv_vec(x, min, max)

Arguments

x

A numeric vector.

min

The population min value in the normalization process.

max

The population max value in the normalization process.

silent

Whether or not to report the automated min and max parameters as a message.

Details

Standardization vs Normalization

  • Standardization refers to a transformation that reduces the range to mean 0, standard deviation 1

  • Normalization refers to a transformation that reduces the min-max range: (0, 1)

See Also

  • Normalization/Standardization: standardize_vec(), normalize_vec()

  • Box Cox Transformation: box_cox_vec()

  • Lag Transformation: lag_vec()

  • Differencing Transformation: diff_vec()

  • Rolling Window Transformation: slidify_vec()

  • Loess Smoothing Transformation: smooth_vec()

  • Fourier Series: fourier_vec()

  • Missing Value Imputation for Time Series: ts_impute_vec(), ts_clean_vec()

Examples

library(dplyr)
library(timetk)

d10_daily <- m4_daily %>% filter(id == "D10")

# --- VECTOR ----

value_norm <- normalize_vec(d10_daily$value)
value      <- normalize_inv_vec(value_norm,
                                min = 1781.6,
                                max = 2649.3)

# --- MUTATE ----

m4_daily %>%
    group_by(id) %>%
    mutate(value_norm = normalize_vec(value))


timetk documentation built on June 1, 2022, 1:07 a.m.