dimanche 28 novembre 2021

How to calculate the probability of each class for test sample in a classification task?

I have used Random Forest from scikit-learn for a classification task:

rf = ensemble.RandomForestClassifier(n_estimators=1000,
                                      max_depth = 10,
                                      max_features = 2,
                                      max_samples = 0.5)
rf.fit(xtrain, ytrain)
train_output_rf = rf.predict(xtrain)
test_output_rf = rf.predict(xtest)  

In practice, the trained model labels the test sample with a single output (class). Is there any way or alternative algorithm to achieve a list of probable classes for the test sample instead of single output (class)? For instance:

1. A (80%)
2. B (15%)
3. C (4%)
4. D (1%)



Aucun commentaire:

Enregistrer un commentaire