extracting posterior probabilities from trained classifiers

5 ビュー (過去 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 Center および File ExchangeClassification Ensembles についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by