I am trying to build a layer that autonomously handles the preprocessing of categorical features of type string, I started by constructing the following function:
def encodingLayer(features):lookup = tf.keras.layers.StringLookup(output_mode = "int", max_tokens = None, vocabulary = None)lookup.adapt(features)return(lookup.get_vocabulary())
and I get the following output:
encodingLayer(df)['[UNK]','food','serious','not serious','nuts, nut products and seeds','fruits and vegetables',...]
How can I integrate the tf.keras.layers.CategoryEncoding()
function at this point to get a one-hot encoding?Any suggestions?