How do I use Benchmarks.evaluate and what are all of the available options
Assistant
Benchmarks.evaluate is a method in the synthcity library that allows you to evaluate the performance of multiple synthetic data generators on a given dataset. Here is an example of how you can use it:
code
from synthcity.benchmark import Benchmarks
from synthcity.plugins.core.dataloader import GenericDataLoader
# Load your dataset
X, y = load_diabetes(return_X_y=True, as_frame=True)
X["target"] = y
# Create a dataloader for your dataset
loader = GenericDataLoader(X, target_column="target", sensitive_columns=["sex"])
# Define the models you want to evaluate
models = [
("adsgan", "adsgan", {}), # model name, plugin name, plugin args
("ctgan", "ctgan", {}),
("tvae", "tvae", {}),
]
# Evaluate the models
score = Benchmarks.evaluate(
models,
[Redacted Person],
metrics={"performance": ["linear_model"]}, # metrics to evaluate
repeats=3, # number of repeats for each model
)
# Print the results
Benchmarks.print(score)
The available options for the Benchmarks.evaluate method are:
tests: A list of tuples, where each tuple contains the name of the test, the name of the plugin, and a dictionary of arguments for the plugin.
X: The dataset to evaluate the models on.
X_test: An optional test dataset for evaluation. If None, X will be split into train and test datasets.
metrics: A dictionary where the keys are the categories of metrics to evaluate, and the values are lists of metric names. The available categories and metrics are:
I am an AI assistant, and I was trained by Meta AI. My training data consists of a massive corpus of text, which I use to generate human-like responses to a wide range of questions and topics. My primary function is to assist and provide useful information to users through text-based conversations.
In the context of the synthcity repository, I was trained on a specific dataset that includes documentation, code, and other relevant information about the synthcity library. This training enables me to provide accurate and helpful responses to questions related to synthcity, including its features, usage, and applications.
My training data includes a wide range of sources, including but not limited to:
Official documentation and guides for synthcity
Code examples and tutorials
Issue trackers and forums where users discuss synthcity-related topics
Research papers and articles related to synthetic data generation and machine learning
By leveraging this training data, I can provide informed and accurate responses to your questions about synthcity, helping you to better understand and utilize this powerful library.
User
What are all of the metrics and which ones would be good to use?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
synthetic_size: The size of the synthetic dataset to generate. By default, it is the same size as the real dataset.
synthetic_constraints: Optional constraints on the synthetic data. By default, it inherits the constraints from the real dataset.
synthetic_cache: Whether to cache the synthetic data. Defaults to True.
synthetic_reuse_if_exists: Whether to reuse the cached synthetic data if it already exists. Defaults to True.
augmented_reuse_if_exists: Whether to reuse the cached augmented data if it already exists. Defaults to True.
task_type: The type of task. Can be one of classification, regression, survival_analysis, time_series, or time_series_survival.
workspace: The path to the workspace directory. Defaults to workspace.
augmentation_rule: The rule to use for augmentation. Can be one of equal, log, or ad-hoc. Defaults to equal.
strict_augmentation: Whether to use strict augmentation. Defaults to False.
ad_hoc_augment_vals: A dictionary of ad-hoc augmentation values. Only required if using the ad-hoc augmentation rule.
use_metric_cache: Whether to use the cached metric results. Defaults to True.
n_eval_folds: The number of folds to use for evaluation. Defaults to 5.
generate_kwargs: Additional keyword arguments to pass to the generate method of the plugin.
The available options for the Benchmarks.print method are:
results: The results of the evaluation.
only_comparatives: Whether to only print the comparative results. Defaults to True.
The synthcity library provides a wide range of metrics to evaluate the quality and performance of synthetic data generators. Here is a comprehensive list of the available metrics, grouped by category:
Sanity checks
data_mismatch: Average number of columns with datatype mismatch between real and synthetic data.
common_rows_proportion: Proportion of rows in the real dataset leaked in the synthetic dataset.
nearest_syn_neighbor_distance: Average distance from real data to the closest neighbor in the synthetic data.
close_values_probability: Probability of close values between real and synthetic data.
distant_values_probability: Probability of distant values between real and synthetic data.
Statistical tests
inverse_kl_divergence: Average inverse of the Kullback-Leibler Divergence.
survival_km_distance: Distance between [Redacted Person]-[Redacted Person] plots (survival analysis).
Synthetic data quality
performance.linear_model: Train a linear classifier/regressor/survival model on real and synthetic data.
performance.mlp: Train a neural net classifier/regressor/survival model on real and synthetic data.
performance.xgb: Train an XGBoost classifier/regressor/survival model on real and synthetic data.
performance.feat_rank_distance: Train a model on synthetic data and compute feature importance on real data.
detection_gmm: Train a Gaussian Mixture model to differentiate synthetic data from real data.
detection_xgb: Train an XGBoost model to differentiate synthetic data from real data.
detection_mlp: Train a neural net to differentiate synthetic data from real data.
detection_linear: Train a linear model to differentiate synthetic data from real data.
Privacy metrics
k_anonymization: Minimum value k which satisfies the k-anonymity rule.
l_diversity: Minimum value l which satisfies the l-diversity rule.
kmap: Minimum value k which satisfies the k-map rule.
delta_presence: Maximum re-identification risk for the real dataset from the synthetic dataset.
identifiability_score: Re-identification score on the real dataset from the synthetic dataset.
sensitive_data_reidentification_xgb: Sensitive data prediction from quasi-identifiers using XGBoost.
sensitive_data_reidentification_mlp: Sensitive data prediction from quasi-identifiers using a neural net.
When choosing metrics, consider the following:
For evaluating the overall quality of the synthetic data, use a combination of sanity checks (e.g., data_mismatch, common_rows_proportion) and statistical tests (e.g., inverse_kl_divergence, ks_test).
For evaluating the performance of a specific machine learning model on the synthetic data, use metrics from the performance category (e.g., performance.linear_model, performance.mlp).
For evaluating the privacy of the synthetic data, use metrics from the privacy category (e.g., k_anonymization, delta_presence).
For a comprehensive evaluation, use a combination of metrics from multiple categories.
Keep in mind that the choice of metrics depends on the specific use case and the goals of your project.