I am trying to better learn about the Probability Calibration of Statistical Models . For example, if a Random Forest model is trained on a binary supervised classification problem :
library(mlbench)
library(randomForest)
data(sonar)
rf <- randomForest(Class ~ ., data=Sonar, importance=TRUE,
proximity=TRUE)
prob = predict(rf,Sonar,type="prob")
pred = data.frame(cbind(prob , rf$predicted))
plot(pred$M, pred$V3)
plot(hist(pred$M))
As far as I understand, Probability Calibration would involve fitting a second statistical model (e.g. logistic regression) to the probability scores generated by the random forest model. For example:
pred$V3 = as.factor(ifelse(pred$V3 == "1", "0", "1"))
mylogit <- glm(V3 ~ M, data = pred, family = "binomial")
In a random forest model, if the generated probability is greater than 0.5, it belongs to the first class. If the probability is less than 0.5, it belongs to the other class. This is a very general rule which might not be very accurate. Probability Calibration might be able to solve this problem?
My Question: Can someone please tell me if my understanding of Probability Calibration is correct?
Thanks