Skip to contents

Given a segmentation rack, returns a single dataframe with segment assignments for all models, either in tall or wide format.

Usage

rack_extract_segment_assignments(rack, type = c("wide", "tall"))

Arguments

rack

A model rack object for segmentation models.

type

If "wide" (default), return assignments in "wide" format - id column and one segment column for each model. If "tall" - result will have three columns: model_name, id and segment.

Examples

rack_extract_segment_assignments(example_seg_rack)
#> # A tibble: 100 × 5
#>    id                weight nmf_3 nmf_4 nmf_5
#>    <chr>              <dbl> <fct> <fct> <fct>
#>  1 R_yyyU2RdwNtBtXHj  0.771 3     3     4    
#>  2 R_3Jqm7E60eZmLHUL  0.879 3     1     1    
#>  3 R_TsVtU9pnig96wvf  1.08  3     3     1    
#>  4 R_1Fn2QNuPz7eT8nG  1.42  2     2     2    
#>  5 R_ai3slhE8Ua9aDV7  0.707 3     3     1    
#>  6 R_2uw8aNOkURhjVTk  1.41  3     3     3    
#>  7 R_1PdETTmHmJpBbbh  1.46  2     2     2    
#>  8 R_enW7a74WZCtGehr  1.17  3     1     3    
#>  9 R_1mCA8bWg0XAZ7Y2  1.14  3     3     1    
#> 10 R_2V4HFTieiV5VhDG  0.566 3     1     1    
#> # ℹ 90 more rows
rack_extract_segment_assignments(example_seg_rack, "tall")
#> # A tibble: 300 × 4
#>    model_name id                weight segment
#>    <fct>      <chr>              <dbl> <fct>  
#>  1 nmf_3      R_yyyU2RdwNtBtXHj  0.771 3      
#>  2 nmf_3      R_3Jqm7E60eZmLHUL  0.879 3      
#>  3 nmf_3      R_TsVtU9pnig96wvf  1.08  3      
#>  4 nmf_3      R_1Fn2QNuPz7eT8nG  1.42  2      
#>  5 nmf_3      R_ai3slhE8Ua9aDV7  0.707 3      
#>  6 nmf_3      R_2uw8aNOkURhjVTk  1.41  3      
#>  7 nmf_3      R_1PdETTmHmJpBbbh  1.46  2      
#>  8 nmf_3      R_enW7a74WZCtGehr  1.17  3      
#>  9 nmf_3      R_1mCA8bWg0XAZ7Y2  1.14  3      
#> 10 nmf_3      R_2V4HFTieiV5VhDG  0.566 3      
#> # ℹ 290 more rows