0
$\begingroup$

Is there a way to encode categorical nominal (no ordered) data to be used in CNN models?

Let's say I need to create a 1D CNN model for categorization of time series but the values are not measurements, but categories like for example colors:

  1. red, red, blue, green, blue, red, green
  2. blue, red, green, green, red, red, green
  3. green, blue, green, red, red, blue, red and so on (can be 2D array of colors input as well)

It seems to me it would be hard to one-hot encode it. On the other hand If I change colors into integers like: 1-red, 2-green, 3-blue, then wouldn't convolutional layers assume these are ordinal or discrete data and proceed as such?

$\endgroup$
1
  • $\begingroup$ This sounds like processing sentences where the words (categories) are in some order. It’s up for debate if a convolutional architecture would be preferred to a recurrent architecture (maybe a combination), but is absolutely can be done. Brandon Rohrer discusses this around 23:00, and that approach seems perfectly reasonable for your task, if you’re determined to use a convolutional architecture. $\endgroup$
    – Dave
    Commented Oct 21, 2022 at 16:14

1 Answer 1

0
$\begingroup$

This is just my opinion, but I don't think that what you are proposing can be done on categorical data, nor do I think you can meaningfully encode categorical data so that it can be a substrate for 1D CNNs. In a 1D CNN, a 1D kernel (a vector of numbers) would slide over your 1D dataset and carry out numerical operations on that dataset. This cannot be done with categories (one-hot encoded or not).

This article has a very good and simple explanation of how 1D CNNs work: Understanding 1D and 3D Convolution Neural Network | Keras.

The Kaggle exercise in the Computer Vision course also provides valuable information (see Lesson 4, Exercise)

$\endgroup$
2
  • 1
    $\begingroup$ Isn't 1D convolution commonly used in NLP tasks, where inputs are for example words (so they are categorical)? $\endgroup$
    – NikoNyrh
    Commented Nov 20, 2022 at 20:43
  • $\begingroup$ @NikoNyrh, you might be right. This article and this article seem to thinks so. I think this is a good question and deserves an answer from someone more knowledgeable than I am. $\endgroup$ Commented Nov 20, 2022 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .