"use client"; import { useQuery } from "@tanstack/react-query"; import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts"; import { CheckCircle2 } from "lucide-react"; import { api } from "@/lib/api"; import { useT } from "@/i18n/context"; import { Card, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; export function ModelInsights() { const { dict } = useT(); const { data, isLoading } = useQuery({ queryKey: ["model-info"], queryFn: api.modelInfo, }); if (isLoading || !data) { return ( {dict.common.loading} ); } const all = [ { name: data.name, accuracy: data.metrics.accuracy, recall: data.metrics.recall, roc_auc: data.metrics.roc_auc, selected: true, }, ...data.alternatives.map((a) => ({ ...a, selected: false })), ]; const chartData = all.map((m) => ({ name: m.name, Accuracy: +(m.accuracy * 100).toFixed(1), Recall: +(m.recall * 100).toFixed(1), "ROC-AUC": +(m.roc_auc * 100).toFixed(1), })); return (

{dict.model.selected}

{data.name}
threshold {data.threshold}%

{dict.model.comparison}

{dict.model.rationale}

{dict.model.rationaleText}

); } function Metric({ label, value }: { label: string; value: string }) { return (
{label}
{value}
); }