View source: R/helper_functions.R
get_best_model_idx | R Documentation |
Identifies and returns the indices of rows in a data frame where the specified metric reaches the overall maximum within groups defined by one or more columns.
get_best_model_idx(df, metric, group_cols = c("Model", "Engine"))
df |
A data frame containing model performance metrics and grouping columns. |
metric |
A character string specifying the name of the metric column in |
group_cols |
A character vector of column names used for grouping. Defaults to |
The function converts the metric values to numeric and creates a combined grouping factor using the specified group_cols
. It then computes the maximum metric value within each group and determines the overall best metric value across the entire data frame. Finally, it returns the indices of rows belonging to groups that achieve this overall maximum.
A numeric vector of row indices in df
corresponding to groups whose maximum metric equals the overall best metric value.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.