AI Cybersecurity Lab

Intrusion and anomaly detection, malware analysis, threat intelligence, phishing, security logs and incident response: defensive experiments that really compute in your browser on synthetic data, with algorithms, datasets, projects and quizzes.

28interactive experiments

Isolation Forest

Algorithm Library · Algorithm Unsupervised Learning Runs in the browser

The idea

Isolates points with random splits; anomalies are isolated with fewer splits, so shortness of the average path length measures anomaly.

The problem it addresses

Unsupervised anomaly detection without labels.

Data it needs

Numeric tabular data.

Equations

s(x,n)=2^{-E[h(x)]/c(n)},\quad c(n)=2H(n-1)-\tfrac{2(n-1)}{n}

Steps

  1. Build isolation trees on sub-samples
  2. Route each point and record path length
  3. Turn the average into an anomaly score

Pseudocode

isolation-forest.txt
for t in trees: depth[t][x] = path_length(t, x)
score = 2 ** (-mean(depth, axis=0) / c(psi))

Strengths

  • Near-linear time
  • No labels needed
  • Handles moderate dimensions

Limitations

  • The contamination threshold is a manual choice
  • Weak against dense clusters of anomalies

Uses in cybersecurity

  • Network-traffic anomalies
  • Suspicious sessions

Common pitfalls

  • "Anomalous" is not "malicious": rare legitimate states will be flagged too.

Computational complexity

The original paper reports roughly linear time in the sub-sample size.

Suggested datasets

Related experiments

See also

References

  1. Liu, Ting, Zhou (2008). Isolation Forest. IEEE ICDM 2008, pp. 413-422. doi:10.1109/icdm.2008.17
  2. Chandola, Banerjee, Kumar (2009). Anomaly detection: A survey. ACM Computing Surveys 41(3), pp. 1-58. doi:10.1145/1541880.1541882