cleverly.interventions.Intervention#
- class cleverly.interventions.Intervention(*args, **kwargs)[source]#
A conditional distribution over the treatment arms.
Implement
density(), carry aname, and declaredensity_kind; everything else – the clever covariate, the influence curve, the positivity report, the parameter names – is written against the(n, K)matrix and needs to know nothing about which kind of intervention produced it.densityreceives the data of the fit, so it can compute \(g^\star\) from the analysis sample, and no code can inspect what it computes. So a user-written class declaresdensity_kind."known"says thatdensity(data)returns a fixed function of the covariates, chosen independently of the analysis sample, and it is the one value a fit accepts.refuse_regime_densities()refusesNoneand"estimated"before any learner. A plain class attributedensity_kind = "known"satisfies the protocol.Static,RuleandStochasticcarry their own declarations. A subclass ofStaticcan overridedensity, so it declaresdensity_kinditself.- Parameters:
- *args, **kwargs
Present because
typing.runtime_checkable()gives a protocol a synthetic constructor. A protocol is implemented, not instantiated.
- Attributes:
namestrWhat this regime is called in reported parameter names:
ey[treat_all].density_kind{“known”, “estimated”}orNoneThe declaration that
density()is a fixed function of the covariates.
Methods#
- Intervention.density(data: CausalData) ndarray[tuple[Any, ...], dtype[float64]][source]#
Evaluate this regime’s arm probabilities for every row.
- Parameters:
- data
CausalData Validated study data, which supplies the covariates and the arm order.
- data
- Returns:
ndarray(n, K)array of \(g^\star(a \mid W_i)\), columns in arm-code order.
Attributes#
- Intervention.density_kind#
The declaration that
density()is a fixed function of the covariates."known"is the one value a fit accepts.Nonemeans undeclared, and it is refused with"estimated", a density computed from the analysis sample. Any other value is aDataError.
- Intervention.name#
What this regime is called in reported parameter names:
ey[treat_all].A read-only property rather than a mutable attribute so that the frozen dataclasses below satisfy the protocol: an intervention that could be renamed after a fit had used it would put the reported parameter names out of step with the densities they came from.