0
$\begingroup$

in my dataset for machine learning I have many categorical features with one dominant category as you can see on the picture. enter image description here

How can I deal with this kind of categorical data in preprocessing?

$\endgroup$

closed as unclear what you're asking by mkt, Peter Flom Apr 9 at 14:46

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Deal with what? $\endgroup$ – Tim Apr 9 at 11:17
  • $\begingroup$ In general. I'm not sure if this kind of data should be somehow weighted / transformed or if I can just apply dummy encoding and the fact that one category is dominant will not negatively affect model performance. $\endgroup$ – soldous Apr 9 at 11:30
  • $\begingroup$ Transformed what for? Why exactly do you need to transform it? What is the problem? $\endgroup$ – Tim Apr 9 at 11:33
  • $\begingroup$ My problem in general is: Binary classification machine learning scenario (predict 0 or 1). I'm kind of a newbie to the machine learning and I walked through the basic workflow of data preprocessing (dealing with nulls, outliers, encode categorical features as dummy variables and scale features) but even in with my best algorithm the precision is only 0,67 and I need a more precise model. So I was thinking if unbalanced categorical features could negatively affect the precision. $\endgroup$ – soldous Apr 9 at 11:43
2
$\begingroup$

You are asking what could be done in terms of preprocessing the data when one of the categories in categorical feature is very frequent. In such case nothing should, or even can, be done. In such case for many samples you observe the same value. If you transformed the values in some way, nothing would change about the fact that still many samples have the same category (while it would be encoded using different value). Saying it differently, if you changed the encoding of classes, the only thing that would change is the labels on the $x$-axis of your plot.

What can be done with such features, is you can create new features using the categorical variables, this however would be very problem specific and without additional details not much can be recommended. For example, in some cases using TF-IDF features may beneficial, or you could replace the categories with the conditional means of the target variable given the category (so called mean encoding or target encoding), etc. and treat them as continuous features.

$\endgroup$
  • $\begingroup$ Thank you very much. So this kind of categorical feature will not negatively affect the precision of the model? I can encode them as dummy variables and leave that? $\endgroup$ – soldous Apr 9 at 13:28
  • $\begingroup$ @soldous This is the data you have. It can either improve the model performance if it is meaningful, or be useless & dropped out of the model, but it is not "wrong". What I'm saying is that this is not something that you need to "correct", but in some cases you could benefit for using this feature differently, by applying more advanced feature engineering techniques. $\endgroup$ – Tim Apr 9 at 13:32
  • $\begingroup$ ok, thanks again! I'll look at provided techniques $\endgroup$ – soldous Apr 9 at 13:37

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