# Encoding continuous values

I've been reading about one-hot encoding for categorical values. Could similar mechanism make sense for continuous values? I'm looking at a problem, where I try to predict the volume of product X, with a variables being the price of product Y.

The reason is to increase the strength of the signal from the price of Y, which otherwise could be understated because overall prices fluctuate in relatively low range. The idea would be to e.g. remove attribute of "Price Y" and replace it with "Promotion Y" based on a set threshold.

E.g.

Price X | Price Y | Vol X | Vol Y  | Promotion X  | Promotion Y
100     | 90      | 40    | 50     | 0            |  0
75      | 75      | 60    | 60     | 1            |  1
100     | 75      | 30    | 70     | 0            |  0


I could just test it out on a dataset, but this could be very specific to this very set and I just want some more theoretical suggestion if and where such approaches would make sense?

• what you are asking is not clear, One Hot Encoding is used for converting categorical data into numeric. Now here what do you mean by converting numeric into what? Categorical Variable(if yes, that method is called Binning). How are you planning to replace Promotion Y with Price Y?? Did you find any correlation? Mar 6, 2018 at 8:58
• Thank you for the hint on binning. This is useful for me to further explore. I cannot see correlation which is suprising and I'm trying to find a way.
– Turo
Mar 6, 2018 at 9:27
• Then it doesn't make any sense for you waste time in replacing Price Y with Promotion Y. Did you do correlation analysis with the target variable? If they both are Important you can use them else you can remove one of them Mar 6, 2018 at 9:59
• Thank you for a hint :) I need to look for some other ways,
– Turo
Mar 6, 2018 at 15:12
• Do let us know if you are stuck somewhere, we are always here to help you. 😊 Mar 6, 2018 at 15:28

No. There is no similar mechanism for continuous variable.

If it worries you, that overall prices fluctuate in relatively low range, you can

1) demean the price, that is subtract mean price from all price values. Then negative values will clearly show below-average and positive above-average prices.

2) after demeaning you can divide values by the standard deviation of the price. (1) and (2) together is called "standardization".

Alternatively you can

3) rescale your price to the range of values you want. Usual choice is (0,1) range.

If you do this for one feature (price in your case), then it makes sense to do the same for other features.

Whether or not this will help to get better prediction results depends on the model. Some models, a typical example would be SVM, do require such transformation.

You can use pandas.cut() function to convert your continuous data into categorical data. And then you can use one-hot encoding on it. Also, this will solve the problem of the threshold that you mentioned. By setting the number of bins you can find the best solution. This will also be a more generalized approach.