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

DatetimeFormatAdherence

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

Data Compatibility

  • Datetime : This metric is meant to for datetime columns that are reprsented as strings with specific datetime formatting, for example YYYY-MM-DD

This metric ignores missing values.

Score

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

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

How does it work?

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

Note that the datetime format can only be checked if the synthetic data has a string representation. If it is present as datetime64, then the format cannot be checked and the score is NaN.

Usage

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

from sdmetrics.single_column import DatetimeFormatAdherence

DatetimeFormatAdherence.compute(
    real_data=real_table['purchase_date'],
    synthetic_data=synthetic_table['purchase_date'],
    datetime_format='%Y-%m-%d'
)

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) datetime_format: A string containing the datetime format to check against. For more information, see Python's strftime module.

FAQs

Does this metric use real data?

If the real data is represented as a string and it does not match the provided datetime format, then the metric will issue a warning but it will continue to check the synthetic data.

The final score is only based on whether the synthetic data matches the format.

Last updated