diff --git a/sdv/evaluation.py b/sdv/evaluation.py index 44a18bb6e..ddbbeeb2a 100644 --- a/sdv/evaluation.py +++ b/sdv/evaluation.py @@ -94,7 +94,7 @@ def _select_metrics(synthetic_data, metrics): def evaluate(synthetic_data, real_data=None, metadata=None, root_path=None, - table_name=None, metrics=None, aggregate=True): + table_name=None, metrics=None, aggregate=True, report_errors=False): """Apply multiple metrics at once. Args: @@ -117,6 +117,9 @@ def evaluate(synthetic_data, real_data=None, metadata=None, root_path=None, If ``get_report`` is ``False``, whether to compute the mean of all the normalized scores to return a single float value or return a ``dict`` containing the score that each metric obtained. Defaults to ``True``. + report_errors (bool): + If ``True``, report the metrics that errored out and their corresponding errors. + If ``False``, omit the metrics that errored out. Return: float or sdmetrics.MetricsReport @@ -133,7 +136,14 @@ def evaluate(synthetic_data, real_data=None, metadata=None, root_path=None, synthetic_data = synthetic_data[table] scores = sdmetrics.compute_metrics(metrics, real_data, synthetic_data, metadata=metadata) + + if report_errors: + errored_metrics = scores[~scores['error'].isnull()] + errored_metrics = errored_metrics[['metric', 'name', 'error']] + print(f'The following metrics errored out: \n %s', errored_metrics.to_string()) + scores.dropna(inplace=True) + scores.drop(columns=['error'], errors='ignore') if aggregate: return scores.normalized_score.mean()