当前位置: 首页>>代码示例>>Python>>正文


Python schema_pb2.Schema方法代码示例

本文整理汇总了Python中tensorflow_metadata.proto.v0.schema_pb2.Schema方法的典型用法代码示例。如果您正苦于以下问题:Python schema_pb2.Schema方法的具体用法?Python schema_pb2.Schema怎么用?Python schema_pb2.Schema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow_metadata.proto.v0.schema_pb2的用法示例。


在下文中一共展示了schema_pb2.Schema方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_validate_stats_invalid_environment

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_validate_stats_invalid_environment(self):
    statistics = statistics_pb2.DatasetFeatureStatisticsList()
    statistics.datasets.extend([statistics_pb2.DatasetFeatureStatistics()])
    schema = text_format.Parse(
        """
        default_environment: "TRAINING"
        default_environment: "SERVING"
        feature {
          name: "label"
          not_in_environment: "SERVING"
          value_count { min: 1 max: 1 }
          presence { min_count: 1 }
          type: BYTES
        }
        """, schema_pb2.Schema())
    with self.assertRaisesRegexp(
        ValueError, 'Environment.*not found in the schema.*'):
      _ = validation_api.validate_statistics(statistics, schema,
                                             environment='INVALID') 
开发者ID:tensorflow,项目名称:data-validation,代码行数:21,代码来源:validation_api_test.py

示例2: test_get_feature_using_path

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_get_feature_using_path(self):
    schema = text_format.Parse(
        """
        feature {
          name: "feature1"
          type: STRUCT
          struct_domain {
            feature {
              name: "sub_feature1"
            }
          }
        }
        """, schema_pb2.Schema())
    sub_feature1 = schema_util.get_feature(
        schema, types.FeaturePath(['feature1', 'sub_feature1']))
    self.assertIs(sub_feature1, schema.feature[0].struct_domain.feature[0]) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:18,代码来源:schema_util_test.py

示例3: test_get_string_domain_schema_level_domain

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_get_string_domain_schema_level_domain(self):
    schema = text_format.Parse(
        """
        string_domain {
          name: "domain1"
        }
        string_domain {
          name: "domain2"
        }
        feature {
          name: "feature1"
          domain: "domain2"
        }
        """, schema_pb2.Schema())

    domain2 = schema_util.get_domain(schema, 'feature1')
    self.assertIsInstance(domain2, schema_pb2.StringDomain)
    self.assertEqual(domain2.name, 'domain2')
    # Check to verify that we are operating on the same domain object.
    self.assertIs(domain2, schema_util.get_domain(schema, 'feature1')) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:22,代码来源:schema_util_test.py

示例4: test_get_string_domain_feature_level_domain

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_get_string_domain_feature_level_domain(self):
    schema = text_format.Parse(
        """
        string_domain {
          name: "domain2"
        }
        feature {
          name: "feature1"
          string_domain {
            name: "domain1"
          }
        }
        """, schema_pb2.Schema())

    domain1 = schema_util.get_domain(schema, 'feature1')
    self.assertIsInstance(domain1, schema_pb2.StringDomain)
    self.assertEqual(domain1.name, 'domain1')
    # Check to verify that we are operating on the same domain object.
    self.assertIs(domain1, schema_util.get_domain(schema, 'feature1')) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:21,代码来源:schema_util_test.py

示例5: test_get_int_domain_feature_level_domain

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_get_int_domain_feature_level_domain(self):
    schema = text_format.Parse(
        """
        feature {
          name: "feature1"
          int_domain {
            name: "domain1"
          }
        }
        """, schema_pb2.Schema())

    domain1 = schema_util.get_domain(schema, 'feature1')
    self.assertIsInstance(domain1, schema_pb2.IntDomain)
    self.assertEqual(domain1.name, 'domain1')
    # Check to verify that we are operating on the same domain object.
    self.assertIs(domain1, schema_util.get_domain(schema, 'feature1')) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:18,代码来源:schema_util_test.py

