Skip to main content

Overview

This library contains tools for evaluating fidelity and privacy of synthetic data.

Usage

Import the desired modules from the library:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from tonic_reporting import univariate, multivariate, privacy

Preface

Numeric columns refer to columns encoded as numeric. Numerical data types in the schema underlying a model may be encoded as other types.

Categorical columns refer to columns encoded as categorical.

source_df is a Pandas DataFrame of original data from the source database

synth_df is a Pandas DataFrame of sampled data from trained models

The source and synthetic DataFrames should be equal in row count and schema.

Numeric Column Statistics

univariate.summarize_numeric(source_df, synth_df, numeric_cols)

Categorical Column Statistics

univariate.summarize_categorical(source_df, synth_df, categorical_cols)

Numeric Column Comparative Histograms

fig, axarr = plt.subplots(1, len(numeric_cols), figsize = (9,12))
axarr = axarr.ravel()

for col, ax in zip(numeric_cols, axarr):
    univariate.plot_histogram(source_df, synth_df, col,ax)

Categorical Column Comparative Frequency Tables

for col in categorical_cols:
    univariate.plot_frequency_table(source_df, synth_df, col, ax)

Numeric Column Aggregates Over Time

If the data represents time series, we can visualize means and confidence intervals of numeric features over time:

for col in numeric_cols:
    fig, ax = plt.subplots(figsize=(10, 8))
    univariate.plot_events_means(source_df, synth_df, col, order_col, ax=ax)

and

for col in numeric_cols:
    fig, ax = plt.subplots(figsize=(12, 10))
    univariate.plot_events_confidence_intervals(source_df, synth_df, col, order_col, ax=ax)

where order_col denotes the time/order column.

Numeric Column Multivariate Correlations Table

multivariate.summarize_correlations(source_df, synth_df, numeric_cols)

Numeric Column Multivariate Correlations Heat Map

fig, axarr = plt.subplots(1, 2, figsize=(13, 8))
multivariate.plot_correlations(source_df, synth_df, numeric_cols, axarr=axarr, )
fig.tight_layout()

Distance to Closest Record Comparison

syn_dcr, real_dcr = privacy.compute_dcr(source_df, synth_df, numeric_cols, categorical_cols)

fig, ax = plt.subplots(1,1,figsize=(8,6))
ax.hist(real_dcr,bins=300,label = 'Real vs. real', color='mediumpurple');
ax.hist(syn_dcr,bins=300,label='Synthetic vs. real', color='mediumturquoise');
ax.tick_params(axis='both', which='major', labelsize=14)
ax.set_title('Distances to closest record',fontsize=22)
ax.legend(fontsize=16);

Metadata

Release files for tonic-reporting 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tonic-reporting 1.5.0
File Size Uploaded
tonic_reporting-1.5.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tonic-reporting 1.5.0
File Interpreter ABI Platform
tonic_reporting-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.9 kB

Release files / tonic_reporting-1.5.0.tar.gz

Download URL tonic_reporting-1.5.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d4cceba407ddd4fac3ea5a97fb0467cbbe9df8b4bf19f97d15811165cd4b144f
BLAKE2b-256 checksum
How to use checksums
5dabc3bced69de1019f38201a6fe2a6ce096001f470391e3a717fc51948d3f25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/21.6.0

Release files / tonic_reporting-1.5.0-py3-none-any.whl

Download URL tonic_reporting-1.5.0-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
588579a4b761af97a5e7acb811a4a962b2adfbd2ccdeed946a1c0e755105d955
BLAKE2b-256 checksum
How to use checksums
dad704ad17652efcf0c4e5f2ed82d16ab321703ef447b1c9cf6444912ac20368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.10.9 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page