python-3.xnamed-entity-recognitiongoogle-cloud-nl

How to get a confidence score in Google Cloud NLU while analyzing named entities?


I have a text that can contain multiple named entities (say, for example, one person and two organizations). I need to select one of the texts based on the confidence of the Named-Entity-Tagger. (Example at the end)

The project uses "analyzeEntities" details here to tag the Named Entities. How can I get a confidence level of each of the tagged entities?

Example: Let the text be "Homes and Joshua are two employees at StackOverflow."

Let us assume that the tagger has the following confidences:

Homes -> PERSON -> 0.3
Joshua -> PERSON -> 0.7
StackOverflow -> ORGANIZATION -> 0.4

I need to select "Joshua" as this entity has the highest confidence score. One way to do this is to get the confidence scores along with the returned content from the service API. How can I do this? Is there any way to get the scores like above?

PS: I use Python 3.x, but solutions in other languages are also welcome.


Solution

  • Currently, the API doesn't expose any confidence numbers for the entity predictions. It produces a "salience" score which associates a score to each entity to indicate how important they are in the text, not to be confused with the confidence which would indicate how confident the model is in its prediction.