diff_diff.SieveLearner#

class diff_diff.SieveLearner[source]#

Bases: object

Polynomial-sieve regressor with information-criterion degree selection.

For each candidate total degree K = 1..k_max (auto k_max = floor(n_pos**0.2), floored at 1, where n_pos is the positive-weight support count; degrees whose basis dimension reaches n_pos are inadmissible), builds the monomial basis via the EfficientDiD sieve helper, fits by (W)LS, and scores IC(K) = n_pos * log(RSS_w / n_pos) + c_n * p_K with c_n = 2 (AIC) or log(n_pos) (BIC). Degrees with an ill-conditioned (weighted) design Gram are skipped (one consolidated UserWarning). If EVERY degree is inadmissible on a non-empty support, falls back to an intercept-only (weighted-mean) fit with a UserWarning; genuinely degenerate inputs (empty data, fewer than 2 positive-weight rows) raise a targeted ValueError instead (the fail-closed sibling contract).

The standardization statistics center_/scale_ are UNWEIGHTED even under sample_weight — the helper standardizes for numerical conditioning only, and fitted values are standardization-invariant. Fitted state is plain floats/ndarrays (deep-copyable, picklable); fit fully re-initializes it (sklearn fit-reset semantics).

Methods

__init__([k_max, criterion])

fit(X, y[, sample_weight])

predict(X)

__init__(k_max=None, criterion='bic')[source]#
Parameters:
  • k_max (int | None)

  • criterion (str)

Return type:

None

classmethod __new__(*args, **kwargs)#