Multiclass Classification in Recommender system

I am trying to build a recommender system that predicts an output class which is categorical in nature. I have implemented the same for the movie ratings database where I convert the dataset into a matrix with the rows representing user id, columns representing movie ids and values are ratings.

The problem I face is useing multiclass output labels, I want to understand how can I use the matrix after one hot encoding the variables? Will I need to create two separate matrices?

For a multiclass setting you usually use nn.NLLLoss+ nn.LogSoftmax or nn.CrossEntropyLoss with logits as criteria.
Both loss functions need a target tensor containing class indices, not a one-hot encoded matrix.
Have a look at the docs for more information and an example of the usage.

Hi ptrblck,

Thanks for your response. I am fairly new to deep learning, even though I went to the documentations as suggested by you I was having trouble understanding the same. Could you point me towards a more practical implementation if possible?

Moreover, I’ll just give you the context of my dataset. I basically have 3 columns in my dataset: user_id, movie_id, and review. Review column is my target output which has 6 classes in it.

I am trying to build an autoencoder which is able to predict the output class for a movie.

I understand the criterion you mentioned and will be able to implement the same, however, much of my doubt revolves around the correct data preprocessing to achieve the same.

Looking forward to your response.

Best,
S

The simplest possible approach would be to use something like this. However the loss-function @ptrblck suggested has been used here.

I’m not sure, how to pre-process your data as it seems you just have ids as your input.
Also, do you want to use the latent vector of your autoencoder for classification?

Do you have a starter code or do you need one?

Also, just to be clear on the problem: is your use case about multi-class or multi-label classification?

I have a multiclass problem with my classes belonging to - ‘good’, ‘bad’, ‘interesting’, etc.

While researching, I came across autoencoders to be the best way to approach the same. However, I have additional data about the movies such as genre, actors, etc. Is there anyway I could include the same in my model and perhaps not implement an autoencoder but a different neural network?

What do you think would be the correct way to go about the same?

Are different labels possible for one datapoint?

To include your additional data you would have to encode it somehow. The simplest approach would be to use one-hot encoding which, however, is relatively sparse. Another approach would be to use nn.Embedding as this will not be one-hot encoded but in a dense way.

No, so 1 row corresponds to the following:
user_id, movie_id, actor, genre, date_released, total_ratings and review(output class)

1 row only has one output class which can be either (good / bad/ interesting…etc).

I am trying to investigate if it’s possible for me to predict ratings based on past behaviour. If not for autoencoders what can I implement to do this classification problem?

And are your ids fixed or are they usually changing?

In general it sounds like a problem which might be able to solve by neural networks, but intuitively, I would recommend some other methods like clustering. For clustering, however you would probably also need an embedding.

Edit: with changing I mean if they are expanding/will there be any Ids added in the future?

Ids are fixed for all the users.Do you recommend a particular type of neural networks?

Actually no. I would recommend non-deep data-driven methods like standard clustering (an overview of clustering algorithms in scikit-learn is given here) and I would probably start with K-Means or K-Nearest-Neighbor clustering.