Skip to contents

Convenience function to extract the top N most anomalous records from scored data.

Usage

get_top_anomalies(scored_data, n = 100)

Arguments

scored_data

A data frame with anomaly scores.

n

Integer indicating the number of top records to return. Default is 100.

Value

A data frame containing the top N most anomalous records, sorted by anomaly_score (descending).

Examples

# \donttest{
data <- data.frame(
  patient_id = 1:50,
  age = rnorm(50, 50, 15),
  cost = rnorm(50, 10000, 5000)
)
scored_data <- score_anomaly(data)
top_10 <- get_top_anomalies(scored_data, n = 10)
#> Error in scored_data %>% dplyr::arrange(dplyr::desc(.data$anomaly_score)) %>%     dplyr::slice_head(n = n): could not find function "%>%"
# }