How can I code in r for the threshold of a predictive model to automatically be a value such that the sensitivity is a particular proportion/value for all runs of the model?
For example, given the following scenarios:
- At threshold of 0.2; True positive = 20, False negative = 60 i.e. sensitivity of 0.25
- At threshold of 0.35; True positive = 60, False negative = 20 i.e. sensitivity of 0.8
How do I write an r code that automatically always picks the threshold for sensitivity 0.8 i.e. scenario 2 from above? For context, I'm using the caret modelling framework.
These links on threshold optimization did not help much:
http://topepo.github.io/caret/using-your-own-model-in-train.html#Illustration5