Generates Parsing Spec for TensorFlow Example to be Used with Classifiers
If users keep data in TensorFlow Example format, they need to call tf$parse_example
with a proper feature spec. There are two main things that this utility
helps:
Users need to combine parsing spec of features with labels and weights (if any) since they are all parsed from same
tf$Example
instance. This utility combines these specs.It is difficult to map expected label by a classifier such as
dnn_classifier
to correspondingtf$parse_example
spec. This utility encodes it by getting related information from users (key, dtype).
classifier_parse_example_spec(feature_columns, label_key,
label_dtype = tf$int64, label_default = NULL, weight_column = NULL)
Arguments
feature_columns | An iterable containing all feature columns. All items
should be instances of classes derived from |
label_key | A string identifying the label. It means |
label_dtype | A |
label_default | used as label if label_key does not exist in given
|
weight_column | A string or a numeric column created by
|
Value
A dict mapping each feature key to a FixedLenFeature
or
VarLenFeature
value.
Raises
ValueError: If label is used in
feature_columns
.ValueError: If weight_column is used in
feature_columns
.ValueError: If any of the given
feature_columns
is not a feature column instance.ValueError: If
weight_column
is not a numeric column instance.ValueError: if label_key is
NULL
.
See also
Other parsing utilities: regressor_parse_example_spec