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

Decision tree

Algorithm Library · Algorithm Supervised Learning Runs in the browser

The idea

Splits the space with successive threshold rules, choosing at each node the split that reduces Gini impurity most.

The problem it addresses

Human-readable rules that analysts can review.

Data it needs

Tabular numeric and categorical data.

Equations

G(S)=1-\sum_c p_c^2,\quad \Delta=G(S)-\tfrac{|S_L|}{|S|}G(S_L)-\tfrac{|S_R|}{|S|}G(S_R)

Steps

  1. Find the best feature and threshold
  2. Split samples
  3. Recurse to max depth or pure nodes
  4. Predict majority class at leaves

Pseudocode

decision-tree.txt
def grow(S, depth):
    if pure(S) or depth == D: return leaf(S)
    f, t = best_split(S)
    return Node(f, t, grow(S[S[:,f]<=t], depth+1), grow(S[S[:,f]>t], depth+1))

Strengths

  • Interpretable
  • No scaling needed
  • Handles interactions

Limitations

  • High variance, overfits
  • Axis-aligned boundaries

Uses in cybersecurity

  • Teaching detection rules
  • Building block of forests

Common pitfalls

  • Deep trees memorise the training set; limit depth and watch the train/test gap.

Computational complexity

Inference is tree-depth; building requires sorting features.

Suggested datasets

Related experiments

See also

References

  1. Breiman (2001). Random Forests. Machine Learning 45(1), pp. 5-32. doi:10.1023/a:1010933404324