SklearnModelAdapter#

class causalpy.experiments.model_adapter.SklearnModelAdapter[source]#

Adapter for sklearn RegressorMixin backends.

Parameters:

model (RegressorMixin) – CausalPy-compatible sklearn backend model.

Methods

SklearnModelAdapter.build(X, y, *[, coords])

Record the design matrices for sample_posterior().

SklearnModelAdapter.coefficients(*[, group])

Return fitted sklearn coefficients as singleton posterior draws.

SklearnModelAdapter.fit(X, y, *[, coords])

Fit the sklearn model.

SklearnModelAdapter.predict(X, *[, coords, ...])

Return point predictions as singleton posterior draws.

SklearnModelAdapter.print_coefficients(labels)

Print model coefficients with labels.

SklearnModelAdapter.require_idata()

Return fitted inference-result DataTree or raise an explicit capability error.

SklearnModelAdapter.sample_posterior(**kwargs)

Fit the sklearn model on the recorded design matrices.

SklearnModelAdapter.sample_prior_predictive(...)

Raise: point-estimate backends have no prior predictive phase.

SklearnModelAdapter.score(X, y, *[, coords, ...])

Return per-output \(R^2\) scores from the sklearn model.

Attributes

has_posterior

Whether the sklearn model has been fitted.

has_prior

Whether prior draws are available on this backend.

idata

Return None because sklearn models have no inference-result DataTree.

is_bayesian

Whether the backend is Bayesian (PyMC or pymc-forecast).

is_built

Whether design matrices have been recorded via build().

is_ols

Whether the backend is OLS/sklearn.

kind

Backend identifier.

model

The underlying sklearn model.

supports_idata

Whether the backend exposes an inference-result DataTree.

supports_prior_predictive

Whether this backend can sample a prior predictive phase.

__init__(model)[source]#
Parameters:

model (RegressorMixin)

Return type:

None

classmethod __new__(*args, **kwargs)#