Inverse Transform After Prediction

Beginner
~10 min
code completion

Inverse Transform After Prediction

When a target variable y is standardized before training, model predictions are in scaled space. To evaluate them in the original units (e.g., dollars, seconds), you must apply the inverse transform:

where and are the statistics used during the forward transform.

This is a critical pipeline step: if you forget it, your RMSE will be in the wrong units and your business logic will be completely wrong.

Example:

mu = 100.0, sigma = 20.0
predictions = [0.0, 1.0, -1.0]
→ inverse: [100.0, 120.0, 80.0]

Your task:

Implement inverse_standardize(predictions, mu, sigma) that maps scaled predictions back to the original scale.

Example Tests

Scaled 0 maps to mu, +1 maps to mu+sigma, -1 maps to mu-sigma

Input: {"mu":100,"sigma":20,"predictions":[0,1,-1]}

Expected: [100,120,80]

Identity case: sigma=1, mu=0 leaves predictions unchanged

Input: {"mu":0,"sigma":1,"predictions":[3,-2,0.5]}

Expected: [3,-2,0.5]

All-zero predictions map to mu regardless of sigma

Input: {"mu":50,"sigma":10,"predictions":[0,0]}

Expected: [50,50]

Sign in to solve this problem

You can read the full problem statement above. Create a free account to run code in the browser, submit solutions, and track your progress.