# How do you handle multiple categorical values in a single column for wide_deep model in tensorflow?

To start, let me just say that I am very new to tensorflow and Machine Learning in general. But, as part of my learning project I am trying to adapt the tensorflow wide and deep model to generate movie recommendations. However, the part I'm getting stuck on is handling multiple values for a categorical column. Below is a sample of how a couple of rows in my CSV look like.

    ID,Genres,Tags,Rating,Recommendations
----------------------------------------
1,genre1:genre2:genre3,tag1:tag3,4.3,44
2,genre2:genre3,tag1:tag5,3.7,22


The Genres and Tags column have multiple categorical values. I have looked at tf.string_split to parse the strings and return a SparseTensor.

Once I have parsed my delimited string values into SparseTensor, what do I do with? If I want to create categorical_column_with_vocabulary_file, how does the SparseTensor interact with it? Is that even the correct step? Should the SparseTensor be converted into a something before I can create a categorical_column_*?

I am just not sure how to train the Wide and Deep model when you have multiple categorical values for a single column. Some people have suggested that I use each 'Genre' as its own column and encode it using One-Hot, but it is not realistic for me to do this, because there could be 100s of genres and tags in the data.

Any help on this matter would be welcome. Thank you!!

• I ended up using the following way to read them into tensorflow: df_dataset = read_csv(file=input_file) df_dataset = df_dataset.fillna(value='') And then for my Categorical for col in _CATEGORICAL_COLUMNS: df_dataset[col] = df_dataset[col].str.split(pat=':').astype('|S') From there I just used categorical_column_with_vocabulary_file – Ruchir Doshi Jul 31 '18 at 17:27