Rank averaging ensemble

From wenmin-wu/ds-skills · View interactive version

Rank averaging ensemble is an AI agent skill from the GitHub repository wenmin-wu/ds-skills. Ensembles multiple model predictions by converting to ranks, averaging, and normalizing back to [0,1].

How to use this skill

Skill file

Rank Averaging Ensemble

Overview

Combine predictions from multiple models by converting each to ranks, averaging the ranks, then normalizing to [0,1]. This is robust to different prediction scales and distributions across models, making it ideal when blending heterogeneous model families.

Quick Start

import numpy as np
from scipy.stats import rankdata

def rank_average(predictions_list):
    """Ensemble by rank averaging.

    Args:
        predictions_list: list of arrays, each shape (n_samples,)

    Returns:
        array of shape (n_samples,) with averaged ranks normalized to [0,1]
    """
    ranks = np.column_stack([
        rankdata(preds) for preds in predictions_list
    ])
    avg_ranks = ranks.mean(axis=1)
    return (avg_ranks - avg_ranks.min()) / (avg_ranks.max() - avg_ranks.min())

Workflow

  1. Generate predictions from each model on the same test set
  2. Convert each prediction vector to ranks via scipy.stats.rankdata
  3. Average ranks across models (optionally with weights)
  4. Normalize averaged ranks to [0, 1] via min-max scaling
  5. Use as final submission or feed into calibration

Key Decisions

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.