Apply to speak at TensorFlow World. Deadline April 23rd. Propose talk

tfdv.set_domain

tfdv.set_domain(
    schema,
    feature_name,
    domain
)

Sets the domain for the input feature in the schema.

If the input feature already has a domain, it is overwritten with the newly provided input domain. This method cannot be used to add a new global domain.

Args:

  • schema: A Schema protocol buffer.
  • feature_name: The name of the feature whose domain needs to be set.
  • domain: A domain protocol buffer (one of IntDomain, FloatDomain, StringDomain or BoolDomain) or the name of a global string domain present in the input schema.

Example:

  >>> from tensorflow_metadata.proto.v0 import schema_pb2
  >>> import tensorflow_data_validation as tfdv
  >>> schema = schema_pb2.Schema()
  >>> schema.feature.add(name='feature')
  # Setting a int domain.
  >>> int_domain = schema_pb2.IntDomain(min=3, max=5)
  >>> tfdv.set_domain(schema, "feature", int_domain)
  # Setting a string domain.
  >>> str_domain = schema_pb2.StringDomain(value=['one', 'two', 'three'])
  >>> tfdv.set_domain(schema, "feature", str_domain)

Raises:

  • TypeError: If the input schema or the domain is not of the expected type.
  • ValueError: If an invalid global string domain is provided as input.