DEV Community

Karan
Karan

Posted on

Single Label Multiclass Classification Using Keras

Hi DEVz,

It's my second post using Keras for machine learning. This time it's the next lesson in the book for Multiclass Classification. This post is pretty much like the last post, the only difference is that I've tried to put some explanation in the following diagram which I hope will make you/or me in future understand why was the data split and what is one hot encoding.😊

datasplit

What's multiclass classification?

Multiclass classification or more specifically in this case single label multiclass classification would allow you to put a sample in one category out of many, i.e. it's an extension of binary classification.

For Example: A movie can be good or bad, which is binary, however it's genre could be single label out of several genres, for example it could be: Horror out of [Thriller, Romance, Drama, Action, Adventure]

What's one hot encoding?

The diagram shows you how you represent a single label as an array whose length is the number of labels, and that my fellow devs is one hot encoding.
Each sample can lie in only ONE of the 46 categories of labels or topics to be precise.

46 Labels? How would that affect the neural networks?

Good question! This time instead of using 16 units in a hidden layer, we'll use 64 units. Why? you ask...because last time we only had 2 labels (postive or negative sentiment) however this time we have 46 topics and to NOT DROP any of that information from the 46 size array we need an even larger input stack and so we use a 64 unit layer for input and a 46 unit layer for output.

This exercise is based on classifying Reuters news feeds into labels, and for some reason I can't find the text of the label!😅

The source is here.
Enjoy!

Top comments (1)

Collapse
 
adampeake20 profile image
AdamPeake

I was complete unaware of what this platform all about Brother Printer To Wifi and what kind of services they would offer. That is why I came across this article of Aligner Therapie in Frankfurt literally helped me a lot in learning about it, thanks!