extracting posterior probabilities from trained classifiers

조회 수: 2 (최근 30일)
Derrick
Derrick 2017년 10월 19일
답변: Shubham 2024년 9월 5일
I am using the Classification Learner App to classify geochemical data using the ensemble decision trees (Bagged, AdaBoost, RUSBoost). Once I export a trained classifier, is it possible to obtain posterior probabilities on the predicted class?

답변 (1개)

Shubham
Shubham 2024년 9월 5일
Hi Derrick,
Yes, once you have exported a trained classifier from the Classification Learner App in MATLAB, you can obtain posterior probabilities for the predicted classes using the exported model. The posterior probabilities represent the likelihood of each class given the input data. Here's how you can do it:
Steps to Obtain Posterior Probabilities
  1. Export the Model: After training your model in the Classification Learner App, export it to the MATLAB workspace. The exported model is typically a ClassificationEnsemble object for ensemble methods like Bagged Trees, AdaBoost, or RUSBoost.
  2. Use the predict Function: The predict function can be used to obtain both the predicted class labels and the posterior probabilities for each class.
Example Code
Assuming you have already exported the model to your workspace as trainedModel, and you have a new dataset newData for which you want to predict the classes and obtain posterior probabilities:
% Load or define your new data
% newData = ... (your new data matrix)
% Predict class labels and posterior probabilities
[predictedLabels, scores] = predict(trainedModel, newData);
% Display results
disp('Predicted Class Labels:');
disp(predictedLabels);
disp('Posterior Probabilities:');
disp(scores);
Explanation:
  • trainedModel: This is the exported model from the Classification Learner App. Make sure this variable is in your workspace.
  • newData: This is the new input data for which you want to predict class labels and obtain posterior probabilities. Make sure it has the same feature structure as the data used to train the model.
  • predict Function: This function returns two outputs:
  • predictedLabels: The predicted class labels for each observation in newData.
  • scores: A matrix where each row corresponds to an observation and each column corresponds to a class. The values represent the posterior probabilities for each class.

카테고리

Help CenterFile Exchange에서 Classification Ensembles에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by