import dash from dash import html import dash_bootstrap_components as dbc dash.register_page(__name__, path="/", name="Overview") def stat(value, label, icon, color): return dbc.Col(html.Div([ html.I(className=f"bi {icon} fs-3", style={"color": color}), html.H3(value, className="text-white fw-bold mt-2 mb-0"), html.Small(label, className="text-muted"), ], className="stat-card"), md=3, className="mb-3") layout = html.Div([ html.Div([ html.H1("Engine Anomaly Detection", className="text-white fw-bold mb-2"), html.P("Catching engine faults before they become failures, using an autoencoder " "trained only on healthy driving.", className="lead text-info", style={"letterSpacing": "0.5px"}), ], className="mb-5"), dbc.Row([ stat("30,807", "sensor readings", "bi-database", "#1d9e75"), stat("9", "engine sensors", "bi-cpu", "#378add"), stat("168", "model parameters", "bi-diagram-3", "#9d50bb"), stat("0.80", "ROC-AUC", "bi-graph-up", "#e8a33d"), ], className="mb-5"), dbc.Card(dbc.CardBody([ html.H2("What this project does", className="text-white fw-bold mb-3"), html.P([ "A modern engine streams thousands of sensor values per second. Most faults do not " "announce themselves with a single dramatic reading - they start as a subtle drift in " "the ", html.B("relationship"), " between sensors. This dashboard demonstrates an " "unsupervised detector that learns what healthy driving looks like and flags anything " "that no longer fits that shape." ], className="text-light mb-4", style={"fontSize": "1.1rem", "lineHeight": "1.8"}), html.H4("How it works, in one line", className="text-white mb-3"), html.P([ "An ", html.B("autoencoder"), " compresses each 9-sensor reading down to 3 numbers and " "rebuilds it. Trained on healthy data, it rebuilds normal readings accurately and " "unfamiliar ones poorly. The reconstruction error is the anomaly score." ], className="text-light mb-4", style={"fontSize": "1.1rem", "lineHeight": "1.8"}), html.H4("The workflow behind the app", className="text-white mb-3"), dbc.Row([ dbc.Col(html.Div([ html.Span("1", className="badge bg-success me-2"), html.B("Exploratory analysis", className="text-white"), html.P("Understand the sensors, their correlations, and what faults look like.", className="text-muted small mt-1"), ], className="stat-card"), md=4, className="mb-3"), dbc.Col(html.Div([ html.Span("2", className="badge bg-success me-2"), html.B("Model comparison", className="text-white"), html.P("Benchmark a statistical baseline, Isolation Forest and the autoencoder.", className="text-muted small mt-1"), ], className="stat-card"), md=4, className="mb-3"), dbc.Col(html.Div([ html.Span("3", className="badge bg-success me-2"), html.B("Final pipeline", className="text-white"), html.P("Train, threshold, save the model and serve it through this app.", className="text-muted small mt-1"), ], className="stat-card"), md=4, className="mb-3"), ]), html.Div([ dbc.Button(["Try the Anomaly Engine ", html.I(className="bi bi-arrow-right ms-1")], href="/engine", color="success", className="mt-3"), ]), ]), className="modern-card mb-4"), ])