Reputation: 21
I am trying to implement a method to evaluate prediction probability as is done with the help of scikit learn's
confidence = model._predict_proba_lr(x_count).max() * 100
Is there a way to evaluate the same using BERT Models?
Currently using Bert Base Uncased.
Using Ktrain Library(using Keras internally)
Reference Code : https://github.com/amaiya/ktrain/blob/master/examples/text/20newsgroups-BERT.ipynb
Upvotes: 2
Views: 4609
Reputation: 489
In ktrain, you can pass return_proba=True
to the predictor.predict
method to output probabilities. See the text classification tutorial for more details.
Upvotes: 2
Reputation: 1599
I don't know much about the specific code you are using. But for classification (I guess this is what you're looking for), BERT uses a linear + soft-max layer over the last layer of the pre-trained BERT. So computing probabilities should be straightforward. I found an example with ktrain apparently where you can specify that you want probabilities (line 23).
Upvotes: 0