Extracting Predicted Probability from a fitted ML/DL model

To evaluate model’s calibration

machine learning
model evaluation
Author

Tra Tran

Published

September 4, 2025

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")

🔍 Predicted Probability Extraction in Python

Package Function
scikit-learn model.predict_proba(X)
xgboost model.predict(X)
lightgbm model.predict(X)
catboost model.predict_proba(X)
keras model.predict(X)
PyTorch torch.sigmoid(model(X))