liveBook · Manning

Feature scaling

As explained in Cyber Threat Hunting

Feature scaling is the transformation of numerical features to comparable scales so that differences in magnitude do not disproportionately affect computations.

Feature scaling transforms numerical features to comparable ranges so large-magnitude variables do not dominate distance calculations or model performance. It is especially important for k-means, which assigns points using Euclidean distance. section 8.2.1 section 8.2.2

A practical scaling workflow includes:

  • Identify magnitude differences, such as binary app indicators alongside byte counts measured in thousands. section 8.2.1
  • Apply StandardScaler so each feature has a mean of 0 and a standard deviation of 1. section 8.2.2
  • Use the scaled data for distance-based clustering or as preparation for PCA. section 8.2.1 section 9.2.5

Scaling a feature with scikit-learn

Create a StandardScaler and fit-transform numerical columns such as bytes, std1, and count1. The transformed values become comparable, while the data distribution’s shape remains unchanged. section 8.2.2

How Cyber Threat Hunting covers it

How deep it goes
Explains magnitude bias, Euclidean distance, StandardScaler, and implementation, but does not develop scaling mathematics beyond a simple distance example.
Examples
Uses binary app indicators, byte counts, a three-feature distance example, and scaled DataFrames for demonstration.
What it assumes
Assumes numerical features and basic DataFrame handling, while introducing distance effects and normalization through concrete examples.
What you can do after
Apply it via scikit-learn's StandardScaler to numerical DataFrame columns and training features before k-means or PCA.
How it connects
Connects feature scaling to k-means, Euclidean distance, StandardScaler, PCA, and dimensionality reduction.

Also explained in

Compare how 5 books explain feature scaling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Cyber Threat Hunting. The section links point to the parts of the book it draws on.