> For the complete documentation index, see [llms.txt](https://docs.sdv.dev/sdmetrics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sdv.dev/sdmetrics/data-metrics/diagnostic.md).

# Diagnostic

Diagnostic metrics capture basic information of synthetic data, such as the format and validity. They represent the most basic kinds of measurements you can make to ensure nothing is going wrong in your synthetic data creation process.

We expect that diagnostic metrics should almost always achieve perfect scores. The only exception would be if you have made an explicit choice to deviate from the real data in some way. (For example, you purposely want the synthetic data to go out-of-bounds.)

## Diagnostic Report

**Measure basic diagnostic metrics at once.** The [Diagnostic Report](/sdmetrics/data-metrics/diagnostic/diagnostic-report-api.md) is designed to capture basic diagnostic measurements across your entire dataset at once, reporting areas that may be problematic.

```python
from sdmetrics.reports import DiagnosticReport

report = DiagnosticReport()
report.generate(real_data, synthetic_data, metadata)
```

```
Generating report ...

(1/3) Evaluating Data Validity: |██████████| 15/15 [00:00<00:00, 603.69it/s]|
Data Validity Score: 100.0%

(2/3) Evaluating Data Structure: |██████████| 2/2 [00:00<00:00, 151.49it/s]|
Data Structure Score: 100.0%

(3/3) Evaluating Relationship Validity: |██████████| 1/1 [00:00<00:00, 68.51it/s]|
Relationship Validity Score: 100.0%

Overall Score (Average): 100.0%
```

## How does it work?

The diagnostic report captures the **Validity**, **Structure** and **Relationship Validity**.

### Data Validity

Does each column in the data contain valid data?

<figure><img src="/files/XbskJT3oDcaiPhLdWRIx" alt=""><figcaption></figcaption></figure>

#### Methodology

This property applies metrics based on the column types.

<table><thead><tr><th width="186">Column Type</th><th width="194">Metric</th><th>Validity Check</th></tr></thead><tbody><tr><td>primary keys</td><td><a href="/pages/YlwEoEwKsGFpIuq38pzn">KeyUniqueness</a></td><td>Primary keys must always be unique and non-null</td></tr><tr><td>numerical, datetime</td><td><a href="/pages/2enr2rLXB6mulN1uWuEV">BoundaryAdherence</a></td><td>Continuous values in the synthetic data must adhere to the min/max range in the real data</td></tr><tr><td>categorical, boolean</td><td><a href="/pages/D2VB6WKxdZ0si3HhGzkw">CategoryAdherence</a></td><td>Discrete values in the synthetic data must adhere to the same categories as the real data.</td></tr></tbody></table>

This yields a separate score for every column. The final **Data Validity** score is the average of all columns.

### Data Structure

Does each table have the same overall structure as the real data? The structure includes the column names.

<figure><img src="/files/IHvH4qT6bCpJ0E2Ukng7" alt=""><figcaption></figcaption></figure>

#### Methodology

This property applies the [TableStructure](/sdmetrics/data-metrics/diagnostic/tablestructure.md) metric to each table of the dataset. This checks to see that there are the same set of column names in the synthetic vs. the real data.

### Relationship Validity

{% hint style="info" %}
This property is only available for multi table datasets.
{% endhint %}

Does the synthetic data contain valid relationships between different tables?

<figure><img src="/files/EJ7B8f4vIvMLijv2YlNq" alt=""><figcaption></figcaption></figure>

#### Methodology

Every relationship in your dataset is determined by a primary/foreign key connection. This property applies two metrics to the relationship to determine the validity:

* [ReferentialIntegrity](/sdmetrics/data-metrics/diagnostic/referentialintegrity.md): Does each foreign key refer to an existing primary key? If a foreign key refers to a non-existent primary key, it is known as an *orphaned child*, which is invalid in most databases.
* [CardinalityBoundaryAdherence](/sdmetrics/data-metrics/diagnostic/cardinalityboundaryadherence.md): Does each primary key have the correct number of children? The correct number is based on the min/max bounds that are present in the real data.

The final **Relationship Validity** score is the average of all the sub scores.

## Browse Metrics

Alternatively, you can apply diagnostic metrics to individual columns and tables in your data:

* [BoundaryAdherence](/sdmetrics/data-metrics/diagnostic/boundaryadherence.md), [CategoryAdherence](/sdmetrics/data-metrics/diagnostic/categoryadherence.md): measure the validity of statistical values
* [KeyUniqueness](/sdmetrics/data-metrics/diagnostic/keyuniqueness.md): measure the validity of primary keys
* [ReferentialIntegrity](/sdmetrics/data-metrics/diagnostic/referentialintegrity.md), [CardinalityBoundaryAdherence](/sdmetrics/data-metrics/diagnostic/cardinalityboundaryadherence.md): measure the validity of a connection between a foreign and primary key
* [TableStructure](/sdmetrics/data-metrics/diagnostic/tablestructure.md): measure whether the overall structure of the data is the same


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sdv.dev/sdmetrics/data-metrics/diagnostic.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
