SDQCPy
SDQCPy: A Comprehensive Python Package for Synthetic Data Management
Table of Contents
Features
SDQCPy offers a comprehensive toolkit for synthetic data generation, quality assessment, and analysis:
- Data Synthesis: Generate synthetic data using various models.
- Quality Evaluation: Assess synthetic data quality through statistical tests, classification metrics, explainability analysis, and causal inference.
- End-to-End Analysis: Perform holistic analysis by integrating multiple evaluation methods to provide a comprehensive view of synthetic data quality.
- Results Display: Store the results in a HTML file.
Installation
You can install SDQCPy using pip:
pip install sdqcpy
Alternatively, you can install it from the source:
git clone https://github.com/T0217/sdqcpy.git
cd sdqcpy
pip install -e .
Results Display
SDQCPy provides a SequentialAnalysis class to perform the sequential analysis and store the results in a HTML file.
Usage
Demo
You can use the following code to achieve the sequential analysis and store the results in a HTML file:
from sdqc_integration import SequentialAnalysis
from sdqc_data import read_data
import logging
import warnings
# Ignore warnings and set logging level to ERROR
warnings.filterwarnings('ignore')
logger = logging.getLogger()
logger.setLevel(logging.ERROR)
# Set random seed
random_seed = 17
# Replace with your own data path and use pandas to read the data
raw_data = read_data('3_raw')
synthetic_data = read_data('3_synth')
output_path = 'raw_synth.html'
# Perform sequential analysis
sequential = SequentialAnalysis(
raw_data=raw_data,
synthetic_data=synthetic_data,
random_seed=random_seed,
use_cols=None,
)
results = sequential.run()
sequential.visualize_html(output_path)
Data Synthesis
SDQCPy supports various methods, the implementation of these methods are using ydata-synthetic and SDV.
[!TIP]
We only display simple code here, and the parameters of each model can be further modified as needed.
-
YData Synthesizer
import pandas as pd from sdqc_synthesize import YDataSynthesizer raw_data = pd.read_csv("raw_data.csv") # Please replace with your own data path ydata_synth = YDataSynthesizer(data=raw_data) synthetic_data = ydata_synth.generate()
[!IMPORTANT]
In the latest version,
ydata-synthetichas switched to using ydata-sdk. However, since synthetic data is only a supplementary feature of this library, it has not been updated yet.
-
SDV Synthesizer
import pandas as pd from sdqc_synthesize import SDVSynthesizer raw_data = pd.read_csv("raw_data.csv") # Please replace with your own data path sdv_synth = SDVSynthesizer(data=raw_data) synthetic_data = sdv_synth.generate()
Workflow
SDQCPy use the process shown below to perform the quality check and analysis:
---
title Main Idea
---
flowchart TB
%% Define the style
classDef default stroke:#000,fill:none
%% Define the nodes
initial([Input Real Data and Synthetic Data])
step1[Statistical Test]
step2[Classification]
step3[Explainability]
step4[Causal Analysis]
endprocess[Export HTML file]
%% Define the relationships between nodes
initial --> step1
step1 --> step2
step2 --> step3
step3 --> step4
step4 --> endprocess
- Statistical Test
SDQCPyemploys various methods for descriptive analysis, distribution comparison, and correlation testing tailored to different data types. - Classification
SDQCPyemploys machine learning models(SVC,RandomForestClassifier,XGBClassifier,LGBMClassifier) to evaluate the similarity between the real and synthetic data. - Explainability
SDQCPyemploys several of the current mainstream explainability methods(Model-Based,SHAP,PFI) to evaluate the explainability of the synthetic data. - Causal Analysis
SDQCPyemploys several causal structure learning methods and evaluation metrics to compare the adjacency matrix of the raw and synthetic data. The implementation of these methods are usinggCastle. - End-to-End Analysis(named
SequentialAnalysis) To streamline the process of calling individual modules one by one, we have integrated all the functions. If you have specific needs, you can also use these functions along your lines.
Support
Need help? Report a bug? Ideas for collaborations? Reach out via GitHub Issues
[!IMPORTANT]
Before reporting an issue on
GitHub, please check the existing Issues to avoid duplicates.If you wish to contribute to this library, please first open an Issue to discuss your proposed changes. Once discussed, you are welcome to submit a Pull Request.
License
Metadata
Release files for sdqcpy 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sdqcpy-1.0.1.tar.gz | 29.2 kB | Without provenance | Details for sdqcpy-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sdqcpy-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for sdqcpy-1.0.1-py3-none-any.whl |
Total release size: 64.3 kB
Release files / sdqcpy-1.0.1.tar.gz
| Download URL | sdqcpy-1.0.1.tar.gz |
|---|---|
| Size | 29.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4aef2958940e67b6e353b476cdb2405e0571521993daf3be400af0921fbb26b7
|
|
BLAKE2b-256 checksum How to use checksums |
1a4336373aa80af71ac1ac7f4a690d98a04caeef3c61b6c85ca5f32f4e406753
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / sdqcpy-1.0.1-py3-none-any.whl
| Download URL | sdqcpy-1.0.1-py3-none-any.whl |
|---|---|
| Size | 35.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62f334c4bcfabb105eb21def736ef7eb79b9e404b85dad3ec9ca950e271b2a0b
|
|
BLAKE2b-256 checksum How to use checksums |
a892029e50f22fe52bb23f17ea2ff88b344b25ffa5805ac252c89ebc5db8b28e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for sdqcpy 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.