""" page1_intro.py — Introduction, How to Use, Objectives, Architecture Diagram """ import streamlit as st from styles import (inject_global_css, page_header, metric_row, WCO_GOLD, WCO_BLUE, WCO_GREEN, WCO_RED, WCO_CARD_BG, WCO_BORDER, WCO_MUTED) ARCH_SVG = """ No-CelH · Self-Learning RMS Architecture DATE Exploitation ◈ gATE Exploration ◈ Human-in-the-Loop ◈ WCO Compendium 📦 Import Declarations 1,000 Bills / Batch 📋 Risk Register 5 Risk Areas · Rules Weights · Targets 🧠 DATE Engine Exploitation: ŷᶜˡˢ + ŷʳᵉᵛ Fraud Score × Revenue Risk Scoring Pipeline ⚖️ Hybrid Selector 90% DATE + 10% gATE Bandwidth: 10% (adj.) Optimal Selection 🔍 gATE Engine unc_i × log(ŷʳᵉᵛ + ε) K-means++ Diversity Concept Drift Guard 🔴 RED Physical Exam 🟡 YELLOW Doc Check 🟢 GREEN Facilitated 👮 Officer Inspection Labels: yᶜˡˢ + yʳᵉᵛ Human-in-the-Loop 🗄️ Offence Database Augmented Real-Time 5 Risk Categories Model Update Weight Update 📉 Static Model (Baseline) Selection Rate: 10% | Detection: 4.1% Efficiency Index: 0.41 Exploitation-only · No Learning 📈 Hybrid Model (No-CelH) Selection Rate: 10% | Detection: 8.2% Efficiency Index: 0.82 DATE 90% + gATE 10% · Self-Learning +100% 🔬 Discovery Barometer New Importers Discovered: ~10× more New HS Codes Mapped: 2,000+ in 5 yrs Sequential Fraud Detection: ✓ Enabled Uncertainty: unc_i = −1.8 × |ŷᶜˡˢ − 0.5| + 1 Scale: S_i = unc_i × log(ŷʳᵉᵛ + ε) Efficiency Index = Detection Rate / Selection Rate Reference: Kim et al. (2022) IEEE TKDE · WCO Risk Compendium 🌐 WCO Accredited Expert Framework """ def show(): inject_global_css() page_header("🛃", "No-CelH: Self-Learning RMS", "WCO ACCREDITED · CUSTOMS RISK MANAGEMENT SYSTEM · ACTIVE LEARNING SIMULATION") # ── KPI strip ───────────────────────────────────────────────── metric_row([ ("5", "Risk Areas", WCO_GOLD), ("1,000","Declarations / Run", WCO_BLUE), ("10%", "Interdiction Bandwidth", WCO_RED), ("0.82", "Target Efficiency Index", WCO_GREEN), ("2×", "Revenue vs Static", WCO_GOLD), ]) # ── Architecture SVG ────────────────────────────────────────── st.markdown('
🏗️ System Architecture
', unsafe_allow_html=True) st.markdown(ARCH_SVG, unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) # ── Three info columns ──────────────────────────────────────── c1, c2, c3 = st.columns(3) with c1: st.markdown("""

🎯 Objectives

""", unsafe_allow_html=True) with c2: st.markdown("""

📖 How to Use This App

📋 Page 2 → Configure 5-area Risk Register, 3×3 Matrix, rules & annual weights

🔄 Page 3 → Run live simulation — watch 1,000 bills routed in real-time

📊 Page 4 → Analyse offence DB growth, exploration gains, rule hit tables

🏆 Page 5 → Optimisation report — efficiency, accuracy, bandwidth ROI

""", unsafe_allow_html=True) with c3: st.markdown("""

🔬 Recommended Exploration Strategy

bATE — Best for customs context

✅ Uncertainty-scaled gradient embeddings

✅ Revenue-weighted diversity (K-means++)

✅ Outperforms BADGE & random by large margin

✅ Anomaly + probability-based hybrid sampling

gATE adds gatekeeping randomness for adversarial robustness

""", unsafe_allow_html=True) # ── How RMS works ───────────────────────────────────────────── st.markdown('
⚙️ How the Self-Learning Cycle Works
', unsafe_allow_html=True) steps = [ ("1", "#C8A951", "📥 Ingest", "Batch of import declarations enters the scoring pipeline each week"), ("2", "#0066CC", "🧠 Score (DATE)", "Exploitation engine scores each bill: fraud probability ŷᶜˡˢ + revenue ŷʳᵉᵛ"), ("3", "#9933CC", "🔍 Explore (gATE)","Exploration engine identifies uncertain bills (unc_i near 0.5) for new knowledge"), ("4", "#C8A951", "⚖️ Hybrid Select", "10% bandwidth split: 90% exploitation + 10% exploration → RED/YELLOW/GREEN"), ("5", "#0066CC", "👮 Inspect", "Officers examine Red & Yellow — outcomes labelled (fraud / clean / doc-query)"), ("6", "#00843D", "🗄️ Feedback", "Confirmed frauds augment offence DB; rule weights auto-update → model retrains"), ] cols = st.columns(6) for i, (num, col, title, desc) in enumerate(steps): with cols[i]: st.markdown(f"""
{num}
{title}
{desc}
""", unsafe_allow_html=True) st.markdown("
", unsafe_allow_html=True) # ── Scientific basis ────────────────────────────────────────── with st.expander("📚 Scientific Basis & Mathematical Formulas"): fc1, fc2 = st.columns(2) with fc1: st.markdown("""

DATE Exploitation Engine

Dual Attentive Tree-aware Embedding model optimises two objectives simultaneously:

h_θ(x) = σ(W · z_φ(x))

""", unsafe_allow_html=True) with fc2: st.markdown("""

gATE Exploration Engine

Selects uncertain, high-revenue, diverse bills via:

Efficiency Index = Detection Rate / Selection Rate

""", unsafe_allow_html=True)