Iskander Safiulin
Iskander Safiulin

Reputation: 21

How i can get probabilities in DeepPavlov classifier?

I train my classifier using DeepPavlov, and then when i call trained model for some sample function returns only one class label, but I want to get the probabilities of every class. I did not find function parameters that would allow me to get probabilities. Has anyone encountered such a problem? Thank!

from deeppavlov import configs, train_model

model = train_model(configs.classifiers.intents_snips)

model(['Some sentence'])


I want the output like np.array with number of classes length, but current output is one label like ['PlayMusic'].

Upvotes: 2

Views: 276

Answers (1)

Aleksei Lymar
Aleksei Lymar

Reputation: 66

You can change chainer.out parameter of your config to be ["y_pred_probas"] before inferring, but it will also most likely require you to update change train.metrics if you want to train your model on the same config.

Alternatively you can call your model like

model.compute(['Some sentence'], targets=["y_pred_probas"])

And to get classes indexes you can run

dict(model['classes_vocab'])

Upvotes: 1

Related Questions