neural networks
data processing
machine learning
denormalization
predictive modeling

Denormalization of predicted data in neural networks

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

In the context of neural networks, data normalization is a commonly used preprocessing step that aims to bring all input features onto a similar scale. This is critical to the efficient training of neural networks. However, after training and when the network is used for prediction, it is often necessary to convert these predictions back to their original scale—a process known as denormalization. Understanding denormalization is crucial when deploying models for real-world applications where the interpretability of the predicted results is necessary.

Understanding Denormalization

Denormalization is the process of reverting normalized values to their original range or distribution. In the realm of neural networks, data normalization techniques such as Min-Max Scaling, Z-Score Normalization, and others, transform input data into a specified range (often [0, 1] or with zero mean and unit variance). Denormalization reverses this transformation after the network has generated its output.

Necessity of Denormalization

  1. Interpretability: Predictions produced by neural networks are typically in a scaled form (e.g., within [0, 1]). These values are often not suitable for direct human interpretation or consumption.
  2. Accuracy in Real-world Applications: Real-world implementations often rely on the original data scale. For instance, in financial forecasting, one must convert predicted revenue back to its original dollar scale to make accurate and actionable decisions.
  3. Result Evaluation: Denormalization is critical for evaluating the model’s performance in terms that are meaningful within the dataset’s context, such as error metrics like Mean Absolute Error (MAE) or Root Mean Squared Error (RMSE) that are sensibly computed in the original scales.

Common Normalization Techniques and Their Denormalization

Min-Max Scaling

  • Normalization Formula: xnorm=xxminxmaxxminx_{\text{norm}} = \frac{x - x_{\text{min}}}{x_{\text{max}} - x_{\text{min}}}
  • Denormalization Formula: x=xnorm×(xmaxxmin)+xminx = x_{\text{norm}} \times (x_{\text{max}} - x_{\text{min}}) + x_{\text{min}}

Z-Score Normalization

  • Normalization Formula: xnorm=xμσx_{\text{norm}} = \frac{x - \mu}{\sigma}
  • Denormalization Formula: x=xnorm×σ+μx = x_{\text{norm}} \times \sigma + \mu

Example

Consider a dataset where values are scaled using Min-Max Scaling. The denormalization of a prediction can be demonstrated with the following Python code snippet:


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.