Skip to content

Commit 6db54c1

Browse files
feat: integrate QSVM and ECOD into ML analytics pipeline
1 parent 05c81e9 commit 6db54c1

16 files changed

Lines changed: 38677 additions & 362 deletions

Frontend/Dashboard/src/lib/api.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export interface FeatureImportanceItem {
6060
feature: string;
6161
importance: number;
6262
}
63+
export interface ROCPoint {
64+
fpr: number;
65+
tpr: number;
66+
}
6367

6468
export interface MLMetrics {
6569
accuracy: number;
@@ -76,6 +80,7 @@ export interface MLMetrics {
7680
threshold: number;
7781
evaluated_at?: string;
7882
feature_importance?: FeatureImportanceItem[];
83+
roc_curve: ROCPoint[];
7984
calibration?: {
8085
precision_target: number | null;
8186
calibration_precision: number;
@@ -105,6 +110,7 @@ export interface SupervisedModelResult {
105110
feature_importance: FeatureImportanceItem[];
106111
feature_importance_label: string;
107112
train_seconds: number;
113+
roc_curve: ROCPoint[];
108114
}
109115

110116
export interface SupervisedComparison {
@@ -145,6 +151,37 @@ export interface LanlComparison {
145151
note: string;
146152
}
147153

154+
// Standalone QSVM subsample experiment (train_qsvm.py) - NOT part of
155+
// SupervisedComparison's models[] array. Different sample size and
156+
// PCA-reduced feature space than the other supervised models, so it's
157+
// kept as its own type/endpoint rather than shoehorned into
158+
// SupervisedModelResult, to avoid implying a 1:1 comparison.
159+
export interface QsvmExperiment {
160+
model_key: "qsvm";
161+
model: string;
162+
accuracy: number;
163+
precision: number;
164+
recall: number;
165+
f1: number;
166+
roc_auc: number;
167+
pr_auc: number;
168+
tn: number;
169+
fp: number;
170+
fn: number;
171+
tp: number;
172+
threshold: number;
173+
train_seconds: number;
174+
sample_size: number;
175+
train_size: number;
176+
cal_size: number;
177+
test_size: number;
178+
n_qubits: number;
179+
pca_explained_variance: number;
180+
feature_map: string;
181+
roc_curve: ROCPoint[];
182+
note: string;
183+
}
184+
148185
async function getJSON<T>(path: string): Promise<T> {
149186
const response = await fetch(`${API_BASE}${path}`);
150187
if (!response.ok) {
@@ -166,6 +203,7 @@ export const api = {
166203
getMLMetrics: () => getJSON<MLMetrics>("/ml"),
167204
getSupervisedComparison: () => getJSON<SupervisedComparison | null>("/ml/supervised-comparison"),
168205
getLanlComparison: () => getJSON<LanlComparison | null>("/ml/lanl-comparison"),
206+
getQsvmExperiment: () => getJSON<QsvmExperiment | null>("/ml/qsvm-experiment"),
169207
getSystemStatus: () => getJSON<SystemStatus>("/system"),
170208
};
171209

Frontend/Dashboard/src/lib/queries.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ export function useLanlComparison() {
8282
});
8383
}
8484

85+
export function useQsvmExperiment() {
86+
return useQuery({
87+
queryKey: ["ml-qsvm-experiment"],
88+
queryFn: api.getQsvmExperiment,
89+
// This is a one-off, manually-run experiment (~2hrs to regenerate),
90+
// not a recurring pipeline output - no need to poll every 60s like
91+
// the other panels.
92+
refetchInterval: false,
93+
staleTime: Infinity,
94+
});
95+
}
96+
8597
export function useSystemStatus() {
8698
return useQuery({
8799
queryKey: ["system-status"],

0 commit comments

Comments
 (0)