liveBook · Manning

Z-score normalization

As explained in Advanced Algorithms and Data Structures

Z-score normalization transforms each feature by subtracting its mean and dividing by its standard deviation.

Z-score normalization rescales each feature by subtracting its mean from every value and dividing by that feature’s standard deviation. The result has zero mean and unit variance, preventing large-unit features from dominating distance calculations. section 12.5

Apply the transformation independently to each feature:

  • Compute the feature’s mean and standard deviation. section 12.5
  • Subtract the mean from every feature value. section 12.5
  • Divide each centered value by the feature’s standard deviation before measuring similarity. section 12.5

Customer clustering

Annual salaries around $100K–$200K and monthly expenses around $500–$1,000 have very different scales. Without normalization, salary differences can overwhelm expense differences when Euclidean distance assigns customers to clusters. section 12.5

Figure 12.24 A synthetic dataset showing customers of a hypothetic e-commerce website after feature scaling. On the right, a possible (bad) clustering for the dataset.

View the synthetic customer dataset after feature scaling and compare it with the resulting clustering context. section 12.5

How Advanced Algorithms and Data Structures covers it

How deep it goes
Explains the transformation and its zero-mean, unit-variance result without developing implementation code.
Examples
Uses customer salaries and monthly expenses to demonstrate scale imbalance.
What it assumes
Assumes familiarity with feature values, means, standard deviations, and Euclidean distance.
What you can do after
Apply normalization before Euclidean-distance clustering so differently scaled features contribute more comparably.
How it connects
Connects feature scaling with Euclidean distance, k-means, and clustering.

Also explained in

Compare how 2 books explain z-score normalization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.