0
$\begingroup$

I have used np.log(data) and then applied data.diff() to transform my data in timeseries model. I have the predictions. How do I convert it back to normal scale?

Here is an example for your reference:

--------------------------------------------------------------------
| sales     | np.log(sales) | (np.log(sales)).diff() | predictions |
--------------------------------------------------------------------
|166.594019 | 5.115560      | -0.045918              | -0.045918   |
--------------------------------------------------------------------

Note: I have provided only one example which from index 2 as the first value after data.diff() will be null. And hence the prediction at index 1 is 0.

$\endgroup$
2
  • 1
    $\begingroup$ mathematically log can be reversed with exp, but I don't understand the context. $\endgroup$
    – Erwan
    Nov 27, 2021 at 12:17
  • $\begingroup$ I need to revert it to a natural number to share forecasted sales back with my team. $\endgroup$ Nov 27, 2021 at 18:15

1 Answer 1

0
$\begingroup$

As far as I understand the difference is $log(s_t)-log(s_{t-1})$, right?

I'm not sure that doing the diff on the log value is the best option but this means:

$$log(s_t)-log(s_{t-1})=log\left(\frac{s_t}{s_{t-1}}\right)$$

You could use exp to go back to the regular ratio:

$$exp\left(log\left(\frac{s_t}{s_{t-1}}\right)\right)=\frac{s_t}{s_{t-1}}$$

$\endgroup$

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.