def _validate_schema(feature_columns, cat_names, cont_names, schema=None): _uses_feature_columns = feature_columns is not None _uses_explicit_schema = (cat_names is not None) or (cont_names is not None) cat_tag_names = schema.select_by_tag([Tags.CATEGORICAL ]).column_names if schema else [] cont_tag_names = schema.select_by_tag([Tags.CONTINUOUS ]).column_names if schema else [] _uses_dataset_schema = cat_tag_names or cont_tag_names if _uses_feature_columns and _uses_explicit_schema: raise ValueError( "Passed `feature_column`s and explicit column names, must be one or the other" ) elif _uses_feature_columns: return get_dataset_schema_from_feature_columns(feature_columns) elif _uses_explicit_schema: cat_names = cat_names or [] cont_names = cont_names or [] return cat_names, cont_names elif _uses_dataset_schema: cat_tag_names = cat_tag_names or [] cont_tag_names = cont_tag_names or [] return cat_tag_names, cont_tag_names else: raise ValueError( "Must either pass a list of TensorFlow `feature_column`s " "or explicit `cat_name` and `cont_name` column name lists.")
def _validate_schema(feature_columns, cat_names, cont_names): _uses_feature_columns = feature_columns is not None _uses_explicit_schema = (cat_names is not None) or (cont_names is not None) if _uses_feature_columns and _uses_explicit_schema: raise ValueError( "Passed `feature_column`s and explicit column names, must be one or the other" ) elif _uses_feature_columns: return get_dataset_schema_from_feature_columns(feature_columns) elif _uses_explicit_schema: cat_names = cat_names or [] cont_names = cont_names or [] return cat_names, cont_names else: raise ValueError( "Must either pass a list of TensorFlow `feature_column`s " "or explicit `cat_name` and `cont_name` column name lists.")