Subsets strategy calls based on a threshold.

threshold_strategies(strategies, threshold = NULL)

Arguments

strategies

An rtrack_strategies object as generated by call_strategy.

threshold

A numeric value between 0 and 1.

Value

An rtrack_strategies object including only above-threshold calls. In addition, the component thresholded is set to TRUE

if thresholding was performed.

Details

For strategy-calling algorithms yielding a confidence score (such as call_strategy), a value between 0 and 1 will return a new rtrack_strategies object only including calls with a confidence score above the given threshold.

Examples

require(Rtrack)
track_file <- system.file("extdata", "Track_1.tab", package = "Rtrack")
arena_description <- system.file("extdata", "Arena.txt", package = "Rtrack")
arena <- read_arena(arena_description)
path <- read_path(track_file, arena, track.format = "raw.tab")
metrics <- calculate_metrics(path, arena)
strategies <- call_strategy(metrics)
# Inspect the strategy call (minimal experiment only has one track)
strategies$calls
#>   strategy            name confidence           1           2           3
#> 1        6 directed search  0.7076923 0.003076923 0.006153846 0.003076923
#>            4    5         6         7 8 9
#> 1 0.08923077 0.04 0.7076923 0.1507692 0 0
# Thresholding at 0.7 will retain the track (confidence = 0.72)
strategies = threshold_strategies(strategies, threshold = 0.7)
strategies$calls
#>   strategy            name confidence           1           2           3
#> 1        6 directed search  0.7076923 0.003076923 0.006153846 0.003076923
#>            4    5         6         7 8 9
#> 1 0.08923077 0.04 0.7076923 0.1507692 0 0
# Thresholding at 0.8 will discard the track, still returning an (empty) rtrack_strategies object
strategies = threshold_strategies(strategies, threshold = 0.8)
strategies$calls
#>  [1] strategy   name       confidence 1          2          3         
#>  [7] 4          5          6          7          8          9         
#> <0 rows> (or 0-length row.names)