tf.feature_column.bucketized_column
| Просмотреть исходный код на GitHub |
Представляет дискретизированный плотный ввод.
tf.feature_column.bucketized_column(
source_column, boundaries
)
Ведра включают левую границу и исключают правую границу. Иными словами, boundaries=[0., 1., 2.] генерирует ведра (-inf, 0.), [0., 1.), [1., 2.), и [2., +inf).
Например, если входные данные
boundaries = [0, 10, 100]
input tensor = [[-5, 10000]
[150, 10]
[5, 100]]
то выходными данными будут
output = [[0, 3]
[3, 2]
[1, 3]]
Пример:
price = numeric_column('price')
bucketized_price = bucketized_column(price, boundaries=[...])
columns = [bucketized_price, ...]
features = tf.io.parse_example(..., features=make_parse_example_spec(columns))
linear_prediction = linear_model(features, columns)
# or
columns = [bucketized_price, ...]
features = tf.io.parse_example(..., features=make_parse_example_spec(columns))
dense_tensor = input_layer(features, columns)
bucketized_column также можно перекрестить с другим категориальным столбцом с помощью crossed_column:
price = numeric_column('price')
# bucketized_column converts numerical feature to a categorical one.
bucketized_price = bucketized_column(price, boundaries=[...])
# 'keywords' is a string feature.
price_x_keywords = crossed_column([bucketized_price, 'keywords'], 50K)
columns = [price_x_keywords, ...]
features = tf.io.parse_example(..., features=make_parse_example_spec(columns))
linear_prediction = linear_model(features, columns)
| Аргументы | |
|---|---|
source_column | Одномерный плотный столбец, сгенерированный с помощью numeric_column. |
boundaries | Отсортированный список или кортеж чисел, определяющий границы. |
| Возвращаемое значение | |
|---|---|
A BucketizedColumn. |
| Исключения | |
|---|---|
ValueError | Если source_column не является числовым столбцом или не является одномерным. |
ValueError | Если boundaries не является отсортированным списком или кортежем. |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/feature_column/bucketized_column