An interpretable machine-learning baseline for detecting unusual vessel behavior from operational and environmental signals.
Shipping systems produce many signals at once: speed, course changes, route distance, draught, weather, visibility, traffic density, and AIS signal gaps. This project turns those signals into a reproducible anomaly-detection workflow that can be inspected, tested, and extended.
The included synthetic dataset contains 6,000 vessel observations with:
- vessel type and seasonality
- speed, course-change angle, route distance, and draught
- wind, visibility, and traffic density
- AIS signal-gap duration
- binary
anomalytarget
The data is synthetic and is intended for engineering demonstration and model prototyping, not operational decisions.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python train.pyThe training script prints a classification report and saves a feature-importance chart to outputs/feature_importance.png.
The reproducible baseline uses an 80/20 stratified split and a screening threshold of 0.30:
| Metric | Normal (0) | Anomaly (1) |
|---|---|---|
| Precision | 0.938 | 0.125 |
| Recall | 0.963 | 0.078 |
| F1 | 0.950 | 0.096 |
Overall ROC-AUC is 0.590 on the held-out split. The result is intentionally treated as a starting point: the rare anomaly class and weak signal separation make threshold selection, calibration, temporal splits, and stronger features important next steps. The script also exports outputs/evaluation_curves.png for visual inspection.
- Load and validate the tabular data.
- One-hot encode categorical vessel type.
- Train a reproducible Random Forest baseline.
- Apply a documented screening threshold and report precision, recall, F1, ROC-AUC, and confusion matrix.
- Export model diagnostics for inspection.
- reproducible random seed
- explicit feature list
- no hidden network calls
- validation before training
- clear separation between data, source code, and outputs
- transparent reporting of class imbalance and baseline limitations
- compare calibrated tree models and gradient boosting
- add temporal and vessel-level split strategies
- evaluate class imbalance and threshold selection
- connect the feature pipeline to live AIS data only after source and geofence validation
MIT

