For the complete documentation index, see llms.txt. This page is also available as Markdown.

RegexFormatAdherence

This metric captures whether the synthetic data adheres to a specific Regex format.

Data Compatibility

  • ID : This metric is meant for ID columns (like primary and foreign keys) with specific Regex formats.

This metric ignores missing values.

Score

(best) 1.0: All values in the synthetic data respect the specified Regex format

(worst) 0.0: No value in the synthetic data respects the specified Regex format

How does it work?

This metrics checks each individual value of the synthetic data column to see if it follows the Regex format that is provided. The score is the proportion of synthetic data values that match the Regex format.

Named capture groups are treated specially. In some cases, your Regex format might contain named capture group such as (?P<country>[A-Z]{2})-[0-9A-Z]{5}. This indicates a specific 2-letter code (country) followed by a random 5-character string, for example US-45PL3 or CA-10P3R.

In such cases, this metric will parse out the groups that are available in the real data and ensure that only those values appear in the synthetic data. For example if the real data contained prefixes US, CA and MX, then it will explicitly look for those named groups in the synthetic data. If the named value cannot be found in the real data, then the synthetic value would not match the Regex.

Usage

To manually apply this metric, access the single_column module and use the compute method.

Parameters

  • (required) real_data: A pandas.Series object with the column of real data

  • (required) synthetic_data: A pandas.Series object with the column of synthetic data

  • (required) regex_format: A string containing the Regex format to check against. For more information, see Python's re module.

FAQs

Does this metric use real data?

If the real data doesn't match the provided Regex, then the metric will provide a warning but it will still continue to check the synthetic data.

If the real data doesn't match the provided Regex and there is a named capture group, then the metric cannot be computed and the score is NaN.

Last updated