Description Usage Arguments Value Note Examples
This function will help you when you have to choose a decision threshold to turn probabilities into binary values. Depending on your scoring problem, the false negatives and false positives haven't got the same level of importance so you can't keep a 0.5 decision threshold.
1 | choix_seuil(obs_test, pred_test, seuils)
|
obs_test |
A numeric or factor vector containing the observations from the test sample you try to predict. |
pred_test |
A numeric vector inheriting from a |
seuils |
A numeric vector with the threshold values you want to try. |
Plots the graph with the false positive and false negative rates for each threshold, and displays the table with the global error rate as well as false negative and false positive rates, for each threshold. Also indicates the optimal threshold
A dataframe with the results as well as a graph of the errors will be returned in addition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Let's take an example with the SAheart dataset
## You can run the following code :
data("SAheart")
set.seed(234)
indapp <- sample(1:nrow(SAheart),nrow(SAheart)*(2/3),replace=FALSE)
dapp <- SAheart[indapp,]
dtest <- SAheart[-indapp,]
model_complet <- glm(chd~., data = dapp, family = binomial)
predictions <- predict(model_complet, newdata = dtest, type = "response")
seuils <- seq(0.4,0.9,by=0.05)
choix_seuil(dtest$chd,predictions,seuils)
## "Seuil minimisant le taux d'erreur global : 0.55"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.