Skip to main content

Synthpop-py

synthpop-py is a Python package for generating synthetic tabular data using sequential modelling methods. It is based on the established synthpop R package, but provides a modern python interface and software architecture specifically designed for usability, reproducibility, maintainability and extensibility.

Synthetic data can help researchers, data scientist, statisticians and organisations work with realistic datasets when access to original or sensitive data is restricted. synthpop-py learns statistical relationships from an original dataset and uses these relationships to generate new synthetic observations. Properly synthesised data does not have any row-to-row relationships to the original data. As such, it may be considered non-personal data in the concept of privacy laws such as the GDPR.

However, synthetic data does not automatically eliminate privacy risks. Sensitive information or distinctive patterns from the original data may still be reproduced or inferred from synthetic data. Users should therefore always carefully consider the characteristics and sensitivity of the original data, the synthesis methods, the settings used, and the intended use and sharing context of the synthetic data.

Project status: synthpop-py is currently under active development and the project is working towards its 1.0.0 release

Quick start

The following example demonstrates the basic synthpop-py workflow:

import pandas as pd
from synthpop import Synthesiser

# Load original data
orig_df = pd.read_csv("path/to/your/data.csv")

# Create and fit the synthesiser
synth = Synthesiser(random_seed=42)
synth.fit(orig_df)

# Generate synthetic data
syn_df = synth.generate()

The original data should always be provided as a pandas.DataFrame. The Synthesiser learns the data patterns using a synthesis model when fit() is called, after which generate() creates a new synthetic dataset. It is possible to generate a dataset with a different number of observations than the original data.

For a complete introduction to preparing data, configuring synthesis, generating synthetic datasets, and evaluating the results, see the Getting Started guide.

Installation

Requirements

synthpop-py requires:

  • Python 3.13 or later
  • pandas 3.0.2 or later
  • scikit-learn 1.8.0 or later
  • plotly 6.5.2 or later

The runtime dependencies are installed when installing synthpop-py from PyPI

Install from PyPi

The recommended installation method is through PyPI:

pip install synthpop-py

You can verify the installation by importing the package:

import synthpop

For installation in a virtual environment, installation from source, and troubleshooting, see the Installation documentation.

Documentation

The full documentation is available on Read the Docs.

It includes:

  • Getting Started — an introduction to generating synthetic data with synthpop-py.
  • User Guide — detailed guidance on data preparation, synthetic data generation, synthesis methods, and evaluation.
  • Examples - detailed examples on creating a synthesis, evaluating the data, adjusting parameters and creating custom synthesis methods.
  • API Reference — documentation of the Python API.
  • Developer documentation — information about the project architecture, development workflow, and contributing to the package.

Supported data and synthesis methods

synthpop-py is designed for structured tabular datasets. It currently supports:

  • numeric variables;
  • categorical variables;
  • boolean variables;
  • ordinal variables; and
  • missing values.

The package is not currently designed for unstructured data such as free text, images, audio, or time-series data.

Synthesis methods

synthpop-py currently provides the following synthesis methods:

  • CART — A Classification and Regression Trees method, the default sequential modelling method;
  • Sampling — a sampling-based synthesis method; and
  • Copying — a copying-based method.

The package is designed with extensibility in mind. Additional synthesis methods can be developed and integrated through the package's architecture, allowing users and contributors to extend the available synthesis functionality.

See the User Guide for detailed information about synthesis methods and their configuration.

Evaluating synthetic data

Synthetic data should be evaluated before it is used or shared. In particular, users should consider both utility and privacy.

Utility describes how well the synthetic data preserves the statistical properties and relationships that are relevant to the intended use. synthpop-py provides functionality for evaluating synthetic data utility.

Privacy concerns the extent to which information about individuals in the original data could be inferred from the synthetic data. Synthetic data can reduce the need to share sensitive original data, but generating synthetic data does not automatically guarantee privacy or anonymity.

Privacy evaluation functionality is planned for future development. Until then, users should independently assess the privacy risks associated with their datasets, synthesis settings, and intended use.

For more information about synthetic data evaluation, see the documentation.

Relationship to the synthpop R package

synthpop-py is based on the core concepts of the established synthpop R package, which provides a widely used framework for generating synthetic tabular data through sequential modelling.

