1
$\begingroup$

I currently have eight features which are either categorical or continuous variables. My targets are many (~1000) binary variables. So far I have attempted skmultilearn and sklearn.multioutput. I would like some help on developing a tensorflow model, or if its even possible. Any guidance is appreciated.

$\endgroup$
1
  • $\begingroup$ Hi @FoolsGold1997, welcome to the site. If you find the answers to your question useful, please consider upvoting them. Also, please consider accepting one (with the tick mark ✓ next to it) if you consider it correct or, alternatively, please describe in a comment why you consider it incorrect or not clear enough. $\endgroup$
    – noe
    Nov 22, 2023 at 9:53

1 Answer 1

1
$\begingroup$

The term you would use for that is "multilabel classification".

It is certainly possible to do so in Tensorflow, although I would say it is more frequent to see it in examples of image classification rather than tabular data.

They key to this kind of task is that the final unnormalized log-probabilities (logits) go through a sigmoid layer, and then the binary cross-entropy is used as loss function.

Here you can find a complete example.

As a side note, when implementing it, you can compute both the sigmoid and the loss together with tf.nn.sigmoid_cross_entropy_with_logits.

$\endgroup$
2
  • $\begingroup$ Thanks @noe! I will try this ASAP. Your example is focused on classification of images. Are there any major differences in the way the model is setup when features are more typical, like numerical or strings? $\endgroup$ Nov 22, 2023 at 17:40
  • $\begingroup$ While the last layers are typically Dense for any model, the initial layers vary wildly between networks meant for different kinds of data. For tabular data, you will normally find dense layers from beginning to end (with appropriate activation functions), while for text you would normally find LSTM or self-attention layers. $\endgroup$
    – noe
    Nov 22, 2023 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.