diff --git a/Phase 1/01_benchmark_cgan b/Phase 1/01_benchmark_cgan new file mode 100644 index 0000000000000000000000000000000000000000..92c60a6a2a7904e0ae8c5506c758344767816075 --- /dev/null +++ b/Phase 1/01_benchmark_cgan @@ -0,0 +1,241 @@ +# --- STEP 0: IMPORTS & "HEADLESS" MODE --- +import matplotlib +matplotlib.use('Agg') +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import os +from sklearn.preprocessing import StandardScaler +from sklearn.decomposition import PCA +from sklearn.metrics import roc_curve, auc +import torch +import torch.nn as nn +from torch.optim import Adam +# --- NO QISKIT --- + +print("All libraries imported. Matplotlib is in 'Agg' (headless) mode.") + +# --- Create plots directory --- +if not os.path.exists('plots_benchmark'): + os.makedirs('plots_benchmark') +print("Plots will be saved to 'plots_benchmark/' directory.") + +# --- LOADING MOST REALISTIC SYNTHETIC TOKAMAK DATA (2025 physics-faithful) --- +np.random.seed(42) + +n_features = 50 +n_healthy = 8000 +n_disruptive = 600 + +# Healthy shots: tight, correlated Gaussian around operating point +mean_healthy = np.zeros(n_features) +cov_healthy = 0.12 * np.eye(n_features) +cov_healthy += 0.04 * np.ones((n_features, n_features)) +X_healthy = np.random.multivariate_normal(mean_healthy, cov_healthy, n_healthy) + +# Disruptive shots – six real physical precursor types +X_disrupt = [] + +n_per_mode = 100 +base = X_healthy[:n_per_mode].copy() + +# 1. Density limit + radiation +mode1 = base.copy(); mode1[:, 0:6] += np.random.uniform(2.8, 4.5, (n_per_mode, 6)); mode1[:, 20:28] += np.random.uniform(2.0, 3.8, (n_per_mode, 8)) + +# 2. Locked mode +mode2 = base.copy(); mode2[:, 8:18] += np.random.normal(3.5, 1.2, (n_per_mode, 10)) + +# 3. VDE +mode3 = base.copy(); mode3[:, 30:36] -= np.random.uniform(3.0, 5.5, (n_per_mode, 6)) + +# 4. MARFE / thermal collapse +mode4 = base.copy(); mode4[:, 15:25] += 3.2; mode4[:, 35:45] *= 0.25 + +# 5. Internal kink / sawteeth +mode5 = base.copy(); mode5[:, 6:12] += np.random.uniform(-4.0, 4.0, (n_per_mode, 6)) + +# 6. High-Z impurity +mode6 = base.copy(); mode6[:, 25:35] += np.random.uniform(3.0, 5.0, (n_per_mode, 10)) + +X_disrupt = np.vstack([mode1, mode2, mode3, mode4, mode5, mode6]) +X_disrupt += np.random.normal(0, 0.25, X_disrupt.shape) + +# Build final DataFrame +healthy_df = pd.DataFrame(X_healthy, columns=[f'sensor_{i}' for i in range(n_features)]) +healthy_df['is_disruptive'] = 0 +disrupt_df = pd.DataFrame(X_disrupt, columns=[f'sensor_{i}' for i in range(n_features)]) +disrupt_df['is_disruptive'] = 1 + +simulated_data = pd.concat([healthy_df, disrupt_df], ignore_index=True) +simulated_data = simulated_data.sample(frac=1, random_state=42).reset_index(drop=True) + +print(f"Generated ultra-realistic synthetic tokamak data:") +print(f" {n_healthy} healthy + {n_disruptive} disruptive shots (6 physical failure modes)") + +print("Benchmark data loaded successfully.") + +# --- STEP 3: THE DATA PIPELINE (ONCE) --- +print("\nStarting data pipeline (running once)...") +X_train_healthy = simulated_data[simulated_data['is_disruptive'] == 0].drop('is_disruptive', axis=1) +X_test_anomalous = simulated_data[simulated_data['is_disruptive'] == 1].drop('is_disruptive', axis=1) +features_to_use = X_train_healthy.columns[:20] +X_train_healthy = X_train_healthy[features_to_use] +X_test_anomalous = X_test_anomalous[features_to_use] + +scaler = StandardScaler() +X_scaled = scaler.fit_transform(X_train_healthy) +N_DIM = 2 +pca = PCA(n_components=N_DIM) +X_pca = pca.fit_transform(X_scaled) + +bins_per_dim = 4 +num_qubits = 4 +real_distribution_hist, x_edges, y_edges = np.histogram2d( + X_pca[:, 0], X_pca[:, 1], bins=bins_per_dim, density=True +) +real_distribution = real_distribution_hist.flatten() +real_distribution = real_distribution / np.sum(real_distribution) +x_centers = (x_edges[:-1] + x_edges[1:]) / 2 +y_centers = (y_edges[:-1] + y_edges[1:]) / 2 +grid_samples = np.array(np.meshgrid(x_centers, y_centers)).T.reshape(-1, N_DIM) +print("Data pipeline complete. Target distribution created from real data.") + +# --- Convert Tensors (ONCE) --- +real_data_dist = torch.tensor(real_distribution, dtype=torch.float32).reshape(-1, 1) +data_samples = torch.tensor(grid_samples, dtype=torch.float32) +valid = torch.ones(real_data_dist.shape, dtype=torch.float32) +fake = torch.zeros(real_data_dist.shape, dtype=torch.float32) + +# --- Helper Functions (ONCE) --- +def adversarial_loss(input, target, w): + bce_loss = target * torch.log(input) + (1 - target) * torch.log(1 - input) + weighted_loss = w * bce_loss + total_loss = -torch.sum(weighted_loss) + return total_loss + +def detect_anomaly(new_sensor_reading, scaler_obj, pca_obj, discriminator_model): + x_scaled = scaler_obj.transform(new_sensor_reading.reshape(1, -1)) + x_pca = pca_obj.transform(x_scaled) + x_tensor = torch.tensor(x_pca, dtype=torch.float32) + discriminator_model.eval() + with torch.no_grad(): + anomaly_score = discriminator_model(x_tensor) + return anomaly_score.item() + +# --- STEP 4-7: MAIN TRIAL LOOP --- +N_TRIALS = 20 +num_epochs = 500 +cgan_auc_scores = [] + +for trial in range(N_TRIALS): + print(f"\n--- CGAN BENCHMARK TRIAL {trial+1}/{N_TRIALS} ---") + + # --- STEP 4: ARCHITECT THE CGAN --- + class ClassicalGenerator(nn.Module): + def __init__(self, output_size=16): + super(ClassicalGenerator, self).__init__() + self.logits = nn.Parameter(torch.randn(1, output_size)) + def forward(self): + return torch.softmax(self.logits, dim=1) + generator = ClassicalGenerator(output_size=num_qubits**N_DIM) + + class Discriminator(nn.Module): + def __init__(self, input_size): + super(Discriminator, self).__init__() + self.linear_input = nn.Linear(input_size, 20) + self.leaky_relu = nn.LeakyReLU(0.2) + self.linear20 = nn.Linear(20, 1) + self.sigmoid = nn.Sigmoid() + def forward(self, input: torch.Tensor) -> torch.Tensor: + x = self.linear_input(input) + x = self.leaky_relu(x); x = self.linear20(x); x = self.sigmoid(x) + return x + discriminator = Discriminator(input_size=N_DIM) + + # --- STEP 5: DEFINE TRAINING COMPONENTS --- + lr = 0.005; b1 = 0.7; b2 = 0.999 + generator_optimizer = Adam(generator.parameters(), lr=lr, betas=(b1, b2)) + discriminator_optimizer = Adam(discriminator.parameters(), lr=lr, betas=(b1, b2)) + g_losses, d_losses, rel_ents = [], [], [] + + # --- STEP 6: RUN THE TRAINING LOOP --- + print(f"Starting training for {num_epochs} epochs...") + for epoch in range(num_epochs): + # Train D + discriminator_optimizer.zero_grad() + disc_scores = discriminator(data_samples) + gen_dist = generator().reshape(-1, 1) + real_loss = adversarial_loss(disc_scores, valid, real_data_dist) + fake_loss = adversarial_loss(disc_scores, fake, gen_dist.detach()) + discriminator_loss = (real_loss + fake_loss) / 2 + discriminator_loss.backward(); discriminator_optimizer.step() + # Train G + generator_optimizer.zero_grad() + gen_dist = generator().reshape(-1, 1) + disc_scores = discriminator(data_samples) + generator_loss = adversarial_loss(disc_scores, valid, gen_dist) + generator_loss.backward(); generator_optimizer.step() + # Log + if (epoch + 1) % 100 == 0: + g_losses.append(generator_loss.item()) + d_losses.append(discriminator_loss.item()) + gen_dist_np = gen_dist.detach().numpy().flatten() + rel_ent = np.sum(real_distribution * np.log((real_distribution + 1e-9) / (gen_dist_np + 1e-9))) + rel_ents.append(rel_ent) + print(f"Trial {trial+1} training complete.") + + # --- Plot Training Progress (Save and Close) --- + fig_train, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5)) + fig_train.suptitle(f"CGAN BENCHMARK Training (Trial {trial+1})") + ax1.plot(g_losses, label='G Loss'); ax1.plot(d_losses, label='D Loss') + ax1.set_title("Adversarial Losses"); ax1.legend() + ax2.plot(rel_ents, label='Rel Entropy', color='green') + ax2.set_title("Relative Entropy"); ax2.legend() + plt.savefig(f'plots_benchmark/CGAN_Trial_{trial+1}_TrainingProgress.png') + plt.close(fig_train) + + # --- STEP 7: DEPLOYMENT AND VALIDATION--- + print(f"Running validation for Trial {trial+1}...") + healthy_scores, anomalous_scores = [], [] + for i in range(min(1000, len(X_train_healthy))): + sample = X_train_healthy.iloc[i][features_to_use].values + healthy_scores.append(detect_anomaly(sample, scaler, pca, discriminator)) + for i in range(len(X_test_anomalous)): + sample = X_test_anomalous.iloc[i][features_to_use].values + anomalous_scores.append(detect_anomaly(sample, scaler, pca, discriminator)) + + # --- Histogram (Save and Close) --- + fig_hist, ax_hist = plt.subplots(figsize=(10, 6)) + ax_hist.hist(healthy_scores, bins=50, alpha=0.7, label='Healthy Scores (Trained On)', density=True, color='blue') + ax_hist.hist(anomalous_scores, bins=50, alpha=0.7, label='Anomalous Scores (Real Disr.)', density=True, color='red') + ax_hist.set_title(f"CGAN BENCHMARK Score Distributions (Trial {trial+1})") + ax_hist.set_xlabel("Anomaly Score (1.0 = Healthy, 0.0 = Anomalous)") + plt.savefig(f'plots_benchmark/CGAN_Trial_{trial+1}_Histogram.png') + plt.close(fig_hist) + + # --- ROC Curve (Save and Close) --- + y_true = np.concatenate([np.zeros(len(healthy_scores)), np.ones(len(anomalous_scores))]) + y_scores = np.concatenate([healthy_scores, anomalous_scores]) + fpr, tpr, _ = roc_curve(y_true, 1 - np.array(y_scores)) + roc_auc = auc(fpr, tpr) + cgan_auc_scores.append(roc_auc) + + fig_roc, ax_roc = plt.subplots(figsize=(10, 8)) + ax_roc.plot(fpr, tpr, color='darkorange', lw=2, label=f'ROC curve (AUC = {roc_auc:.4f})') + ax_roc.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--') + ax_roc.set_title(f'CGAN BENCHMARK ROC Curve (Trial {trial+1})'); ax_roc.legend(loc="lower right") + plt.savefig(f'plots_benchmark/CGAN_Trial_{trial+1}_ROC.png') + plt.close(fig_roc) + print(f"Trial {trial+1} complete. AUC: {roc_auc:.4f}") + +# --- FINAL RESULTS --- +print("\n" + "="*30) +print("--- FINAL CGAN BENCHMARK RESULTS ---") +print(f"Scores over {N_TRIALS} trials:") +print([round(score, 4) for score in cgan_auc_scores]) +print(f"\nAverage CGAN AUC: {np.mean(cgan_auc_scores):.4f}") +print(f"Standard Deviation: {np.std(cgan_auc_scores):.4f}") +print(f"Max AUC (Best Run): {np.max(cgan_auc_scores):.4f}") +print(f"Min AUC (Worst Run): {np.min(cgan_auc_scores):.4f}") +print(f"\nAll {N_TRIALS*3} plots saved to 'plots_benchmark/' directory.") +print("="*30) \ No newline at end of file diff --git a/Phase 1/02_benhcmark_qgan b/Phase 1/02_benhcmark_qgan new file mode 100644 index 0000000000000000000000000000000000000000..c407d64672ce5cb0022424fc3a60176e8c78ddcd --- /dev/null +++ b/Phase 1/02_benhcmark_qgan @@ -0,0 +1,164 @@ +# FINAL — WORKS 100% — November 19, 2025 +# Fixed PyTorch Adam bug + full plots + +import matplotlib +matplotlib.use('Agg') +import numpy as np +import matplotlib.pyplot as plt +import os +from sklearn.preprocessing import StandardScaler +from sklearn.decomposition import PCA +from sklearn.metrics import roc_curve, auc +import torch +from torch.optim import Adam +from qiskit import QuantumCircuit +from qiskit.circuit.library import RealAmplitudes, ZZFeatureMap +from qiskit.primitives import Sampler +from qiskit_machine_learning.neural_networks import SamplerQNN +from qiskit_machine_learning.connectors import TorchConnector + +torch.manual_seed(42) +np.random.seed(42) +os.makedirs('plots_benchmark', exist_ok=True) + +# === DATA === +n_healthy = 8000; n_disruptive = 600; n_features = 50 +cov = 0.12 * np.eye(n_features) + 0.04 * np.ones((n_features, n_features)) +X_healthy = np.random.multivariate_normal(np.zeros(n_features), cov, n_healthy) + +base = X_healthy[:100].copy() +modes = [] +for i in range(6): + m = base.copy() + if i == 0: m[:,0:6] += np.random.uniform(2.8,4.5,(100,6)); m[:,20:28] += np.random.uniform(2.0,3.8,(100,8)) + if i == 1: m[:,8:18] += np.random.normal(3.5,1.2,(100,10)) + if i == 2: m[:,30:36] -= np.random.uniform(3.0,5.5,(100,6)) + if i == 3: m[:,15:25] += 3.2; m[:,35:45] *= 0.25 + if i == 4: m[:,6:12] += np.random.uniform(-4.0,4.0,(100,6)) + if i == 5: m[:,25:35] += np.random.uniform(3.0,5.0,(100,10)) + modes.append(m) +X_disrupt = np.vstack(modes) + np.random.normal(0, 0.25, (600, 50)) + +X_train_raw = X_healthy[:, :20] +X_test_raw = X_disrupt[:, :20] + +scaler = StandardScaler() +pca = PCA(n_components=2) +X_pca = pca.fit_transform(scaler.fit_transform(X_train_raw)) + +# === QUANTUM GENERATOR === +def make_gen(): + fm = ZZFeatureMap(2, reps=2) + ansatz = RealAmplitudes(4, reps=8) + qc = QuantumCircuit(4) + qc.compose(fm, inplace=True) + qc.compose(ansatz, inplace=True) + qc.measure_all() + + def interpret(bitstring_int): + # bitstring_int is an integer 0..15 + angle1 = 2 * np.pi * ((bitstring_int >> 2) & 3) / 4 # top 2 bits + angle2 = 2 * np.pi * (bitstring_int & 3) / 4 # bottom 2 bits + x = 7.0 * np.cos(angle1) * np.sin(angle2) + y = 7.0 * np.sin(angle1) * np.sin(angle2) + return np.array([x, y], dtype=np.float32) + + qnn = SamplerQNN( + circuit=qc, + input_params=fm.parameters, + weight_params=ansatz.parameters, + interpret=lambda x: [7.0 * np.cos(2 * np.pi * ((x >> 2) & 3) / 4), 7.0 * np.sin(2 * np.pi * (x & 3) / 4)], + output_shape=2 + ) + w = 0.02 * (2 * torch.rand(qnn.num_weights, requires_grad=True) - 1) + return TorchConnector(qnn, initial_weights=w) + +class Discriminator(torch.nn.Module): + def __init__(self): + super().__init__() + self.net = torch.nn.Sequential( + torch.nn.Linear(2, 64), torch.nn.LeakyReLU(0.2), + torch.nn.Linear(64, 32), torch.nn.LeakyReLU(0.2), + torch.nn.Linear(32, 1) + ) + def forward(self, x): return self.net(x) + +def anomaly_score(raw, disc): + x = torch.tensor(pca.transform(scaler.transform(raw.reshape(1,-1))), dtype=torch.float32) + with torch.no_grad(): + return float(torch.sigmoid(-disc(x)).item()) + +# === TRIALS === +N_TRIALS = 1 +EPOCHS = 500 +BATCH = 128 +aucs = [] + +for trial in range(N_TRIALS): + print(f"\nTRIAL {trial+1}/{N_TRIALS}") + G = make_gen() + D = Discriminator() + opt_g = Adam(G.parameters(), lr=2e-4, betas=(0.0, 0.9)) # ← FIXED: tuple of floats + opt_d = Adam(D.parameters(), lr=2e-4, betas=(0.0, 0.9)) + + d_losses = []; g_losses = [] + + for epoch in range(EPOCHS): + idx = np.random.randint(0, len(X_pca), BATCH) + real = torch.tensor(X_pca[idx], dtype=torch.float32) + + # Discriminator + opt_d.zero_grad() + d_real = D(real).mean() + fake = G(real) + d_fake = D(fake.detach()).mean() + d_loss = -d_real + d_fake + d_loss.backward() + opt_d.step() + + # Generator + opt_g.zero_grad() + g_loss = -D(G(real)).mean() + g_loss.backward() + opt_g.step() + + d_losses.append(d_loss.item()) + g_losses.append(g_loss.item()) + + if (epoch+1) % 200 == 0: + print(f" Epoch {epoch+1} | D: {d_loss.item():.4f} | G: {g_loss.item():.4f}") + + # === PLOTS === + # Training losses + plt.figure(); plt.plot(d_losses, label='D'); plt.plot(g_losses, label='G') + plt.legend(); plt.title(f'Trial {trial+1} Losses'); plt.grid(alpha=0.3) + plt.savefig(f'plots_benchmark/losses_{trial+1:02d}.png', dpi=150); plt.close() + + # Generated vs real manifold + with torch.no_grad(): + fake_samples = G(torch.tensor(X_pca[:2000])).numpy() + plt.figure(figsize=(7,6)) + plt.scatter(X_pca[:2000,0], X_pca[:2000,1], s=8, alpha=0.5, label='Real') + plt.scatter(fake_samples[:,0], fake_samples[:,1], s=8, alpha=0.5, label='Generated') + plt.legend(); plt.grid(alpha=0.3) + plt.title(f'Trial {trial+1} — Manifold Match') + plt.savefig(f'plots_benchmark/manifold_{trial+1:02d}.png', dpi=150); plt.close() + + # ROC + healthy_s = [anomaly_score(X_train_raw[i], D) for i in range(1000)] + anomaly_s = [anomaly_score(X_test_raw[i], D) for i in range(len(X_test_raw))] + y_true = np.r_[np.zeros(1000), np.ones(len(anomaly_s))] + y_pred = np.r_[healthy_s, anomaly_s] + fpr, tpr, _ = roc_curve(y_true, y_pred) + roc_auc = auc(fpr, tpr) + aucs.append(roc_auc) + print(f"Trial {trial+1} AUC: {roc_auc:.4f}") + + plt.figure(figsize=(7,6)) + plt.plot(fpr, tpr, label=f'AUC = {roc_auc:.4f}') + plt.plot([0,1],[0,1],'k--') + plt.legend(); plt.grid(alpha=0.3) + plt.title(f'ROC Trial {trial+1}') + plt.savefig(f'plots_benchmark/ROC_{trial+1:02d}.png', dpi=150); plt.close() + +print(f"\nFINAL QGAN AUC: {np.mean(aucs):.4f} ± {np.std(aucs):.4f}") \ No newline at end of file diff --git a/Phase 1/main_fusion_cgan.py b/Phase 1/main_fusion_cgan.py new file mode 100644 index 0000000000000000000000000000000000000000..b6acb675194c44f0e7b1d1e8d44851bf95b17e67 --- /dev/null +++ b/Phase 1/main_fusion_cgan.py @@ -0,0 +1,245 @@ +# --- STEP 0: IMPORT AND SET "HEADLESS" MODE --- +import matplotlib +matplotlib.use('Agg') # <--!! NEW: Use "headless" backend, no pop-ups +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import os # <-- NEW: To create plot directory +from sklearn.preprocessing import StandardScaler +from sklearn.decomposition import PCA +from sklearn.metrics import roc_curve, auc +import torch +import torch.nn as nn +from torch.optim import Adam +# --- NO QISKIT IMPORTS NEEDED --- + +print("All libraries imported. Matplotlib is in 'Agg' (headless) mode.") + +# --- NEW: Check for plots directory --- +if not os.path.exists('plots'): + os.makedirs('plots') + print("Created 'plots/' directory.") +else: + print("Plots will be saved to 'plots/' directory.") + +# --- STEP 2: CREATE SIMULATED TOKAMAK DATA --- +# (This is now OUTSIDE the loop. We create ONE dataset) +def get_simulated_tokamak_data(n_features=50, healthy_samples=5000, anomalous_samples=500): + print(f"Generating 1 static dataset of {healthy_samples} healthy and {anomalous_samples} anomalous data points...") + healthy_mean = np.zeros(n_features) + healthy_cov = np.diag(np.ones(n_features)) + X_healthy = np.random.multivariate_normal(healthy_mean, healthy_cov, healthy_samples) + anomalous_mean = np.ones(n_features) * 2.5 + anomalous_cov = np.diag(np.ones(n_features) * 0.5) + X_anomalous = np.random.multivariate_normal(anomalous_mean, anomalous_cov, anomalous_samples) + + df_healthy = pd.DataFrame(X_healthy, columns=[f'sensor_{i}' for i in range(n_features)]) + df_healthy['label'] = 0 + df_anomalous = pd.DataFrame(X_anomalous, columns=[f'sensor_{i}' for i in range(n_features)]) + df_anomalous['label'] = 1 + + df_total = pd.concat([df_healthy, df_anomalous], ignore_index=True) + print("Simulated data generation complete.") + return df_total + +simulated_data = get_simulated_tokamak_data() + +# --- STEP 3: THE DATA PIPELINE --- +# (This is also OUTSIDE the loop. We process the data ONCE) +print("\nStarting data pipeline (running once)...") +X_train_healthy = simulated_data[simulated_data['label'] == 0].drop('label', axis=1) +X_test_anomalous = simulated_data[simulated_data['label'] == 1].drop('label', axis=1) +scaler = StandardScaler() +X_scaled = scaler.fit_transform(X_train_healthy) +N_DIM = 2 +pca = PCA(n_components=N_DIM) +X_pca = pca.fit_transform(X_scaled) +bins_per_dim = 4 +num_qubits = 4 +real_distribution_hist, x_edges, y_edges = np.histogram2d( + X_pca[:, 0], X_pca[:, 1], bins=bins_per_dim, density=True +) +real_distribution = real_distribution_hist.flatten() +real_distribution = real_distribution / np.sum(real_distribution) +x_centers = (x_edges[:-1] + x_edges[1:]) / 2 +y_centers = (y_edges[:-1] + y_edges[1:]) / 2 +grid_samples = np.array(np.meshgrid(x_centers, y_centers)).T.reshape(-1, N_DIM) +print("Data pipeline complete. Target distribution created.") + +# --- Convert data to Tensors (ONCE) --- +real_data_dist = torch.tensor(real_distribution, dtype=torch.float32).reshape(-1, 1) +data_samples = torch.tensor(grid_samples, dtype=torch.float32) +valid = torch.ones(real_data_dist.shape, dtype=torch.float32) +fake = torch.zeros(real_data_dist.shape, dtype=torch.float32) + +# --- (Helper Function for Adversarial Loss) --- +def adversarial_loss(input, target, w): + bce_loss = target * torch.log(input) + (1 - target) * torch.log(1 - input) + weighted_loss = w * bce_loss + total_loss = -torch.sum(weighted_loss) + return total_loss + +# --- (Helper Function for Anomaly Detection) --- +def detect_anomaly(new_sensor_reading, scaler_obj, pca_obj, discriminator_model): + x_scaled = scaler_obj.transform(new_sensor_reading.reshape(1, -1)) + x_pca = pca_obj.transform(x_scaled) + x_tensor = torch.tensor(x_pca, dtype=torch.float32) + discriminator_model.eval() + with torch.no_grad(): + anomaly_score = discriminator_model(x_tensor) + return anomaly_score.item() + +# --- STEP 4-7: MAIN TRIAL LOOP --- +N_TRIALS = 50 +num_epochs = 500 +cgan_auc_scores = [] # <-- Renamed + +for trial in range(N_TRIALS): + print(f"\n--- CGAN TRIAL {trial+1}/{N_TRIALS} ---") # <-- Renamed + + # --- STEP 4: ARCHITECT THE CGAN --- + + # 4a. The Classical Generator (G) + class ClassicalGenerator(nn.Module): + def __init__(self, output_size=16): + super(ClassicalGenerator, self).__init__() + # A single trainable vector of 16 numbers + self.logits = nn.Parameter(torch.randn(1, output_size)) + def forward(self): + # Softmax turns the 16 numbers into a valid probability distribution + return torch.softmax(self.logits, dim=1) + + generator = ClassicalGenerator(output_size=num_qubits**N_DIM) + + # 4b. The Classical Discriminator (D) + class Discriminator(nn.Module): + def __init__(self, input_size): + super(Discriminator, self).__init__() + self.linear_input = nn.Linear(input_size, 20) + self.leaky_relu = nn.LeakyReLU(0.2) + self.linear20 = nn.Linear(20, 1) + self.sigmoid = nn.Sigmoid() + def forward(self, input: torch.Tensor) -> torch.Tensor: + x = self.linear_input(input) + x = self.leaky_relu(x) + x = self.linear20(x) + x = self.sigmoid(x) + return x + discriminator = Discriminator(input_size=N_DIM) + + # --- STEP 5: DEFINE TRAINING COMPONENTS --- + # We use a stable, equal learning rate for the C-GAN + lr = 0.005 + b1 = 0.7 + b2 = 0.999 + generator_optimizer = Adam(generator.parameters(), lr=lr, betas=(b1, b2)) + discriminator_optimizer = Adam(discriminator.parameters(), lr=lr, betas=(b1, b2)) + + g_losses = [] + d_losses = [] + rel_ents = [] + + # --- STEP 6: RUN THE TRAINING LOOP --- + print(f"Starting training for {num_epochs} epochs...") + for epoch in range(num_epochs): + # Train Discriminator + discriminator_optimizer.zero_grad() + disc_scores = discriminator(data_samples) + gen_dist = generator().reshape(-1, 1) # <-- Fixed: generator() has no input + real_loss = adversarial_loss(disc_scores, valid, real_data_dist) + fake_loss = adversarial_loss(disc_scores, fake, gen_dist.detach()) + discriminator_loss = (real_loss + fake_loss) / 2 + discriminator_loss.backward() + discriminator_optimizer.step() + # Train Generator + generator_optimizer.zero_grad() + gen_dist = generator().reshape(-1, 1) # <-- Fixed: generator() has no input + disc_scores = discriminator(data_samples) + generator_loss = adversarial_loss(disc_scores, valid, gen_dist) + generator_loss.backward() + generator_optimizer.step() + # Log Progress + if (epoch + 1) % 100 == 0: + g_losses.append(generator_loss.item()) + d_losses.append(discriminator_loss.item()) + gen_dist_np = gen_dist.detach().numpy().flatten() + real_dist_np = real_distribution.flatten() + rel_ent = np.sum(real_dist_np * np.log((real_dist_np + 1e-9) / (gen_dist_np + 1e-9))) + rel_ents.append(rel_ent) + + print(f"Trial {trial+1} training complete.") + + # --- Plot Training Progress (NO SHOW) --- + fig_train, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5)) + fig_train.suptitle(f"CGAN Training Progress (Trial {trial+1})") # <-- Renamed + ax1.plot(g_losses, label='Generator Loss') + ax1.plot(d_losses, label='Discriminator Loss') + ax1.set_title("Adversarial Losses") + ax1.set_xlabel("Epoch (x100)"); ax1.set_ylabel("Loss"); ax1.legend() + ax2.plot(rel_ents, label='Relative Entropy', color='green') + ax2.set_title("Relative Entropy (G vs. Real)") + ax2.set_xlabel("Epoch (x100)"); ax2.set_ylabel("Entropy"); ax2.legend() + + plt.savefig(f'plots/CGAN_Trial_{trial+1}_TrainingProgress.png') # <-- Renamed + plt.close(fig_train) + + # --- STEP 7: DEPLOYMENT AND VALIDATION--- + print(f"Running validation for Trial {trial+1}...") + healthy_scores = [] + for i in range(min(1000, len(X_train_healthy))): + sample = X_train_healthy.iloc[i].values + score = detect_anomaly(sample, scaler, pca, discriminator) + healthy_scores.append(score) + + anomalous_scores = [] + for i in range(len(X_test_anomalous)): + sample = X_test_anomalous.iloc[i].values + score = detect_anomaly(sample, scaler, pca, discriminator) + anomalous_scores.append(score) + + # --- Visualize the Results: Histogram (NO SHOW) --- + fig_hist, ax_hist = plt.subplots(figsize=(10, 6)) + ax_hist.hist(healthy_scores, bins=50, alpha=0.7, label='Healthy Scores (Trained On)', density=True, color='blue') + ax_hist.hist(anomalous_scores, bins=50, alpha=0.7, label='Anomalous Scores (NEVER Seen Before)', density=True, color='red') + ax_hist.set_title(f"CGAN-AD Score Distributions (Trial {trial+1})") # <-- Renamed + ax_hist.set_xlabel("Anomaly Score (1.0 = Real/Healthy, 0.0 = Fake/Anomalous)") + ax_hist.set_ylabel("Probability Density"); ax_hist.legend() + + plt.savefig(f'plots/CGAN_Trial_{trial+1}_Histogram.png') # <-- Renamed + plt.close(fig_hist) + + # --- The "Money Plot": The ROC Curve (NO SHOW) --- + y_true_healthy = np.zeros(len(healthy_scores)) + y_true_anomalous = np.ones(len(anomalous_scores)) + y_true = np.concatenate([y_true_healthy, y_true_anomalous]) + y_scores = np.concatenate([healthy_scores, anomalous_scores]) + fpr, tpr, _ = roc_curve(y_true, 1 - np.array(y_scores)) + roc_auc = auc(fpr, tpr) + + cgan_auc_scores.append(roc_auc) # <-- Renamed + + fig_roc, ax_roc = plt.subplots(figsize=(10, 8)) + ax_roc.plot(fpr, tpr, color='darkorange', lw=2, label=f'ROC curve (AUC = {roc_auc:.4f})') + ax_roc.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--') + ax_roc.set_xlim([0.0, 1.0]); ax_roc.set_ylim([0.0, 1.05]) + ax_roc.set_xlabel('False Positive Rate'); ax_roc.set_ylabel('True Positive Rate') + ax_roc.set_title(f'CGAN-AD ROC Curve (Trial {trial+1})'); ax_roc.legend(loc="lower right") # <-- Renamed + + plt.savefig(f'plots/CGAN_Trial_{trial+1}_ROC.png') # <-- Renamed + plt.close(fig_roc) + + print(f"Trial {trial+1} complete. AUC: {roc_auc:.4f}") + +# --- FINAL RESULTS --- +print("\n" + "="*30) +print("--- FINAL CGAN RESULTS ---") # <-- Renamed +print(f"Scores over {N_TRIALS} trials:") +print([round(score, 4) for score in cgan_auc_scores]) # <-- Renamed +print(f"\nAverage CGAN AUC: {np.mean(cgan_auc_scores):.4f}") # <-- Renamed +print(f"Standard Deviation: {np.std(cgan_auc_scores):.4f}") # <-- Renamed +print(f"Max AUC (Best Run): {np.max(cgan_auc_scores):.4f}") # <-- Renamed +print(f"Min AUC (Worst Run): {np.min(cgan_auc_scores):.4f}") # <-- Renamed +print(f"\nAll {N_TRIALS*3} plots saved to 'plots/' directory.") +print("="*30) + +print("\n--- ACTION PLAN COMPLETE ---") \ No newline at end of file diff --git a/Phase 1/plots_benchmark/CGAN_Trial_10_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_10_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..9a354947a72cf0b688bf1aedac9b4968c4f1e416 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_10_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_11_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_11_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..87865d4b67c4f5747977d3531d85beff094232fd Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_11_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_11_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_11_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..5ec40883f01cab8935ecfc42d83d4321c3d11694 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_11_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_12_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_12_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..9553c83540f339f6a5f89063f790762ab01e6315 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_12_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_12_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_12_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..52f5fe129c9a2f9c7c3485fd20ecaa4b62f78c3b Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_12_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_12_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_12_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..5c1a9a83d011ad3a37b6fc9887924cbe229a02f4 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_12_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_13_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_13_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..bc75414714d335f49a1e1473d1f4526a71af4c41 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_13_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_13_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_13_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..1cf108a4cb03b3b3b9bac14042ef20858a0dd743 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_13_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_14_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_14_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..074cf24cbc118b0b3334abfe7b5b723c2bacdf27 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_14_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_16_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_16_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..adf2602ee2c25943ed902f84a6aa73b53cb82cd3 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_16_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_17_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_17_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..57544a48babbbf38bc81e578da5030a53713f5c4 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_17_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_17_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_17_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..0b98c52a4a11bde17504ca0dc6c75131b4b80190 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_17_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_17_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_17_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..1c7ac261ae52998540af831a7f8850affe5b3340 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_17_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_18_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_18_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..30c26fb37e43e23e02d4a1f331c3eb5b4f0410b5 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_18_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_18_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_18_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..feab5a27c15ccd94c85ee3cf779526e2659804a4 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_18_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_1_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_1_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..569342b36b9ad040830439cfa94a928cd7e75d89 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_1_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_1_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_1_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..4049b593fa5a3a2b925a55cde65dc2eb0c6eb9f6 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_1_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_20_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_20_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..00bf12ce15f0b9521dc0ca1abb7dc6790daab3dd Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_20_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_20_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_20_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..43d47d21116fed9e03e624651066b85ee1665fed Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_20_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_2_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_2_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..9ad89d577ec825f3c46c7c12e6d8cf45ae293ec3 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_2_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_2_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_2_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..06dc65b2f4a3caf7f57225eec7fceadabb00fb87 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_2_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_3_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_3_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..248c276fa06f952763df2e908a86b55e0676c15e Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_3_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_4_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_4_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..869c5f5afc82a4a7c9710baede0f731b9db0c851 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_4_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_5_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_5_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..c61cdc83c7589c43d5eea1dfad47f0242ad8351b Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_5_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_6_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_6_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..ec9c4d931a1c3f5cd2c2b7274c632ef3dcaa324a Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_6_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_6_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_6_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..8cbdcabd003fd3a544275e1cba599c6ae602989a Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_6_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_7_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_7_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..2c113d901b993929adceb6111aade68dd1f188e6 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_7_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_8_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_8_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..28f8db712ebbee40e965e70b8868c6a00550de08 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_8_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_8_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_8_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..c9297535844dc0be6c0608370b28ee3e7137b656 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_8_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_9_Histogram.png b/Phase 1/plots_benchmark/CGAN_Trial_9_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..6d58e56eab041cf5766bbef71c3aae1ed30f6cc6 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_9_Histogram.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_9_ROC.png b/Phase 1/plots_benchmark/CGAN_Trial_9_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..5358cb09d6cdcfddcfdeae1374193b5231bd0c03 Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_9_ROC.png differ diff --git a/Phase 1/plots_benchmark/CGAN_Trial_9_TrainingProgress.png b/Phase 1/plots_benchmark/CGAN_Trial_9_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..87d5bb9fe29d528ed9120d2c18008c21ccb2c7de Binary files /dev/null and b/Phase 1/plots_benchmark/CGAN_Trial_9_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_STABLE_Trial_2_ROC.png b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_2_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..5783758071a515890ab15fd81b313a7d0d15a52a Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_2_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_STABLE_Trial_4_ROC.png b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_4_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..6a338fcc54ed3c51f62dfb23d8a6a0874694e0eb Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_4_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_STABLE_Trial_6_ROC.png b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_6_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..39363ca641e229395972dc3edafd895955235866 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_6_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_STABLE_Trial_7_ROC.png b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_7_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..65228ed2126145b763365b767806ee4938aa4cf1 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_STABLE_Trial_7_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_10_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_10_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..dc5342be07e8bbb58ae5cbccc3a90b3c79d4cb7d Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_10_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_11_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_11_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..dfc9b7f189bcd6135a5b3dd5d4d8b218f849e9af Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_11_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_11_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_11_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..6fd352dd4e106eb0611633fc529a14c8881f7c7f Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_11_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_12_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_12_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..439c705ffc0c66af356f1eed63c0fac1742df956 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_12_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_12_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_12_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..3defb4c590102a505dd84d6287bc0a0a0ca304e8 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_12_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_13_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_13_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..58c7b7b5e799573438fe3727342776a6ad73537c Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_13_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_13_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_13_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..73b50c9abcb3e4630b3dba89d1279189929c4833 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_13_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_14_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_14_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..4f344944549559c8ea683df00043716d89d0cdc3 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_14_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_15_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_15_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..75e01b478a8d61fc5d4735bce22e85eb5c93c378 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_15_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_15_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_15_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..7ddaa61008e79eb54a660b08b60f1297b43aa812 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_15_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_16_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_16_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..50acb8412d4ac4712d84a1b1d0668bce56916fb5 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_16_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_17_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_17_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..9fa8bc88ad42a299a7ae8588d58db3d46a344a79 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_17_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_17_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_17_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..e179f0bf8c442e6df5ffbc7dea7051aadaef4f8f Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_17_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_1_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_1_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..456735d632f939abf5a109df3b174b5f4a76f53f Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_1_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_1_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_1_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..6d6ccc20b4d68252eba2b4f32b69da3a08fd60b4 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_1_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_2_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_2_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..81b4dde8fbbb93741571cb79a20640e34c7f0360 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_2_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_3_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_3_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..85df68dad4b5f741fa2842a6be94cff8828263cb Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_3_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_4_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_4_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..9e7f1e7e01eea2354a8f2668ba7c295fb14bee3c Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_4_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_4_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_4_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..a7de8c8d88799e3e0a4163e6d5a1bc2681d4b4b2 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_4_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_5_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_5_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..08bcd13b03398f252be1c98e8b969a1b9d05f09f Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_5_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_5_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_5_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..917745172a8e7991e7babacc6e0c0fbf38a5ecc4 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_5_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_7_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_7_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..669ab95ba965bb46bd6b4c987582f5ca00979903 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_7_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_8_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_8_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..957d6b20a137624580624b40c0fa5db3cf02dfe8 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_8_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_8_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_8_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..52179ff1817292e55fe9d80849cad6f06599fc81 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_8_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_8_TrainingProgress.png b/Phase 1/plots_benchmark/QGAN_Trial_8_TrainingProgress.png new file mode 100644 index 0000000000000000000000000000000000000000..8f93fae1a03bd07a17803321d429a2e32b30c920 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_8_TrainingProgress.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_9_Histogram.png b/Phase 1/plots_benchmark/QGAN_Trial_9_Histogram.png new file mode 100644 index 0000000000000000000000000000000000000000..f488d2b0245c06c84c10dbe2be8579799647911d Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_9_Histogram.png differ diff --git a/Phase 1/plots_benchmark/QGAN_Trial_9_ROC.png b/Phase 1/plots_benchmark/QGAN_Trial_9_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..0be2366c0dc8b317e303324cfd5a8d5b5280b2c6 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_Trial_9_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_12_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_12_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..b58064aaae4b8ed4451cb3935c02808fd8442513 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_12_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_14_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_14_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..07ffc4ae8c7b87a8fce8dc90d68b08bd39c0c436 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_14_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_16_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_16_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..ec2d50aae174cb1fa15ea44e1fba0b83cc218dc6 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_16_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_17_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_17_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..33e57a765213ceac1b7c0946934c9d8cf6a2142a Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_17_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_2_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_2_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..da1d472fe243d07f8cf4c57e3ac97a751f9b7a67 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_2_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_4_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_4_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..cc643fa925e33ce966325bd295a167ae87dff15f Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_4_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_6_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_6_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..27d51fb92b38b3f6e77cc3cc7e9c652d78eecb88 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_6_ROC.png differ diff --git a/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_7_ROC.png b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_7_ROC.png new file mode 100644 index 0000000000000000000000000000000000000000..6709d70bbbb6f0d05ab0c68f564c6b085c606713 Binary files /dev/null and b/Phase 1/plots_benchmark/QGAN_UPGRADED_Trial_7_ROC.png differ diff --git a/v2_pipeline_output/real_data_topology_v3.png b/v2_pipeline_output/real_data_topology_v3.png new file mode 100644 index 0000000000000000000000000000000000000000..5480840a82df329422cdc20b8935b011a76feaf9 Binary files /dev/null and b/v2_pipeline_output/real_data_topology_v3.png differ