Show usable recent DEB accuracy
This commit is contained in:
@@ -40,6 +40,19 @@ type DebHistoricalSummary = {
|
||||
hits?: number;
|
||||
};
|
||||
|
||||
type DebUsableRecentSummary = {
|
||||
window?: "recent_7d" | "recent_14d" | string;
|
||||
city_count?: number;
|
||||
samples?: number;
|
||||
hits?: number;
|
||||
hit_rate?: number | null;
|
||||
avg_mae?: number | null;
|
||||
recommendations?: {
|
||||
primary?: number;
|
||||
supporting?: number;
|
||||
};
|
||||
};
|
||||
|
||||
type DebVersionSummary = {
|
||||
version?: string;
|
||||
samples?: number;
|
||||
@@ -51,6 +64,7 @@ type DebVersionSummary = {
|
||||
|
||||
type DebSummaryPayload = {
|
||||
historical?: DebHistoricalSummary;
|
||||
usable_recent?: DebUsableRecentSummary;
|
||||
recent_7d?: DebWindowSummary;
|
||||
recent_14d?: DebWindowSummary;
|
||||
versions?: Record<string, DebVersionSummary>;
|
||||
@@ -178,6 +192,7 @@ export function TrainingDashboard({ isEn }: { isEn: boolean }) {
|
||||
cities: debSummary?.historical?.city_count ?? debSorted.length,
|
||||
sampleDays: debSummary?.historical?.sample_days,
|
||||
weightedHit: debSummary?.historical?.weighted_hit_rate,
|
||||
usableRecent: debSummary?.usable_recent,
|
||||
};
|
||||
}, [debSorted, debSummary]);
|
||||
|
||||
@@ -218,6 +233,10 @@ export function TrainingDashboard({ isEn }: { isEn: boolean }) {
|
||||
|
||||
const formatPct = (value: number | null | undefined) => value == null ? "--" : `${value.toFixed(1)}%`;
|
||||
const formatMaybeDeg = (value: number | null | undefined, digits = 1) => value == null ? "--" : `${value.toFixed(digits)}°`;
|
||||
const usableWindowLabel = (window?: string) => {
|
||||
if (window === "recent_14d") return isEn ? "Usable 14d" : "可用近14天";
|
||||
return isEn ? "Usable 7d" : "可用近7天";
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-full overflow-auto bg-[#f5f7fa]">
|
||||
@@ -242,7 +261,7 @@ export function TrainingDashboard({ isEn }: { isEn: boolean }) {
|
||||
<div className="grid grid-cols-2 gap-2 mb-3 md:grid-cols-3 xl:grid-cols-6">
|
||||
{[
|
||||
{ icon: Hash, label: isEn ? "Cities" : "城市数", value: debStats.cities, tone: "blue" },
|
||||
{ icon: Target, label: isEn ? "Historical Avg" : "历史平均", value: `${debStats.avgHit.toFixed(1)}%`, tone: "emerald" },
|
||||
{ icon: Target, label: usableWindowLabel(debStats.usableRecent?.window), value: formatPct(debStats.usableRecent?.hit_rate), tone: "emerald" },
|
||||
{ icon: TrendingUp, label: isEn ? "Recent 7d" : "近7天", value: formatPct(debSummary?.recent_7d?.hit_rate), tone: "emerald" },
|
||||
{ icon: TrendingUp, label: isEn ? "Recent 14d" : "近14天", value: formatPct(debSummary?.recent_14d?.hit_rate), tone: "purple" },
|
||||
{ icon: Thermometer, label: isEn ? "Avg Error" : "平均误差", value: `${debStats.avgMae.toFixed(1)}°`, tone: "amber" },
|
||||
|
||||
@@ -89,6 +89,18 @@ interface DebSummary {
|
||||
sample_days?: number;
|
||||
city_count?: number;
|
||||
};
|
||||
usable_recent?: {
|
||||
window?: string;
|
||||
city_count?: number;
|
||||
samples?: number;
|
||||
hits?: number;
|
||||
hit_rate?: number | null;
|
||||
avg_mae?: number | null;
|
||||
recommendations?: {
|
||||
primary?: number;
|
||||
supporting?: number;
|
||||
};
|
||||
};
|
||||
recent_7d?: {
|
||||
hit_rate?: number | null;
|
||||
mae?: number | null;
|
||||
@@ -160,6 +172,7 @@ export function TrainingPageClient() {
|
||||
return {
|
||||
avgHit: debSummary?.historical?.avg_hit_rate ?? avgHit,
|
||||
avgMae: debSummary?.historical?.avg_mae ?? avgMae,
|
||||
usableRecent: debSummary?.usable_recent,
|
||||
recent7Hit: debSummary?.recent_7d?.hit_rate,
|
||||
recent14Hit: debSummary?.recent_14d?.hit_rate,
|
||||
best,
|
||||
@@ -167,6 +180,9 @@ export function TrainingPageClient() {
|
||||
};
|
||||
}, [accuracy, debSummary]);
|
||||
|
||||
const usableWindowLabel = (window?: string) =>
|
||||
window === "recent_14d" ? "DEB 可用近 14 天命中" : "DEB 可用近 7 天命中";
|
||||
|
||||
const debChartData = useMemo(() => {
|
||||
if (!accuracy?.length) return [];
|
||||
return accuracy
|
||||
@@ -247,7 +263,9 @@ export function TrainingPageClient() {
|
||||
<div className="grid grid-cols-2 md:grid-cols-6 gap-4">
|
||||
<KpiCard
|
||||
icon={Target} color="bg-cyan-500/20 text-cyan-400"
|
||||
label="DEB 历史平均命中" value={`${kpis.avgHit.toFixed(1)}%`}
|
||||
label={usableWindowLabel(kpis.usableRecent?.window)}
|
||||
value={kpis.usableRecent?.hit_rate == null ? "—" : `${kpis.usableRecent.hit_rate.toFixed(1)}%`}
|
||||
sub={`可用城市 ${kpis.usableRecent?.city_count ?? 0} · 样本 ${kpis.usableRecent?.samples ?? 0} · 历史 ${kpis.avgHit.toFixed(1)}%`}
|
||||
/>
|
||||
<KpiCard
|
||||
icon={Target} color="bg-emerald-500/20 text-emerald-400"
|
||||
|
||||
Reference in New Issue
Block a user