Skip to content

calculate_error() unsupported on scikit-learn 1.9 due to forestci incompatibility #906

@jeongyoonlee

Description

@jeongyoonlee

Describe the bug

CausalRandomForestRegressor.calculate_error() delegates to forestci (forestci==0.6, pinned in pyproject.toml). forestci.calc_inbag() calls scikit-learn's private _get_n_samples_bootstrap and _generate_sample_indices with their pre-1.9 signatures and has no version guard, so on scikit-learn 1.9 it raises:

TypeError: _get_n_samples_bootstrap() missing 1 required positional argument: 'sample_weight'
  .../forestci/forestci.py  (in calc_inbag)

The latest forestci (0.7 / master) is still unfixed.

Why it can't be worked around from causalml alone

random_forest_error(..., calibrate=True) (the default) makes a recursive call on a subsampled forest that recomputes inbag internally without forwarding a caller-supplied inbag, so passing a precomputed inbag to calculate_error() only sidesteps the break for calibrate=False.

Scope / status

fit() and predict() on scikit-learn 1.9 are fixed in #905. calculate_error() remains unsupported on >= 1.9 until forestci is updated upstream and the pin bumped. The test_unbiased_sampling_error cases are marked xfail (non-strict, so they XPASS automatically once forestci is fixed).

Options when resolving

  1. Upstream fix in forestci (version-guard the two private calls) + bump the causalml pin. (Preferred; upstream issue to be filed.)
  2. A scikit-learn >= 1.9 compatibility shim in calculate_error() that defaults sample_weight=None on forestci's private calls (validated working locally).
  3. Vendor forestci's inbag / variance computation into causalml (more maintenance / vendoring fragility).

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency file

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions