0

I am creating a baseline. This baseline is composed by some variables. Some of these variables are positive, whilst others present positive and negative values. Here the problem: I need to do a log transformation of these variables for another model. How can I deal with it?

Do I need to add to every pos/neg vector its minimun in absolute value +1? In this case, my baseline will be modified. Can I proportionate again with the constant used (its minimun in absolute value +1)?

Thank you in advance to everyone.

VIX
  • 5
  • 3
  • Not sure if I understood correctly .. but you can do a simple scaling of the column by using "(X-Xmin)/(Xmax-Xmin)" ..This will ensure the values are >= 0. Then you can take a log of this for your another model ... However without seeing the data and the context, this might be a little naive suggestion. Mind explaining your problem in more detail? – Amit Jan 25 '21 at 12:51
  • Thank you: this is a better approach than mine. Yet problem is still remaining: I have some 0s, given when I have the minimum of the series concerned. – VIX Jan 25 '21 at 13:55
  • You mean your column minimum is less than 0 and you have 0 values as well? If yes, then the scaling will work regardless and all your values will be between 0 and 1. The original 0 value will be scaled as well and will not longer be zero since the minimum of the column is negative .. Not sure if I answered your query – Amit Jan 25 '21 at 13:59
  • 1
    I mean that if (X - Xmin)/(Xmax-Xmin) = 0, when X = Xmin, if I apply a log transformation is a problem. – VIX Jan 25 '21 at 14:39
  • ok I see it .. You are right ... Will adding a "small leak value" after scaling ..for example ((X-Xmin)/(Xmax-Xmin)+0.00000001) ..work? the leak value must be very small though ..much smaller than other values in the column .. – Amit Jan 25 '21 at 14:59
  • For me is ok, but I don't know for the model XD. But in the meanwhile I really appreciate your help and thank you very much. I can do after the transformation an if state as: If x == 0: x = x.min()/10000 else. x = x – VIX Jan 25 '21 at 15:05

0 Answers0