0
$\begingroup$

I am working a price prediction LTSM model for the stock market. I am using multiple features: Open, Close, High and I would like to add the Volume.

The 3 first features are of the same nature but the volume presents much higher values.

What would be the safest way to keep consistency during the normalization process?

$\endgroup$
1
$\begingroup$

You would usually just scale all of them to be within the same range.

You can do this by using something like the Scikit-Learn MinMaxScaler, or just a simple function like this:

def scale(data, new_min=-1, new_max=1)
    """Scale values of data to be within the range [new_min, new_max]
    data must be a numpy array or a Pandas Dataframe/Series"""

    return (data - data.min()) / (data.max() - data.min()) * (new_max - new_min) + new_min

Between -1 and +1 is just nice, as the data is centered around zero. You could play with those values.

You can think about and perhaps experiment to see if you should scale all variables together (meaning one global min and max in the dataset), or whether to scale the individual columns/features of your dataset, so each one lies in the given range.


A tip for financial data is to use the log returns - that means to take your raw prices, compute the logarithm of those values, then take the difference between the closing prices of each day.

The reason for this is to because the resulting values are normally distributed, which is an underlying assumption of many models you will subsequently use (Boosting, ARIMA, GARCH for volatilities etc.). There are also other reasons of convenience - check out this article

$\endgroup$
  • $\begingroup$ - Price features normalized with log returns - Volume normalized with MinMax (-1, 1) or (0,1)? there's obviously no negative values for this feature in my dataset => Could these 2 normalization be compatible? $\endgroup$ – Vincent Roye Oct 26 '18 at 5:27
  • $\begingroup$ @VincentRoye - I would probably normalise them to the same range for consistency. It may also make any model optimisation a little smoother. $\endgroup$ – n1k31t4 Oct 26 '18 at 9:03

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.