sklearn metadata routing: let `treatment` reach a learner inside a Pipeline

Aperta
#986 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@su-jin1425 ci sta già lavorando.

Dal 16/8/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python, scikit-learn

Direzione di ricerca

Inizia con sklearn.utils.metadata_routing e Pipeline, quindi esamina le signature di fit di BaseLearner e del meta-learner dopo l’integrazione di #985. Aggiungi la copertura di integrazione per un S-learner e un learner che consuma propensity con routing abilitato e con prefisso, oltre all’esempio documentato di Pipeline. È completato quando il trattamento raggiunge il learner finale senza un adapter e la riproduzione di #854 funziona.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Part of #980 (v1.0 M1). Closes #854 when it lands.

Reordering fit to (X, y, treatment, …) is necessary but not sufficient for #854. Pipeline.fit(X, y) passes exactly two things; treatment is a third required array with nowhere to ride. After the flip a CausalML learner still can't be a Pipeline step without an adapter — the reordering just removes the first obstacle.

The mechanism sklearn provides is metadata routing: fit(X, y, **fit_params) with set_fit_request(treatment=True), so a caller writes pipe.fit(X, y, treatment=treatment) and the router delivers treatment to the step that asked for it.

Prerequisite

#985, the signature flip. Until then Pipeline's positional y binds to treatment, so an end-to-end test cannot be written. #985 is unblocked and targets v1.0 (Jun 2027).

Scope for the first pass

  • Meta-learners only — they are the classes users most want inside a Pipeline.
  • Integration tests and documentation before any custom MetadataRouter. BaseLearner subclasses BaseEstimator and the fit signatures declare treatment and p explicitly, so set_fit_request should be generated automatically; confirm that against sklearn.utils.metadata_routing before writing any routing code.
  • Cover an S-learner pipeline plus one propensity-consuming learner.
  • Cover both paths: routing enabled via sklearn.set_config(enable_metadata_routing=True), and the prefixed routing-disabled form.
  • Row-preserving transformers only. Resampling has to move X, y, treatment and p together and belongs in its own design.

Out of scope for the first pass: whether p should route into a learner's wrapped estimator, rather than being consumed by the learner itself.

Why it's separate

The argument order is a breaking change on a deadline (v1.0 API freeze); routing is additive and can land any time after. Coupling them would put a design-heavy feature on the critical path of a mechanical rename.

Acceptance

  • A documented, tested example of a CausalML learner as a Pipeline final step with treatment routed, no adapter class.
  • #854's original reproduction works.
Lingua principale
Python
Stelle
6k
Fork
892
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di uber/causalml

Tutte le issue di uber/causalml

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.