AI, machine learning and deep learning · Introductory

Handling Numerical Data

Written by SignalsLab

Early edition: these lessons are being reviewed.

Content

Summary

This lesson covers the classification of numerical data types and essential preprocessing techniques like min-max scaling and standardization to ensure features are on comparable scales. It also highlights the importance of using the median over the mean when dealing with outliers to maintain accurate data representation.

Intuition

Machine learning algorithms often struggle when features have vastly different ranges, such as age in years versus income in dollars. To fix this, we rescale data so all features contribute equally to the model. Min-max scaling squeezes data into a fixed box, usually 0 to 1, while standardization centers the data around zero with a consistent spread. Additionally, when data is skewed by extreme values, the median provides a more honest picture of the 'typical' value than the mean, which gets pulled by those extremes.

Key equations

xi′=xi−min⁡xmax⁡x−min⁡x
(1)

Min-max scaling formula where x_i is the original value, min x is the minimum value in the feature, max x is the maximum value, and x_i' is the rescaled value.

xi′=xi−x‾σ
(2)

Standardization formula where xi is the original value, x‾ is the mean of the feature, σ is the standard deviation, and xi′ is the standardized value.

Derivation

  1. Identify the type of numerical data (continuous, discrete, or ordinal) to determine appropriate preprocessing.
  2. For min-max scaling, locate the minimum and maximum values of the feature vector.
  3. Subtract the minimum value from each data point to shift the range to start at zero.
  4. Divide by the range (max minus min) to scale the data to the interval [0, 1].
  5. For standardization, calculate the mean (x‾) and standard deviation (σ) of the feature.
  6. Subtract the mean from each data point to center the distribution at zero.
  7. Divide by the standard deviation to ensure the resulting distribution has a standard deviation of one.

Worked example

Problem

Given a feature vector [2, 4, 6, 8, 10], calculate the min-max scaled value for the element 6.

  1. Identify min x = 2 and max x = 10.
  2. Apply the formula: x_i' = (6 - 2) / (10 - 2).
  3. Calculate numerator: 6 - 2 = 4.
  4. Calculate denominator: 10 - 2 = 8.
  5. Divide: 4 / 8 = 0.5.

Answer 0.5

Common mistakes

  • Treating ordinal data (like health ratings) as purely numerical without considering its categorical nature may lead to incorrect modeling.
  • Relying solely on the mean in the presence of outliers can be misleading, as outliers skew the average significantly.
  • Assuming that fit_transform and separate fit/transform operations are mathematically different, when they are not, though separate operations allow applying the same transformation to new data.

Animation

Animation coming soon

The animated version of this lesson is being prepared for the web. In the Signals AI app, lessons are drawn step by step.

Code

This is a text lesson: it has no animation code yet.

ccBYNC© 2026 SignalsLab. Lesson text shared as is under CC BY-NC 4.0.