The sequential modelling approach synthesises variables one at a time, using previously synthesised variables as predictors for subsequent variables. This allows statistical relationships between variables in the original data to be incorporated into the generated synthetic data.

synthpop-py brings this approach to the Python ecosystem through a native Python interface and a modular software architecture designed to support usability, testing, reproducibility, maintainability, and future extension.

The two packages are related but are not currently feature-equivalent. The original R package provides a broader collection of synthesis methods and evaluation functionality, while synthpop-py currently focuses on a smaller set of synthesis methods with an emphasis on providing a robust and extensible Python implementation.

The development of synthpop-py has been undertaken with approval from, and in cooperation with, the authors of the original synthpop R package.

For background on the methodology and the use of synthpop, see the references below.

Limitations and responsible use

Synthetic data should not automatically be considered anonymous or free from privacy risks.

The privacy and utility of a synthetic dataset depend on factors including:

  • the characteristics of the original dataset;
  • the synthesis methods and configuration used;
  • the variables included in the data; and
  • the intended use and sharing context.

Users are responsible for evaluating whether generated synthetic data is suitable for their intended purpose and whether it meets applicable privacy, security, legal, and regulatory requirements.

In particular, synthpop-py does not currently provide formal privacy guarantees such as differential privacy. Users should therefore not assume that the use of synthetic data alone guarantees that individuals in the original data cannot be identified or that sensitive information cannot be inferred.

Synthetic data should also be evaluated for utility. A synthetic dataset that provides strong privacy protection may not preserve the statistical characteristics required for a particular analysis, while a highly useful synthetic dataset may retain patterns that increase disclosure risk.

Project status and roadmap

synthpop-py is currently under active development, with the project working towards its 1.0.0 release.

The initial release focuses on providing a robust Python implementation of the core sequential modelling approach, with an emphasis on:

  • usability;
  • reproducibility;
  • maintainability;
  • extensibility; and
  • integration with the Python data science ecosystem.

Future development may include:

  • additional synthesis methods;
  • privacy evaluation functionality; and
  • performance and scalability improvements.

The project roadmap will continue to evolve based on user feedback and the needs of the synthetic data community.

Contributing

synthpop-py is intended to be an open-source project, and contributions are welcome.

For information about contributing to the project, setting up a development environment, and the development workflow, see the project's CONTRIBUTING.md and the developer documentation.

License

synthpop-py is licensed under the European Union Public Licence (EUPL), version 1.2.

See the LICENSE file for the full licence text.

Acknowledgements

synthpop-py is currently developed by a team of employees of the Dutch Ministry of Education, Culture and Science. The project is intended to be developed and maintained as open-source software.

The project builds on the methodology and ideas of the original synthpop R package and is developed with approval from, and in cooperation with, its original authors.

References

For background on the utility and application of synthetic data and the synthpop methodology, see:

Metadata

Release files for synthpop-py 0.1.3

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

Source distribution (sdist)

Source distribution for synthpop-py 0.1.3
File Size Uploaded Provenance
synthpop_py-0.1.3.tar.gz 45.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for synthpop-py 0.1.3
File Interpreter ABI Platform
synthpop_py-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 99.4 kB

Release files / synthpop_py-0.1.3.tar.gz

Download URL synthpop_py-0.1.3.tar.gz
Size 45.3 kB
Tags Source
SHA-256 checksum
How to use checksums
03beb5188bba6395c53bbef96dc1dae04271f13e87520a85975805478fa8e9ce
BLAKE2b-256 checksum
How to use checksums
553447ce02148f6120750a028c8baa3f3b94d654f994bd7fc4ae1c6b6e433ccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.13.5 Windows/11

Release files / synthpop_py-0.1.3-py3-none-any.whl

Download URL synthpop_py-0.1.3-py3-none-any.whl
Size 54.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce0ecba7519b269aa505f2328db2648a623ec3ef5051d78fab1d42c056c706db
BLAKE2b-256 checksum
How to use checksums
dfc2f9c55a5077490c1fa92ecd80093b5e5b1d6439d7721117c15e0d3f45bed1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.13.5 Windows/11

Security for synthpop-py 0.1.3

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.

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