R/feature_spec.R

step_categorical_column_with_hash_bucket

Creates a categorical column with hash buckets specification

Description

Represents sparse feature where ids are set by hashing.

Usage

 
step_categorical_column_with_hash_bucket( 
  spec, 
  ..., 
  hash_bucket_size, 
  dtype = tf$string 
) 

Arguments

Arguments Description
spec A feature specification created with feature_spec().
Comma separated list of variable names to apply the step. selectors can also be used.
hash_bucket_size An int > 1. The number of buckets.
dtype The type of features. Only string and integer types are supported.

Value

a FeatureSpec object.

Examples

library(tfdatasets) 
data(hearts) 
hearts <- tensor_slices_dataset(hearts) %>% dataset_batch(32) 
 
# use the formula interface 
spec <- feature_spec(hearts, target ~ thal) %>% 
  step_categorical_column_with_hash_bucket(thal, hash_bucket_size = 3) 
 
spec_fit <- fit(spec) 
final_dataset <- hearts %>% dataset_use_spec(spec_fit) 

See Also

steps for a complete list of allowed steps. Other Feature Spec Functions: dataset_use_spec(), feature_spec(), fit.FeatureSpec(), step_bucketized_column(), step_categorical_column_with_identity(), step_categorical_column_with_vocabulary_file(), step_categorical_column_with_vocabulary_list(), step_crossed_column(), step_embedding_column(), step_indicator_column(), step_numeric_column(), step_remove_column(), step_shared_embeddings_column(), steps