kaggle-optimal-blending

kaggle-optimal-blending is a skill for Claude Code, Codex from topprismdata/cultivating-ml-agent. It costs 161 tokens per session (1,471 once invoked), scanned A, original, MIT.

A method for combining original similarity scores with scores that have been reordered using nearby-item relationships in Kaggle machine-learning competitions. It recommends giving more weight to the reordered scores while keeping some original scores.

In plain words
What is it for?
Use it to combine raw and reordered similarity matrices in image re-identification, search, or recommendation tasks, and to tune the balance when an ensemble or re-ranking approach has stopped improving.
Why use it?
It helps when reordering results alone loses useful information, or when averaging several models equally fails to improve the score. The blend keeps both local relationships and broader similarities.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to combine raw and reordered similarity matrices in image re-identification, search, or recommendation tasks, and to tune the balance when an ensemble or re-ranking approach has stopped improving.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/topprismdata/cultivating-ml-agent/kaggle-optimal-blending
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add topprismdata/cultivating-ml-agent --skill kaggle-optimal-blending
Clone the repo
git clone --depth 1 https://github.com/topprismdata/cultivating-ml-agent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for kaggle-optimal-blending

README.md
[![agentmods](https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/kaggle-optimal-blending/github.svg)](https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/kaggle-optimal-blending)
Your own site
<a href="https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/kaggle-optimal-blending"><img src="https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/kaggle-optimal-blending/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for kaggle-optimal-blending

Your own site · 80×15
<a href="https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/kaggle-optimal-blending"><img src="https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/kaggle-optimal-blending.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 161 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,471 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00161 $0.01471
Opus 5 $0.00081 $0.00736
Sonnet 5 $0.00032 $0.00294
Haiku 4.5 $0.00016 $0.00147

Measured 11d ago against content hash 5db2a37e384a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

kaggle-optimal-blending scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/examples/kaggle-optimal-blending/SKILL.md · 186 lines

How it starts

The opening of the file, as written. The whole thing — 186 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Kaggle Optimal Blending: The 80/20 Rule

Problem

Re-ranking (k-reciprocal, Jaccard, etc.) is powerful but using 100% re-ranked results can lose valuable signal diversity. Equal-weight blending often underperforms.

Context / Trigger Conditions

Use when:

  • Implementing post-processing for Re-ID, retrieval, or recommendation tasks
  • Re-ranking alone doesn't give expected boost
  • Ensemble of multiple models shows little improvement
  • Kaggle score plateaus despite strong individual models

Solution

The 80/20 Optimal Blending Rule

Key insight from 0.938 mAP solution (Jaguar Re-ID):

blend_raw_ratio = 0.20  # 20% raw, 80% re-ranked

final_similarity = (
    (1 - blend_raw_ratio) * rerank_score +
    blend_raw_ratio * raw_score
)

Why 80/20?

  • 80% re-ranking: Captures neighborhood structure, removes false positives
  • 20% raw: Preserves genuine long-range similarities, maintains diversity
  • This ratio emerged as optimal through experimentation (0.938 mAP)

Implementation

import numpy as np

def optimal_blend(similarity_matrix, reranked_matrix, raw_ratio=0.20):
    """
    Blend re-ranked and raw similarity matrices

    Args:
        similarity_matrix: Original NxM similarity matrix
        reranked_matrix: Re-ranked version (k-reciprocal, etc.)
        raw_ratio: Weight for raw score (default 0.20)

    Returns:
        Blended similarity matrix
    """
    return (1 - raw_ratio) * reranked_matrix + raw_ratio * similarity_matrix

Re-Ranking Parameters (Optimized for 0.938 mAP)

# k-Reciprocal Re-ranking parameters
k1 = 20   # First k for reciprocal neighbors
k2 = 6    # Second k for final re-ranking
lambda_param = 0.2  # Jaccard weight

Complete Post-Processing Pipeline

def post_process_for_reid(query_features, gallery_features):
    """
    Complete post-processing: TTA + QE + Re-ranking + Optimal Blend
    """
    # 1. TTA (Test Time Augmentation)
    # query_features = (f_original + f_flipped) / 2

    # 2. Query Expansion (optional)
    # Expand with top-k gallery samples
    qe_top_k = 3

    # 3. Compute raw similarities
    raw_sim = cosine_similarity(query_features, gallery_features)

    # 4. Re-ranking (k-reciprocal)
    reranked_sim = k_reciprocal_reranking(
        raw_sim,
        k1=k1,
        k2=k2,
        lambda_param=lambda_param
    )

    # 5. Optimal blending (THE KEY!)
    final_sim = optimal_blend(
        raw_sim,
        reranked_sim,
        raw_ratio=0.20  # Don't use 0.0 or 0.5!
    )

    return final_sim

Read the full file on GitHub · 186 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 186 lines · 161 tokens per session scan A 5db2a37e384a

Subscribe to this mod's changes

kaggle-optimal-blending is a skill published in the GitHub repository topprismdata/cultivating-ml-agent (5 stars, last pushed 13d ago), licensed MIT. It adds 161 tokens to every session and 1,471 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

huggingface-hub

Hugging Face Hub CLI (hf) — search, download, and upload models and datasets, manage repos, query datasets with SQL, deploy inference endpoints, manage Spaces and buckets.

braxtonROSE4/zorro-agent · 43 tokens

tensorboard

Visualize training metrics, debug models with histograms, compare experiments, visualize model graphs, and profile performance with TensorBoard - Google's ML visualization toolkit.

davila7/claude-code-templates · 32 tokens

mlflow

Track ML experiments, manage model registry with versioning, deploy models to production, and reproduce experiments with MLflow - framework-agnostic ML lifecycle platform.

davila7/claude-code-templates · 33 tokens

datachain-knowledge

Use whenever datasets, cloud storage buckets, or data pipelines are mentioned — creating, saving, querying, listing, exploring, deleting, or processing data in S3, GCS, Azure Blob, or local storage. Also use when running any script that may create datasets as a side effect. Maintains a knowledge base at dc-knowledge/…

datachain-ai/datachain · 104 tokens

prompt-scanner

A scanner for text sent to an AI agent, looking for prompt injection and jailbreak attempts. Prompt injection is text that tries to override an agent's instructions; a jailbreak tries to bypass its safety limits.

alibaba/anolisa · 103 tokens

install-openviking-memory

Install and configure the OpenViking long-term memory plugin for OpenClaw via natural conversation. Once installed, the plugin automatically captures facts from chats and recalls relevant context before each reply (auto-capture + auto-recall, cross-session). Covers prerequisites, install through OpenClaw's plugin…

volcengine/OpenViking · 191 tokens