示例6: test_get_bool_domain_feature_level_domain

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_get_bool_domain_feature_level_domain(self):
    schema = text_format.Parse(
        """
        feature {
          name: "feature1"
          bool_domain {
            name: "domain1"
          }
        }
        """, schema_pb2.Schema())

    domain1 = schema_util.get_domain(schema, 'feature1')
    self.assertIsInstance(domain1, schema_pb2.BoolDomain)
    self.assertEqual(domain1.name, 'domain1')
    # Check to verify that we are operating on the same domain object.
    self.assertIs(domain1, schema_util.get_domain(schema, 'feature1')) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:18,代码来源:schema_util_test.py

示例7: test_get_domain_using_path

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_get_domain_using_path(self):
    schema = text_format.Parse(
        """
        feature {
          name: "feature1"
          type: STRUCT
          struct_domain {
            feature {
              name: "sub_feature1"
              bool_domain {
                name: "domain1"
              }
            }
          }
        }
        """, schema_pb2.Schema())
    domain1 = schema_util.get_domain(
        schema, types.FeaturePath(['feature1', 'sub_feature1']))
    self.assertIs(
        domain1, schema.feature[0].struct_domain.feature[0].bool_domain) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:22,代码来源:schema_util_test.py

示例8: write_schema_text

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def write_schema_text(schema: schema_pb2.Schema, output_path: Text) -> None:
  """Writes input schema to a file in text format.

  Args:
    schema: A Schema protocol buffer.
    output_path: File path to write the input schema.

  Raises:
    TypeError: If the input schema is not of the expected type.
  """
  if not isinstance(schema, schema_pb2.Schema):
    raise TypeError('schema is of type %s, should be a Schema proto.' %
                    type(schema).__name__)

  schema_text = text_format.MessageToString(schema)
  io_util.write_string_to_file(output_path, schema_text) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:18,代码来源:schema_util.py

示例9: get_all_leaf_features

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def get_all_leaf_features(
    schema: schema_pb2.Schema
) -> List[Tuple[types.FeaturePath, schema_pb2.Feature]]:
  """Returns all leaf features in a schema."""
  def _recursion_helper(
      parent_path: types.FeaturePath,
      feature_container: Iterable[schema_pb2.Feature],
      result: List[Tuple[types.FeaturePath, schema_pb2.Feature]]):
    for f in feature_container:
      feature_path = parent_path.child(f.name)
      if f.type != schema_pb2.STRUCT:
        result.append((feature_path, f))
      else:
        _recursion_helper(feature_path, f.struct_domain.feature, result)

  result = []
  _recursion_helper(types.FeaturePath([]), schema.feature, result)
  return result 
开发者ID:tensorflow,项目名称:data-validation,代码行数:20,代码来源:schema_util.py

示例10: from_json

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def from_json(cls, options_json: Text) -> 'StatsOptions':
    """Construct an instance of stats options from a JSON representation.

    Args:
      options_json: A JSON representation of the __dict__ attribute of a
        StatsOptions instance.

    Returns:
      A StatsOptions instance constructed by setting the __dict__ attribute to
      the deserialized value of options_json.
    """
    options_dict = json.loads(options_json)
    if 'schema_json' in options_dict:
      options_dict['_schema'] = json_format.Parse(options_dict['schema_json'],
                                                  schema_pb2.Schema())
      del options_dict['schema_json']
    options = cls()
    options.__dict__ = options_dict
    return options 
开发者ID:tensorflow,项目名称:data-validation,代码行数:21,代码来源:stats_options.py

示例11: _schema_has_sparse_features

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def _schema_has_sparse_features(schema: schema_pb2.Schema) -> bool:
  """Returns whether there are any sparse features in the specified schema."""

  def _has_sparse_features(
      feature_container: Iterable[schema_pb2.Feature]
  ) -> bool:
    """Helper function used to determine whether there are sparse features."""
    for f in feature_container:
      if isinstance(f, schema_pb2.SparseFeature):
        return True
      if f.type == schema_pb2.STRUCT:
        if f.struct_domain.sparse_feature:
          return True
        return _has_sparse_features(f.struct_domain.feature)
    return False

  if schema.sparse_feature:
    return True
  return _has_sparse_features(schema.feature) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:21,代码来源:stats_impl.py

