Skip to content

Commit 3848685

Browse files
committed
Merge branch 'master' into remove-zetasql
2 parents 144bc08 + 748bb7b commit 3848685

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

g3doc/custom_data_validation.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Custom Data Validation
2+
3+
<!--*
4+
freshness: { owner: 'kuochuntsai' reviewed: '2022-11-29' }
5+
*-->
6+
7+
TFDV supports custom data validation using SQL. You can run custom data
8+
validation using
9+
[validate_statistics](https://github.com/tensorflow/data-validation/blob/master/tensorflow_data_validation/api/validation_api.py;l=236;rcl=488721853)
10+
or
11+
[custom_validate_statistics](https://github.com/tensorflow/data-validation/blob/master/tensorflow_data_validation/api/validation_api.py;l=535;rcl=488721853).
12+
Use `validate_statistics` to run standard, schema-based data validation along
13+
with custom validation. Use `custom_validate_statistics` to run only custom
14+
validation.
15+
16+
## Configuring Custom Data Validation
17+
18+
Use the
19+
[CustomValidationConfig](https://github.com/tensorflow/data-validation/blob/master/tensorflow_data_validation/anomalies/proto/custom_validation_config.proto)
20+
to define custom validations to run. For each validation, provide an
21+
SQL expression, which returns a boolean value. Each SQL expression is run
22+
against the summary statistics for the specified feature. If the expression
23+
returns false, TFDV generates a custom anomaly using the provided severity and
24+
anomaly description.
25+
26+
You may configure custom validations that run against individual features or
27+
feature pairs. For each feature, specify both the dataset (i.e., slice) and the
28+
feature path to use, though you may leave the dataset name blank if you want to
29+
validate the default slice (i.e., all examples). For single feature validations,
30+
the feature statistics are bound to `feature`. For feature pair validations, the
31+
test feature statistics are bound to `feature_test` and the base feature
32+
statistics are bound to `feature_base`. See the section below for example
33+
queries.
34+
35+
If a custom validation triggers an anomaly, TFDV will return an Anomalies proto
36+
with the reason(s) for the anomaly. Each reason will have a short description,
37+
which is user configured, and a description with the query that caused the
38+
anomaly, the dataset names on which the query was run, and the base feature path
39+
(if running a feature-pair validation). See the section below for example
40+
results of custom validation.
41+
42+
See the
43+
[documentation](https://github.com/tensorflow/data-validation/blob/master/tensorflow_data_validation/anomalies/proto/custom_validation_config.proto)
44+
in the `CustomValidationConfig` proto for example
45+
configurations.

0 commit comments

Comments
 (0)