Conversation
…batch type hint Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
… for reproducibility Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Integrate K-fold cross-validation into multitask training pipeline
Add multitask training pipeline with K-fold cross-validation
Feb 8, 2026
Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
…sertion Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Copilot
AI
changed the title
Add multitask training pipeline with K-fold cross-validation
Add patient-preds.csv output to multitask cross-validation folds
Feb 8, 2026
…et names Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Copilot
AI
changed the title
Add patient-preds.csv output to multitask cross-validation folds
Integrate multitask attention-MIL training with K-fold cross-validation
Feb 8, 2026
…ets) Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Copilot
AI
changed the title
Integrate multitask attention-MIL training with K-fold cross-validation
Multitask attention-MIL training with K-fold cross-validation
Feb 8, 2026
Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Copilot
AI
changed the title
Multitask attention-MIL training with K-fold cross-validation
Add multitask attention-MIL training with K-fold cross-validation
Feb 8, 2026
Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Copilot
AI
changed the title
Add multitask attention-MIL training with K-fold cross-validation
Add multitask attention-MIL training with K-fold cross-validation and binary evaluation helpers
Feb 8, 2026
Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
…k_scores param Co-authored-by: drgmo <65294284+drgmo@users.noreply.github.com>
Copilot
AI
changed the title
Add multitask attention-MIL training with K-fold cross-validation and binary evaluation helpers
Add multitask attention-MIL training with K-fold cross-validation, binary evaluation helpers, and survival risk stratification
Feb 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds three major capabilities: (1) a multitask regression pipeline with optional K-fold CV, (2) helpers to evaluate regression models as binary classifiers without retraining, and (3) survival risk scoring and stratification via Cox PH.
Multitask training (
src/stamp/modeling/multitask.py)LitAttnMILMultiTask— shared AttnMIL backbone → N independent regression heads, configurable MSE/Huber loss with per-head weightingMultitaskDataset— patient-level dataset accepting arbitrary number of targets viatarget_labels: dict[str, int]train_multitask_()/crossval_multitask_()— single split orGroupKFoldby patient ID with deterministic per-fold seedspatient-preds.csvwith{target}_true/{target}_predcolumns_build_patient_feature_map()— resolves feature files by FILENAME→PATIENT mapping when files are in subdirectories or named differently from patient IDsstamp --config <yaml> train_multitaskBinary evaluation from regression (
src/stamp/statistics/binary_from_regression.py)Wraps existing inference output to evaluate as a binary classifier — no retraining needed.
binarize_labels()— handles"pos"/"neg",True/False,0/1→{0, 1}extract_score()— scalar, dict, tuple, 2-D array model outputspostprocess_score()— identity / sigmoid / callable, clip to [0,1]aggregate_patient_scores()— multi-image → patient-levelget_thresholds()— Youden, mean, median, fixed, quantile strategiesevaluate_thresholds()→(summary_df, preds_df)with accuracy, F1, AUROC, sensitivity, specificitySurvival risk stratification (
src/stamp/statistics/survival_risk.py)Cox-on-top-of-score approach using lifelines (already a dependency).
fit_cox_model()— CoxPH on score + optional clinical covariates →CoxResultwith risk scores and C-indexget_survival_thresholds()— median, mean, max log-rank (searches candidate cutpoints excluding <10%/>90% quantiles), fixedassign_risk_groups()— dichotomize intohigh_risk/low_risk(or custom labels likeHRDpos/HRDneg)evaluate_survival_stratification()— C-index, log-rank p per threshold strategyplot_km_by_group()— KM curves with at-risk counts and annotationBeartype fix
LitSlideRegressor._step:batch: tuple[Tensor, Tensor]→batch: tuple[Tensor, ...] | list[Tensor]— DataLoader returns lists.Config
MultitaskTrainingConfig/MultitaskCrossvalConfiginmodeling/config.py, wired intoStampConfig.multitask_training. CV disabled by default — existing runs unaffected.Tests
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.