I have a Precision/Recall curve data for several models that I want to loop through and get the Precision at specific Recall levels (eg.: 10, 20, 30, 40, 50...100). I can do it manually by using this code:

RecallFORPrecison <- AllPRCtestV2 %>%
  filter(Recall>= 0.245 & Recall< 0.255) %>%
  group_by(Model) %>% 
  slice(which.max(Precision))

This is what I get for the above code:

# A tibble: 5 x 3
# Groups:   Model [5]
    Recall Precision  Model
     <dbl>    <fctr> <fctr>
1 0.251969  0.351648    ANN
2 0.251969  0.395062    BBN
3 0.251969  0.316832     NB
4 0.251969  0.323232     RF
5 0.251969  0.359551    SVM

is there a way to put a for-loop in the filter command that skips 10 % in my recall column for each model type?

0 Answers