> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.emtelligent.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.emtelligent.com/_mcp/server.

# Relation Confidence

The relation confidence feature includes a confidence value for each relation predicted.

Example NLP API results:

* relation_confidence.json
* relation_confidence.txt

Specifically the following is a snippet showing an example of a measurement relation's confidence:

```python
"measurements": [
  {
    "label": "RMS0",
    "attributes": {
      "confidence": 0.9999994039535522
    },
    "args": {
      "value": {
        "ref": "E0",
        "text": [
          "97/52"
        ]
      },
      "subject": {
        "ref": "E3",
        "text": [
          "Blood pressure"
        ]
      }
    }
  },
```

## Changed

### Python API

All the relations now have a `.confidence` attribute which is a float (e.g. [confidence](/nlp/python/reference/data#measurementrelationconfidence)).

> **Note**
>
> Not all relation types currently support confidence scores, so the `.confidence` attribute may be None. See NLP API documentation on which relations will include confidence scores.

Example usage:

```python
import json
import pathlib
from emtellipro.data import AnnotatedDocument
import emtellipro.load

json_data = pathlib.Path('data/relation_confidence.json').read_text()
doc_dict = json.loads(json_data)['documents'][0]
ann_doc = AnnotatedDocument(doc_dict)

for measurement in ann_doc.relations['measurement']:
    print(
        measurement.value.text,
        measurement.subject.text,
        measurement.confidence,
    )
```

**`Output of above code.`**

```text title="Output of above code."
['97/52'] ['Blood pressure'] 0.9999994039535522
['79'] ['pulse'] 0.9999290704727173
```

### Schema changes

Each relation table now contains a `confidence` column:

* `experiencerrelation.confidence`
* `followuprelation.confidence`
* `measurementrelation.confidence`
* `imagelinkrelation.confidence`
* `qualifierrelation.confidence`
* `medicationrelation.confidence`
* `temporalityrelation.confidence`
* `reportedeventrelation.confidence`
* `anatomicsiterelation.confidence`

For example, here is the new schema for `measurementrelation` (in PostgreSQL):

```text
                                   Table "public.measurementrelation"
   Column   |       Type       | Collation | Nullable |                     Default
------------+------------------+-----------+----------+-------------------------------------------------
 id         | integer          |           | not null | nextval('measurementrelation_id_seq'::regclass)
 subject_id | integer          |           |          |
 value_id   | integer          |           |          |
 confidence | double precision |           |          |
Indexes:
    "pk_measurementrelation" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "fk_measurementrelation_subject_id_entity" FOREIGN KEY (subject_id) REFERENCES entity(id)
    "fk_measurementrelation_value_id_entity" FOREIGN KEY (value_id) REFERENCES entity(id)
```

The following is an example of what you can expect to see in that table:

```text
testdb=# select * from measurementrelation;
 id | subject_id | value_id |     confidence
----+------------+----------+--------------------
  1 |          3 |        1 | 0.9999994039535522
  2 |          4 |        2 | 0.9999290704727173
(2 rows)
```