2
$\begingroup$

My dataset has around 20 features, one of which is colors(in string format). There are around 50 different colors. I have converted them to RGB, but now I want to encode the data in such a way that the values are relevant, because I will cluster the data on this feature later on. To do this, one-hot encoding proved ineffective. Suggestions?

$\endgroup$
2
$\begingroup$

One-hot encoding will give you a sparse matrix, Try LabelEncoding, before converting them into RGB that is.

Also, you could try breaking the RGB values into three features (R, G, B) and try that approach as well.

Hope this helps.

$\endgroup$
  • $\begingroup$ @YashGandhe I think the RGB features approach here is likely to prove most useful when clustering. $\endgroup$ – Dan Scally Aug 19 at 14:09
0
$\begingroup$

Depends on what the Colour means in your data. Example temperature can be colour from blue and red, in which case 1-hot won't work. But looks like colour is categorical in your data. In that case it depends on what you are using to classify the data, are you using a decision tree, or SVM etc. Cos in case of decision tree you don't have to do anything as it can take care of categorical data ( again depends on which implementation you use ). in case of other methods they have their own ways in which categorical data has to be handled.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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