I am trying to create a multiclass product-rating network based on product reviews and other input features. Two of the other input features are "product category" and "gender". However, I want to avoid unfair bias in the classification task between male/female. Since some product categories are more likely to be reviewed by males or females (hence, not balanced), I am seeking for an approach to solve this "imbalance"-like issue.

The options and things that I consider at the moment are:

  1. Downsample the training examples in each product category to balance for gender
  2. Add weights to the training examples for gender, or
  3. Add weights to the loss function (either log-likelihood or cross-entropy)

Even though downsampling might be the easiest option, I would like to explore the options of adding weights in the network in some way. However, most literature are only discussing adding weights to the loss function in order to solve for imbalanced data related to the target value (which is not the issue that I am addressing).

Can someone help me or point me in the right direction to solve this challenge?

  • $\begingroup$ Welcome to SE:AI! $\endgroup$
    – DukeZhou
    Commented Apr 14, 2020 at 22:18
  • $\begingroup$ Thank you @DukeZhou! Do you have any idea how I can solve my question? $\endgroup$
    – nvrs
    Commented Apr 15, 2020 at 4:58
  • $\begingroup$ unfortunately, I'm not the right guy to ask. (I'm sort of the itinerant philosopher on SE:AI) $\endgroup$
    – DukeZhou
    Commented Apr 15, 2020 at 23:08
  • $\begingroup$ No worries! ;-) Anyone else that could help me? $\endgroup$
    – nvrs
    Commented Apr 16, 2020 at 7:43

1 Answer 1


I think your approach to tackle this as an imbalanced problem is correct. The easiest thing you could do is to add weights to the samples, during training, so that the model "pays more attention" to the under-represented class.

There are also a couple of other ways for this to be done: oversampling and undersampling, but initially, I'd focus on adding weights, since its easier to implement.

  • $\begingroup$ Thanks! I am pretty new to this and I am reading about it now. I stumbled upon the technique of importance sampling/weighting. Would you use this to add weights to the samples? If not, how would you do this? And will each sample weight be added to the loss function in this case? Maybe I haven't explained this in a clear way, sorry! But my challenge is that I don't want to focus on imbalanced gender in the entire dataset but per product category (which is another input feature in my model). Thanks for your help again! $\endgroup$
    – nvrs
    Commented Apr 18, 2020 at 15:53
  • $\begingroup$ If you add weights to each sample, you have the degree of freedom to weigh them as you like. A sample from a male that belongs to a female-dominated category could get a high weight, while a female item from the same category could get a lower one. What I'm trying to say is that you can weigh your samples per gender and category if you want to. The importance sampling technique I'm aware of is unrelated, but it's plausible that the same name is used for different techniques. $\endgroup$
    – Djib2011
    Commented Apr 18, 2020 at 23:22

You must log in to answer this question.

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