liveBook · Manning

Min-max normalization

As explained in The Complete Obsolete Guide to Generative AI

Min-max scaling is a normalization method that linearly transforms values into a specified range, commonly from 0 to 1.

Different features often arrive wearing wildly different units: CPU speed in GHz, memory in GB, and storage in GB. Min-max normalization puts them on a common scale so comparisons and visualizations do not let the biggest numbers steal the show. section 6.11

For one feature, find its minimum and maximum, then calculate: (original value − minimum) / (maximum − minimum). The result normally falls between 0 and 1: the minimum becomes 0 and the maximum becomes 1. Relationships and proportions remain available, while the original units disappear. section 6.11

Use min-max normalization when:

  • Comparing features measured in different units or placing them on one graph. section 6.11
  • Preparing inputs for methods sensitive to feature scale, including neural networks, k-means clustering, and support vector machines. section 6.11
  • Remember that normalized lines share endpoints at 0 and 1, so the plot can hide which series grew faster in absolute terms. section 6.13

A normalized hardware trend

A time-series dataset tracks server component specifications by year. Keeping Year unchanged, normalize the other columns and plot them together. The resulting chart can reveal broad trends, such as limited storage growth between roughly 2009 and 2013, but it cannot show absolute growth rates reliably. If the numbers came from an AI-generated dataset, verify them before trusting the conclusion. section 6.13

Listing 6.2 Visualizing a time series with normalization
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.preprocessing import MinMaxScaler
 
df_servers = pd.read_csv("AllServers.csv")
 
 
years = df_servers['Year'].values                               #1
scaler = MinMaxScaler()
normalized_data = scaler.fit_transform\
    (df_servers.drop(columns=['Year']))
 
 
plt.figure(figsize=(10, 6))                                     #2
 
 
for i, column_name in enumerate(df_servers.columns[1:]):
    plt.plot(years, normalized_data[:, i], label=column_name)   #3
 
 
plt.xlabel('Year')                                              #4
plt.ylabel('Normalized Values')                                 #4
plt.title('"All Servers" (Normalized) Specs Over Time')         #4
 
 
plt.legend()                                                    #5
 
 
plt.grid(True)
plt.show()                                                      #6

A runnable Python listing loads CSV data, applies scikit-learn's MinMaxScaler to non-year columns, and plots the normalized series with Matplotlib. section 6.13

How The Complete Obsolete Guide to Generative AI covers it

How deep it goes
Defines the formula and demonstrates a plotted workflow, but stops short of deeper algorithmic internals.
Examples
Uses CPU, memory, storage, employee salaries, experience, and server specifications as normalization examples.
What it assumes
Assumes feature data with identifiable minimum and maximum values; teaches the scaling formula from the beginning.
What you can do after
Apply it via scikit-learn's MinMaxScaler to normalize tabular columns and plot comparable time-series trends.
How it connects
Connects normalization with data visualization, time-series data, neural networks, k-means clustering, and support vector machines.

Also explained in

Compare how 4 books explain min-max normalization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Complete Obsolete Guide to Generative AI. The section links point to the parts of the book it draws on.