1
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ I already dealt with such a question Here, you should have a look at this answer $\endgroup$
    – Adept
    Commented Sep 17, 2020 at 14:29
  • $\begingroup$ 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. $\endgroup$
    – ramin
    Commented Sep 17, 2020 at 17:50
  • $\begingroup$ I should have been more precise sorry, just use TargetEncoder, LeaveOneOut, WeightOfEvidence or JamesStein $\endgroup$
    – Adept
    Commented Sep 18, 2020 at 7:03

2 Answers 2

0
$\begingroup$

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.

Example links:

https://contrib.scikit-learn.org/category_encoders/targetencoder.html

https://maxhalford.github.io/blog/target-encoding/

https://brendanhasz.github.io/2019/03/04/target-encoding

$\endgroup$
1
  • $\begingroup$ thanks. that's good. but if you saw my data, you know my data is dependent on time, it's better I say this is time-series data. I have a question, can I use Target Encoding in time series data? or panel data with a time window? $\endgroup$
    – ramin
    Commented Sep 17, 2020 at 22:00
0
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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