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

Linear SVM (Pegasos)

Algorithm Library · Algorithm Supervised Learning Runs in the browser

The idea

Finds a maximum-margin separating hyperplane, trained here with Pegasos stochastic gradient descent on the hinge loss.

The problem it addresses

Strong linear separation in high dimensions such as TF-IDF.

Data it needs

High-dimensional sparse or dense data.

Equations

\min_w \tfrac{\lambda}{2}\lVert w\rVert^2+\tfrac1n\sum_i\max(0,1-y_i w^\top x_i)

Steps

  1. Pick a random sample
  2. If it violates the margin, update w
  3. Shrink w by the regulariser

Pseudocode

linear-svm.txt
for t in 1..T:
    i = rand(n); eta = 1/(lam*t)
    w *= (1 - eta*lam)
    if y[i]*(w@x[i]) < 1: w += eta*y[i]*x[i]

Strengths

  • Effective in high dimensions
  • Clear margin

Limitations

  • No direct probabilities
  • Needs scaling
  • Only the linear version is implemented here

Uses in cybersecurity

  • Phishing text classification
  • Files with many features

Common pitfalls

  • A fair comparison tunes the regularisation strength for every model rather than using defaults.

Suggested datasets

Related experiments

References

  1. Arp, Quiring, Pendlebury, Warnecke, Pierazzi, Wressnegger, Cavallaro, Rieck (2024). Pitfalls in Machine Learning for Computer Security. Communications of the ACM 67(11), pp. 104-112. doi:10.1145/3643456