title: Reverse Box-Cox transformation
body: <p>I am using <a href="http://docs.scipy.org/doc/scipy-dev/reference/generated/scipy.stats.boxcox.html" rel="noreferrer">SciPy's boxcox function</a> to perform a <a href="http://en.wikipedia.org/wiki/Power_transform#Box.E2.80.93Cox_transformation" rel="noreferrer">Box-Cox transformation</a> on a continuous variable.</p>
  
  <pre><code>from scipy.stats import boxcox
  import numpy as np
  y = np.random.random(100)
  y_box, lambda_ = ss.boxcox(y + 1) # Add 1 to be able to transform 0 values
  </code></pre>
  
  <p>Then, I fit a statistical model to predict the values of this Box-Cox transformed variable. The model predictions are in the Box-Cox scale and I want to transform them to the original scale of the variable.</p>
  
  <pre><code>from sklearn.ensemble import RandomForestRegressor
  rf = RandomForestRegressor()
  X = np.random.random((100, 100))
  rf.fit(X, y_box)
  pred_box = rf.predict(X)
  </code></pre>
  
  <p><strong>However, I can't find a SciPy function that performs a reverse Box-Cox transformation given transformed data and lambda. Is there such a function?</strong> I coded an inverse transformation for now.</p>
  
  <pre><code>pred_y = np.power((y_box * lambda_) + 1, 1 / lambda_) - 1
  </code></pre>