Skip to content
Back to skills

Per Modality Ensemble Averaging

ASecurity

Train separate models per imaging modality (FLAIR/T1w/T1wCE/T2w) and average their predictions for final ensemble

  • 61 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 12, 2026
code-qualitypython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill per-modality-ensemble-averaging --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Per Modality Ensemble Averaging?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Per Modality Ensemble Averaging
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-per-modality-ensemble-averaging/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-per-modality-ensemble-averaging)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cv-per-modality-ensemble-averaging
description: Train separate models per imaging modality (FLAIR/T1w/T1wCE/T2w) and average their predictions for final ensemble
---

# Per-Modality Ensemble Averaging

## Overview

Multi-modal medical imaging (MRI sequences, CT windows) captures complementary information. Rather than concatenating modalities into a single multi-channel input, train an independent model per modality and average their sigmoid/softmax outputs at inference. This avoids missing-modality issues and lets each model specialize, often outperforming multi-channel approaches when modality quality varies.

## Quick Start

```python
import numpy as np
from sklearn.metrics import roc_auc_score

def train_per_modality(train_df, val_df, modalities, train_fn, predict_fn):
    """Train one model per modality, return ensemble predictions."""
    models = {}
    for mod in modalities:
        models[mod] = train_fn(train_df, val_df, modality=mod)

    val_preds = np.zeros(len(val_df))
    for mod in modalities:
        val_preds += predict_fn(models[mod], val_df, modality=mod)
    val_preds /= len(modalities)

    auc = roc_auc_score(val_df['label'], val_preds)
    return models, auc

modalities = ['FLAIR', 'T1w', 'T1wCE', 'T2w']
models, auc = train_per_modality(df_train, df_val, modalities, train_fn, predict_fn)
```

## Workflow

1. Identify available imaging modalities per patient
2. Train one model per modality using modality-specific data
3. At inference, run each model on its corresponding modality
4. Average predictions across all modalities
5. Handle missing modalities by averaging only available ones

## Key Decisions

- **Equal weighting**: simple average works well; learned weights add complexity for marginal gain
- **Missing modalities**: average over available ones only, don't zero-fill
- **vs multi-channel**: ensemble is more robust when some modalities have quality issues
- **Model architecture**: same architecture per modality, but weights are independent

## References

- [Efficientnet3D with one MRI type](https://www.kaggle.com/code/rluethy/efficientnet3d-with-one-mri-type)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.