示例12: __init__

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def __init__(self,
               schema: schema_pb2.Schema,
               name: Text = 'WeightedFeatureStatsGenerator') -> None:
    constituents = []
    for weighted_feature in schema.weighted_feature:
      weight = types.FeaturePath.from_proto(weighted_feature.weight_feature)
      value = types.FeaturePath.from_proto(weighted_feature.feature)
      component_paths = [weight, value]
      constituents.append(length_diff_generator.LengthDiffGenerator(
          weight, value, required_paths=component_paths))
      constituents.append(count_missing_generator.CountMissingGenerator(
          value, required_paths=component_paths))
      constituents.append(count_missing_generator.CountMissingGenerator(
          weight, required_paths=component_paths))
    super(WeightedFeatureStatsGenerator, self).__init__(name, constituents,
                                                        schema) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:18,代码来源:weighted_feature_stats_generator.py

示例13: _get_all_sparse_features

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def _get_all_sparse_features(
    schema: schema_pb2.Schema
) -> List[Tuple[types.FeaturePath, schema_pb2.SparseFeature]]:
  """Returns all sparse features in a schema."""

  def _recursion_helper(
      parent_path: types.FeaturePath, container: Union[schema_pb2.Schema,
                                                       schema_pb2.StructDomain]
  ) -> List[Tuple[types.FeaturePath, schema_pb2.SparseFeature]]:
    """Helper function that is used in finding sparse features in a tree."""
    result = []
    for sf in container.sparse_feature:
      # Sparse features do not have a struct_domain, so they cannot be parent
      # features. Thus, once this reaches a sparse feature, add it to the
      # result.
      result.append((parent_path.child(sf.name), sf))
    for f in container.feature:
      if f.type == schema_pb2.STRUCT:
        result.extend(
            _recursion_helper(parent_path.child(f.name), f.struct_domain))
    return result

  return _recursion_helper(types.FeaturePath([]), schema) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:25,代码来源:sparse_feature_stats_generator.py

示例14: __init__

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def __init__(self,
               y_path: types.FeaturePath,
               schema: Optional[schema_pb2.Schema] = None,
               x_paths: Optional[Iterable[types.FeaturePath]] = None,
               y_boundaries: Optional[Sequence[float]] = None,
               min_x_count: int = 0,
               top_k_per_y: Optional[int] = None,
               bottom_k_per_y: Optional[int] = None,
               weight_column_name: Optional[Text] = None,
               output_custom_stats: Optional[bool] = False,
               name: Text = 'LiftStatsGenerator') -> None:
    super(LiftStatsGenerator, self).__init__(
        name,
        ptransform=_UnweightedAndWeightedLiftStatsGenerator(
            weight_column_name=weight_column_name,
            schema=schema,
            y_path=y_path,
            x_paths=x_paths,
            y_boundaries=y_boundaries,
            min_x_count=min_x_count,
            top_k_per_y=top_k_per_y,
            bottom_k_per_y=bottom_k_per_y,
            output_custom_stats=output_custom_stats,
            name=name),
        schema=schema) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:27,代码来源:lift_stats_generator.py

示例15: test_lift_string_y_with_boundaries

# 需要导入模块: from tensorflow_metadata.proto.v0 import schema_pb2 [as 别名]
# 或者: from tensorflow_metadata.proto.v0.schema_pb2 import Schema [as 别名]
def test_lift_string_y_with_boundaries(self):
    schema = text_format.Parse(
        """
        feature {
          name: 'categorical_x'
          type: BYTES
        }
        feature {
          name: 'string_y'
          type: BYTES
        }
        """, schema_pb2.Schema())
    with self.assertRaisesRegex(ValueError,
                                r'Boundaries cannot be applied to a '
                                'categorical y_path.*'):
      lift_stats_generator.LiftStatsGenerator(
          schema=schema,
          y_path=types.FeaturePath(['string_y']),
          y_boundaries=[1, 2, 3]) 
开发者ID:tensorflow,项目名称:data-validation,代码行数:21,代码来源:lift_stats_generator_test.py


注:本文中的tensorflow_metadata.proto.v0.schema_pb2.Schema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。