For DNN model, indicator_column can be used to wrap any
categorical_column_* (e.g., to feed to DNN). Consider to Use
embedding_column if the number of buckets/unique(values) are large.
For Wide (aka linear) model, indicator_column is the internal
representation for categorical column when passing categorical column
directly (as any element in feature_columns) to linear_model. See
linear_model for details.
name=indicator_column(categorical_column_with_vocabulary_list('name',['bob','george','wanda']))columns=[name,...]features=tf.io.parse_example(...,features=make_parse_example_spec(columns))dense_tensor=input_layer(features,columns)dense_tensor==[[1,0,0]]# If "name" bytes_list is ["bob"]dense_tensor==[[1,0,1]]# If "name" bytes_list is ["bob", "wanda"]dense_tensor==[[2,0,0]]# If "name" bytes_list is ["bob", "bob"]
Args
categorical_column
A CategoricalColumn which is created by
categorical_column_with_* or crossed_column functions.
Returns
An IndicatorColumn.
Raises
ValueError
If categorical_column is not CategoricalColumn type.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.feature_column.indicator_column\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/feature_column/feature_column_v2.py#L1519-L1561) |\n\nRepresents multi-hot representation of given categorical column. (deprecated)\n| **Warning:** tf.feature_column is not recommended for new code. Instead, feature preprocessing can be done directly using either [Keras preprocessing\n| layers](https://www.tensorflow.org/guide/migrate/migrating_feature_columns) or through the one-stop utility [`tf.keras.utils.FeatureSpace`](https://www.tensorflow.org/api_docs/python/tf/keras/utils/FeatureSpace) built on top of them. See the [migration guide](https://tensorflow.org/guide/migrate) for details.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.feature_column.indicator_column`](https://www.tensorflow.org/api_docs/python/tf/feature_column/indicator_column)\n\n\u003cbr /\u003e\n\n tf.feature_column.indicator_column(\n categorical_column\n )\n\n### Used in the notebooks\n\n| Used in the guide | Used in the tutorials |\n|--------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Migrate \\`tf.feature_column\\`s to Keras preprocessing layers](https://www.tensorflow.org/guide/migrate/migrating_feature_columns) | - [Classify structured data with feature columns](https://www.tensorflow.org/tutorials/structured_data/feature_columns) - [Build a linear model with Estimators](https://www.tensorflow.org/tutorials/estimator/linear) - [End to end example for BigQuery TensorFlow reader](https://www.tensorflow.org/io/tutorials/bigquery) - [Preprocessing data with TensorFlow Transform](https://www.tensorflow.org/tfx/tutorials/transform/census) |\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use Keras preprocessing layers instead, either directly or via the [`tf.keras.utils.FeatureSpace`](../../tf/keras/utils/FeatureSpace) utility. Each of `tf.feature_column.*` has a functional equivalent in `tf.keras.layers` for feature preprocessing when training a Keras model.\n\n- For DNN model, `indicator_column` can be used to wrap any\n `categorical_column_*` (e.g., to feed to DNN). Consider to Use\n `embedding_column` if the number of buckets/unique(values) are large.\n\n- For Wide (aka linear) model, `indicator_column` is the internal\n representation for categorical column when passing categorical column\n directly (as any element in feature_columns) to `linear_model`. See\n `linear_model` for details.\n\n name = indicator_column(categorical_column_with_vocabulary_list(\n 'name', ['bob', 'george', 'wanda']))\n columns = [name, ...]\n features = tf.io.parse_example(..., features=make_parse_example_spec(columns))\n dense_tensor = input_layer(features, columns)\n\n dense_tensor == [[1, 0, 0]] # If \"name\" bytes_list is [\"bob\"]\n dense_tensor == [[1, 0, 1]] # If \"name\" bytes_list is [\"bob\", \"wanda\"]\n dense_tensor == [[2, 0, 0]] # If \"name\" bytes_list is [\"bob\", \"bob\"]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------|------------------------------------------------------------------------------------------------------|\n| `categorical_column` | A `CategoricalColumn` which is created by `categorical_column_with_*` or `crossed_column` functions. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An `IndicatorColumn`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------------------------------|\n| `ValueError` | If `categorical_column` is not CategoricalColumn type. |\n\n\u003cbr /\u003e"]]