{% extends "base.html" %} {% block title %}Anomaly Detection{% endblock %} {% block content %}
AI Anomaly Detection

Evidence items are scored by an Isolation Forest model trained on six custody-behaviour features. Scores near 1.0 indicate unusual patterns compared to the rest of the dataset.

{% if not records %}
Not enough evidence items to run anomaly detection (minimum 3 required).
{% else %}
{% for rec in records %} {% endfor %}
Rank Evidence Anomaly Score Flagged? Key Features Actions
{{ loop.index }} #{{ rec.evidence_id }} - {{ rec.evidence_title }} {% set score_val = rec.anomaly_score %} {% set bar_col = 'bg-success' if score_val < 0.25 else 'bg-warning' if score_val < 0.50 else 'bg-danger' if score_val < 0.75 else 'bg-dark' %} {% set pct = (score_val * 100) | int %}
{{ '%.3f' | format(score_val) }}
{% if rec.is_anomaly %} Anomaly {% else %} Normal {% endif %} transfers: {{ rec.feature_vector.transfer_count | round(2) }} | rate: {{ rec.feature_vector.transfer_rate | round(2) }} | handlers: {{ rec.feature_vector.unique_handler_count | int }} | max gap: {{ rec.feature_vector.max_gap_days | round(1) }}d Risk Report
{% endif %}
{% endblock %}