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
- 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.
- 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:
[predictedLabels, scores] = predict(trainedModel, newData);
disp('Predicted Class Labels:');
disp('Posterior Probabilities:');
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.