liveBook · Manning

Unsupervised learning

As explained in Cyber Threat Hunting

Unsupervised machine learning is a machine-learning paradigm that discovers patterns and structures in data without predefined labels or specific instructions.

Unsupervised learning analyzes unlabeled data to find hidden structure: similar records can be grouped, and unusual records can stand apart, without being told which records are benign or malicious. In threat hunting, it shifts the starting point from a fixed indicator or threshold to patterns present in the data. section 8.1 section 8.1.8

Use it after understanding and preparing the data, not as a replacement for that work. Extract useful features from raw events, encode non-numeric values appropriately, inspect correlations, and remove highly correlated fields before applying an algorithm. Data preprocessing can determine whether resulting clusters are meaningful. section 8.1.2 section 8.1.8 section 8.8

A practical unsupervised threat-hunting workflow is:

  • Collect connection events from a data store or file, retaining fields that may describe behavior. section 8.1.2
  • Calculate behavioral features such as connection timing, counts, variance, and inbound-versus-outbound byte differences. section 8.1.2
  • Apply a clustering algorithm such as k-means to group data points, then examine small or unusual clusters for anomalies. section 8.0 section 8.3.2
  • Investigate cluster members, excluding known normal traffic carefully rather than treating cluster assignment as a verdict. section 8.3.2 section 8.8

Finding jittered command-and-control traffic

A hunt can start with a hypothesis that compromised internal hosts beacon to a command-and-control server with an unknown interval, jitter level, port, or destination. After k-means assigns connection records to four clusters, inspecting two small clusters can expose malicious beaconing without setting a standard-deviation threshold first. Clustering remains imperfect: malicious connections may span multiple clusters. section 8.1.8 section 8.3.2

Figure 8.1 Threat hunting with unsupervised machine process

Follow the end-to-end threat-hunting process from unlabeled event data through preparation, modeling, and anomaly investigation. section 8.1

Treat outputs as leads, not proof. Algorithms have different rules and tunable parameters; compare approaches when needed, seek specialist help for deeper mathematical questions, and use findings to help create labeled data for later supervised learning. section 8.8

How Cyber Threat Hunting covers it

How deep it goes
Defines unlabeled pattern discovery and walks through preprocessing, feature selection, k-means clustering, and cluster investigation while deferring deeper mathematics.
Examples
Uses network connection events and jittered command-and-control beaconing, including clusters containing suspicious internal-to-external connections.
What it assumes
Assumes threat-hunting familiarity but introduces core ML concepts and uses existing libraries rather than requiring new algorithm code.
What you can do after
Apply it via existing Python libraries to prepare connection data, cluster it, and investigate anomalous groups as threat-hunting leads.
How it connects
Connects feature engineering, one-hot encoding, correlation analysis, k-means, clustering, anomaly detection, and supervised learning.

Also explained in

Compare how 20 books explain unsupervised learning →

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.