1
$\begingroup$

So I have this model but the data may vary. And it is virtually impossible to always have the values in bounds. If I do I`d have to use larger period leading to concept shift which is worse.

The question is what is the best way to deal with the values of futures that are out of the model bounds? I see 3 options

  1. If the value is greater than max set it to the max value the model has seen
  2. If the value is less than min set it to the min value the model has seen
  3. If the value is greater or less set it to the mean that kind of eliminates the future weight for the prediction.

So what would be the best approach here any thoughts?

Note: I am retraining the model daily and the model has a lot of futures ~500 so it is highly likely even right after retraining some to be out of bounds, excluding futures is not the best option since it's never the same future showing this behaviour.

I am using this function for scaling.

def min_max(value, min_max_map):
    result = 0
    if min_max_map['max'] - min_max_map['min']:
        result = (value - min_max_map['min']) / (min_max_map['max'] - min_max_map['min'])
        if result > min_max_map['max'] or result < min_max_map['min']:
            result = (min_max_map['mean'] - min_max_map['min']) / (min_max_map['max'] - min_max_map['min'])

    return result
$\endgroup$
2
  • $\begingroup$ is not clear to me why data out of training range represent a problem. Is it cause of feature preprocessing? Are you using min max normalization or something similar? $\endgroup$ Commented Aug 3, 2022 at 8:23
  • $\begingroup$ Yes I am using normalization. As far as I know, models tend to give wrong predictions if the values they are analyzing are never seen before. I am using min max scaler to cramp the values on 1 scale $\endgroup$
    – Newbie
    Commented Aug 3, 2022 at 8:31

1 Answer 1

0
$\begingroup$

Steps 1 and 2 are basically the same operation, clipping, which is a possibility but not the best since your loosing information. Imagine having two instances with same features except for feature $n$, which assume value 101 and 201 respectively. Let's say that 100 was your observed maximum in the training data for feature $n$, after clipping both instances will look the same and lead to same predictions, good for instance 1 cause its value of $n$ is close to the training maximum, but nonsense for instance 2.

The best way would be defining a theoretical maximum, so independent from the training data, it could be also a value that we set as maximum and after which we do indeed clip cause occurrences of higher values are rare.

An alternative is also to use z score standardization instead of min max normalization. The output range is [$-\infty$, $\infty$] but in practice you'll end up with values almost all within the range [-1, 1], and rare occurrences below and above this range are totally fine.

$\endgroup$
4
  • $\begingroup$ If I put let's say a theoretical maximum of 100 for features that usually vary between 0 and 35 and we get a value of 71. In the training, the model will see a max value of .35 but in the prediction, it will get .71. Won`t that mislead the model and create some kind of bias? It's binary classification if that matters. $\endgroup$
    – Newbie
    Commented Aug 3, 2022 at 10:13
  • $\begingroup$ no, the purpose of feature scaling is just to set all features in the same order of magnitude, but is not required that every feature includes instances with values 0 as min and 1 as max after being processed. It's actually extremely rare for that to happen, basically only in computer vision where images are always between 0 and 255. $\endgroup$ Commented Aug 3, 2022 at 10:33
  • $\begingroup$ And also if the variability between training and test is huge, than there is a problem in the quality of the training data that are not representative enough, and that can't be solved with preprocessing. $\endgroup$ Commented Aug 3, 2022 at 10:36
  • $\begingroup$ I see thank you. I will actually post a question exactly about the data quality topic soon :). $\endgroup$
    – Newbie
    Commented Aug 3, 2022 at 10:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .