# Diagnostic

The Diagnostic Report runs some basic checks for data format and validity. Run this to ensure that you have created valid synthetic data.

## Usage

Run the diagnostic to receive a score and a corresponding report.

### run\_diagnostic

Use this function to run a diagnostic on the synthetic data.

```python
from sdv.evaluation.multi_table import run_diagnostic

diagnostic_report = run_diagnostic(
    real_data=real_data,
    synthetic_data=synthetic_data,
    metadata=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%
```

**Parameters**:

* (required) `real_data`: A pandas.DataFrame containing the real data
* (required) `synthetic_data`: A pandas.DataFrame containing the synthetic data
* (required) `metadata`: A [Metadata](https://docs.sdv.dev/sdv/concepts/metadata) object with your metadata
* `verbose`: A boolean describing whether or not to print the report progress and results. Defaults to `True`. Set this to `False` to run the report silently.

**Returns**: An [SDMetrics DiagnosticReport](https://docs.sdv.dev/sdmetrics/reports/diagnostic-report/multi-table-api) object generated with your real and synthetic data

## Interpreting the Score

{% hint style="success" %}
**The score should be 100%.** The diagnostic report checks for basic data validity and data structure issues. You should expect the score to be perfect for any of the default SDV synthesizers.
{% endhint %}

### What's Included?

The basic diagnostic checks are summarized in the table below.

<table><thead><tr><th width="158">Property</th><th>Description</th></tr></thead><tbody><tr><td>Data Validity</td><td><p>Basic validity checks for each of the columns:</p><ol><li>Primary keys must always be unique and non-null</li><li>Continuous values in the synthetic data must adhere to the min/max range in the real data</li><li>Discrete values in the synthetic data must adhere to the same categories as the real data.</li></ol></td></tr><tr><td>Relationship Validity</td><td><p>Basic validity checks for each relationship between a parent table and a child table:</p><ol><li>Each primary key in the parent table must have an appropriate number of children (i.e. cardinality) based on the min/max of the real data.</li><li>Each foreign key in the child table must reference a primary key that exists in the parent (i.e. referential integrity).</li></ol></td></tr><tr><td>Structure</td><td>Checks to ensure the real and synthetic data have the same column names</td></tr></tbody></table>

### get\_details

This function returns details about the report's properties. Use it to pinpoint the exact columns or tables that are causing issues.

**Parameters**:

* (required) `property_name`: A string with the name of the property. One of: `'Data Validity'`, `'Structure'`, or `'Relationship Validity'`
* `table_name`: A string with the name of the table. If provided, you'll receive filtered results for the table.

**Returns** A pandas.DataFrame object with the detailed scores

```python
diagnostic_report.get_details(property_name='Data Validity')
```

```python
Table     Column	        Metric                   Score
guests    guest_email           KeyUniqueness            1.0
guests    had_rewards	        CategoryAdherence	 1.0
guests    room_type	        CategoryAdherence	 1.0
guests    amenities_fee	        BoundaryAdherence	 1.0
```

## FAQs

See the [SDMetrics DiagnosticReport](https://docs.sdv.dev/sdmetrics/reports/diagnostic-report) for even more details about the metrics and properties included in the report.

<details>

<summary>What should I do if the score is not 100%?</summary>

All of the default SDV synthesizers should yield a score of 100%. If this is not the case, please get in touch by [visiting our forum](https://forum.datacebo.com/) and starting a new thread.

</details>

<details>

<summary>How did you determine what the validity checks should be?</summary>

The items in this report answer the most basic, data validity questions that we have heard from our users and customers. We've collected thousands of pieces of feedback to come up with this basic set.

IIf you have any questions or suggestions, please contact us via our [forum](https://forum.datacebo.com/).

</details>

<details>

<summary>Older versions of the Diagnostic report contained other metrics. Can I still use them?</summary>

Yes! You can compute additional metrics using our standalone [SDMetrics library](https://docs.sdv.dev/sdmetrics/).&#x20;

If you're used to older versions of the SDV, you may be looking for [NewRowSynthesis](https://docs.sdv.dev/sdmetrics/metrics/metrics-glossary/newrowsynthesis), [CategoryCoverage](https://docs.sdv.dev/sdmetrics/metrics/metrics-glossary/categorycoverage), and [RangeCoverage](https://docs.sdv.dev/sdmetrics/metrics/metrics-glossary/rangecoverage).&#x20;

</details>


---

# Agent Instructions: 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:

```
GET https://docs.sdv.dev/sdv/multi-table-data/evaluation/diagnostic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
