Extracting Predicted Probability from a fitted ML/DL model
To evaluate model’s calibration
machine learning
model evaluation
When assessing classification models, accuracy alone isn’t enough—it’s equally important to check how well the predicted probabilities reflect true event likelihoods. A well-calibrated model provides probabilities that can be trusted for decision-making.
This post shows how to extract predicted probabilities from common machine learning and deep learning packages in R and Python.
🔍 Predicted Probability Extraction in R
| Package | Function |
|---|---|
| glm | predict(model, newdata, type = "response") |
| randomForest | predict(model, newdata, type = "prob") |
| caret | predict(model, newdata, type = "prob") |
| xgboost | predict(model, newdata) |
| lightgbm | predict(model, newdata) |
| nnet | predict(model, newdata, type = "raw") |
| mlr3 | predict(model, newdata)$prob |
| tidymodels | predict(model, new_data, type = "prob") |
| e1071 (SVM) | attr(predict(...), "probabilities") |