Skip to contents

Normalize a set of variables by converting them to proportion, making them sum to 1. Also known as simplex projection.

Usage

step_rownormalize_tss(
  recipe,
  ...,
  role = NA,
  trained = FALSE,
  res = NULL,
  skip = FALSE,
  id = rand_id("rownormalize_tss")
)

# S3 method for class 'step_rownormalize_tss'
tidy(x, ...)

Arguments

recipe

A recipe object. The step will be added to the sequence of operations for this recipe.

...

One or more selector functions to choose variables for this step. See recipes::selections() for more details.

role

Not used by this step since no new variables are created.

trained

A logical to indicate if the quantities for preprocessing have been estimated.

res

This parameter is only produced after the recipe has been trained.

skip

A logical. Should the step be skipped when the recipe is baked by recipes::bake()? While all operations are baked when recipes::prep() is run, some operations may not be able to be conducted on new data (e.g. processing the outcome variable(s)). Care should be taken when using skip = TRUE as it may affect the computations for subsequent operations.

id

A character string that is unique to this step to identify it.

x

A step_rownormalize_tss object.

Value

An updated version of recipe with the new step added to the sequence of any existing operations.

Author

Antoine Bichat

Examples

rec <-
  recipe(Species ~ ., data = iris) %>%
  step_rownormalize_tss(all_numeric_predictors()) %>%
  prep()
rec
#> 
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#> 
#> ── Inputs 
#> Number of variables by role
#> outcome:   1
#> predictor: 4
#> 
#> ── Training information 
#> Training data contained 150 data points and no incomplete rows.
#> 
#> ── Operations 
#>  TSS normalization on: Sepal.Length Sepal.Width, ... | Trained
tidy(rec, 1)
#> # A tibble: 4 × 2
#>   terms        id                    
#>   <chr>        <chr>                 
#> 1 Sepal.Length rownormalize_tss_9QeuR
#> 2 Sepal.Width  rownormalize_tss_9QeuR
#> 3 Petal.Length rownormalize_tss_9QeuR
#> 4 Petal.Width  rownormalize_tss_9QeuR
bake(rec, new_data = NULL)
#> # A tibble: 150 × 5
#>    Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#>           <dbl>       <dbl>        <dbl>       <dbl> <fct>  
#>  1        0.5         0.343        0.137      0.0196 setosa 
#>  2        0.516       0.316        0.147      0.0211 setosa 
#>  3        0.5         0.340        0.138      0.0213 setosa 
#>  4        0.489       0.330        0.160      0.0213 setosa 
#>  5        0.490       0.353        0.137      0.0196 setosa 
#>  6        0.474       0.342        0.149      0.0351 setosa 
#>  7        0.474       0.351        0.144      0.0309 setosa 
#>  8        0.495       0.337        0.149      0.0198 setosa 
#>  9        0.494       0.326        0.157      0.0225 setosa 
#> 10        0.510       0.323        0.156      0.0104 setosa 
#> # ℹ 140 more rows