# Problem with converting string to dummy variables

I'm new in data science, I have data which want to work on it, I omitted extra columns and convert it to 4 columns ( Product, Date, Market, Demand ) . in this data Product and Market are string, I know for working on this data must convert them. I want to convert the string to dummy variables but this isn't logical because I have 64 fruits in the product column.

I am confused and I don't know what can I do whit this strings.

• I already dealt with such a question Here, you should have a look at this answer – BeamsAdept Sep 17 '20 at 14:29
• thanks, that's good. I have a product variable which is the name of fruits and you know these is discrete. making a group for this which Category Encoders are better for this? in first I used OrdinalEncoder but when I see it needs mapping (dictionary) I am regret because I have 64 fruits. You can help me, I'm really confusing. – ramin Sep 17 '20 at 17:50
• I should have been more precise sorry, just use TargetEncoder, LeaveOneOut, WeightOfEvidence or JamesStein – BeamsAdept Sep 18 '20 at 7:03

There are a variety of ways to convert a categorical column to a numeric one, with the right answer many times being use-case specific. Trial and error can help here to see what works best for your problem.

To give a specific recommendation, you may want to try Target Encoding as an option and see how it performs. It will probably be better than One Hot Encoding or Ordinal Encoding in your case.

You can use label encoders for your product and market. however one hot encoding will be the best one to suit for converting string to numbers to feed into an algorithm . I suggest looking at this link for further details :- https://towardsdatascience.com/choosing-the-right-encoding-method-label-vs-onehot-encoder-a4434493149b