Create or ingest telemetry
Collect features such as requests per minute, failed attempts and bytes transferred; normalise timestamps and remove duplicates before modelling.
Detect anomalous web traffic. Prioritise analyst review.
Bot detection for web traffic aims to flag automated or malicious clients from telemetry such as request rates, error counts and bytes transferred. Common challenges include concept drift, attacker evasion, imbalanced labels, and the need to surface explainable alerts so analysts can triage incidents.
Learning concept · Not a validated service
Bot detection for web traffic aims to flag automated or malicious clients from telemetry such as request rates, error counts and bytes transferred. Common challenges include concept drift, attacker evasion, imbalanced labels, and the need to surface explainable alerts so analysts can triage incidents.
A proposed application: surface high-confidence anomalous sessions for a security-operations analyst to inspect and escalate; keep a human in the loop and do not use this prototype for automated account blocking.
Collect features such as requests per minute, failed attempts and bytes transferred; normalise timestamps and remove duplicates before modelling.
Fit an unsupervised detector on representative 'normal' traffic and tune contamination or thresholds using held-out known incidents if available.
Measure precision at fixed recall, review false positives with analysts, and inspect feature distributions for alert explainability.
Add drift monitoring, alert rate limits, audit trails and a manual review workflow before any automated remediation.
The supplied starter synthesises two groups of numeric records (300 'normal' and 15 'suspicious'), concatenates them, fits an IsolationForest (contamination=0.05) and uses fit_predict to label records as inliers (1) or outliers (-1). It then prints the number of alerts and a sample of flagged rows.
suspicious = pd.DataFrame(
{
"events_per_minute": rng.normal(80, 10, 15),
"failed_attempts": rng.poisson(12, 15),
"bytes_out_mb": rng.normal(180, 30, 15),
}
)
logs = pd.concat([normal, suspicious], ignore_index=True)
detector = IsolationForest(contamination=0.05, random_state=42)
logs["anomaly_score"] = detector.fit_predict(logs)
alerts = logs[logs["anomaly_score"] == -1]The starter uses small, synthetic Gaussian/Poisson features rather than real web logs and provides no labelled ground truth for supervised detection or held-out evaluation. It sets contamination statically and does not tune thresholding, compute precision/recall, or provide explainability for alerts. This code is a pedagogical anomaly baseline, not a production-ready bot classifier.
A proposed extension: connect the detector to a review UI that groups alerts by session, provides feature-level explanations, and allows analysts to label examples for periodic supervised retraining.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its Cybersecurity Course, with placement support and hands-on labs.