import React, { useState } from 'react'; import { EpiADRHyperparameters, ModelTrainingSummary } from '../types'; import { ResponsiveContainer, LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts'; import { Play, Square, RotateCcw, Cpu, Sliders, CheckCircle2, ShieldAlert, Sparkles, Activity } from 'lucide-react'; interface ModelTrainerPanelProps { hyperparams: EpiADRHyperparameters; onChangeHyperparams: (params: EpiADRHyperparameters) => void; isTraining: boolean; onStartTraining: () => void; onStopTraining: () => void; trainingSummary: ModelTrainingSummary | null; useTissueConditioning: boolean; } export const ModelTrainerPanel: React.FC = ({ hyperparams, onChangeHyperparams, isTraining, onStartTraining, onStopTraining, trainingSummary, useTissueConditioning }) => { return (
{/* Top Banner */}
EpiADR-Net Foundation Model Training Studio

Model Training & Hyperparameter Tuning

Train Graph Transformer with 16-Head Bi-Directional Gene Pathway Cross-Attention on SIDER 4.1 & GTEx V8 dataset.

{/* Action Buttons */}
{!isTraining ? ( ) : ( )}
{/* Left Column: Hyperparameters Panel */}

Hyperparameters & Loss Tuning

{/* Tissue Conditioning Toggle */}

Disabling tissue conditioning tests the molecule-only baseline scientific control.

{/* Cross-Attention Heads */}
Cross-Attention Heads {hyperparams.crossAttentionHeads} Heads
{/* Learning Rate & Epochs */}
Epochs {hyperparams.epochs}
onChangeHyperparams({ ...hyperparams, epochs: parseInt(e.target.value) })} className="w-full accent-indigo-500 cursor-pointer h-1.5 bg-slate-800 rounded-lg" />
Learning Rate {hyperparams.learningRate}
{/* Pos Weight Loss Class Imbalance */}
Class Imbalance Weight (pos_weight) {hyperparams.posWeight}x
onChangeHyperparams({ ...hyperparams, posWeight: parseFloat(e.target.value) })} className="w-full accent-indigo-500 cursor-pointer h-1.5 bg-slate-800 rounded-lg" />

Balances rare positive toxicity labels in SIDER 4.1.

{/* Monte Carlo Uncertainty Passes */}
MC Dropout Passes (N) N={hyperparams.mcDropoutPasses}
{/* Right Column: Training Progress & Metrics Chart */}
{/* Epoch Metrics Chart */}

Live Training Curves (Loss & Val AUROC)

{isTraining && ( Training in Progress... )}
{trainingSummary && trainingSummary.epochHistory.length > 0 ? (
) : (

Click "Train Model" to start training session.

)}
{/* Final Metrics Cards */} {trainingSummary && (
Val AUROC {trainingSummary.finalValAUROC}%
F1 Macro Score {trainingSummary.finalF1Score}
Final Val Loss {trainingSummary.finalValLoss}
Training Time {trainingSummary.trainingTimeMs}ms
)}
); };