Skip to main content

limen.cohort

Inference-time cohort surfaces for aggregating decoder outputs from completed Limen experiments.

Canonical docs

What this package owns

This package owns the cohort-level inference surface:

  1. Cohort for direct multi-member aggregation from one experiment and selected permutations
  2. single-file cohort (sfc) strategies for choosing those permutations from experiment artifacts

It does not own:

  • experiment search execution (owned by limen.experiment)
  • raw market data infrastructure
  • downstream decisioning/execution logic (outside Limen)

Key entry points

Entry pointUse caseNotes
CohortAggregate selected decoders from one completed experiment at inference timeSupports probability-weighted and majority-vote fallback modes
BUILTIN_SELECTORSMap selector names to built-in selector modulesExported at the package root
limen.cohort.sfc.all.selectDefault "use every round" selectorPreserves existing omitted-permutation_ids behavior
limen.cohort.sfc.top_n.selectResults-column rankerRequires results.csv
limen.cohort.sfc.backtest_pareto.selectTrading-metric Pareto selectionUses backtest return/risk columns
limen.cohort.sfc.diverse_metrics.selectMetric-diverse member selectionUses PCA/KMeans medoids over metric columns

Package map

cohort/
├── cohort.py # Cohort constructor + aggregation logic
└── sfc/ # Single-file cohort strategies
├── all.py # select(context) -> ids
├── top_n.py # select(context, *, column, n) -> ids
├── backtest_pareto.py # select(context, *, target_count) -> ids
└── diverse_metrics.py # select(context, *, target_count) -> ids

Cohort quick behavior

  • Construct from exactly one experiment source (experiment_id or experiment_log_path)
  • Validate explicit or selector-produced permutation_ids
  • Enforce single-architecture selection
  • Infer aggregation mode from architecture capability:
    • probability_weighted when probability output is supported
    • majority_vote fallback otherwise
  • predict(raw_klines) returns one BarPrediction for the last bar
  • predict_all(raw_klines) returns list[BarPrediction]
  • __call__(raw_klines) aliases predict_all(raw_klines)

See Cohort for full contract and examples.

Selector quick behavior

  • Selectors are one-file strategies with one public select(context) function
  • Selectors receive a context dict and return permutation IDs only
  • Cohort owns all validation after selector execution
  • Built-ins cover all-round, single-column rank, backtest Pareto, and metric diversity selection

Adjacent modules

  • limen.experiment owns manifests and parameter search; limen.inference owns Trainer and Sensor reconstruction used by Cohort flows
  • limen.log provides analysis surfaces commonly used before selector-driven promotion
  • limen.sfd and reference architectures define member model output behavior