openasce.inference.learner package

class openasce.inference.learner.DML(*, model_y, model_t, model_final, featurizer=None, treatment_featurizer=None, fit_cate_intercept=True, linear_first_stages=False, discrete_treatment=False, categories='auto', cv=2, mc_iters=None, mc_agg='mean', random_state=None)[source]

Bases: DML, InferenceModel

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__module__ = 'openasce.inference.learner.dml'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs)[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

class openasce.inference.learner.DRLearner(*, model_propensity='auto', model_regression='auto', model_final=StatsModelsLinearRegression(), multitask_model_final=False, featurizer=None, min_propensity=1e-06, categories='auto', cv=2, mc_iters=None, mc_agg='mean', random_state=None)[source]

Bases: DRLearner, InferenceModel

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__module__ = 'openasce.inference.learner.drlearner'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs)[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

class openasce.inference.learner.SLearner(*, models: List, categories: Union[str, list] = 'auto')[source]

Bases: SLearner, InferenceModel

Initialize SLearner

Parameters
  • models – Outcome estimators for all units, only need one model.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__init__(*, models: List, categories: Union[str, list] = 'auto') None[source]

Initialize SLearner

Parameters
  • models – Outcome estimators for all units, only need one model.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__module__ = 'openasce.inference.learner.metalearners'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs) NoReturn[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

class openasce.inference.learner.TLearner(*, models: List, categories: Union[str, list] = 'auto')[source]

Bases: TLearner, InferenceModel

Initialize TLearner

Parameters
  • models (List) – List of outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__init__(*, models: List, categories: Union[str, list] = 'auto') None[source]

Initialize TLearner

Parameters
  • models (List) – List of outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__module__ = 'openasce.inference.learner.metalearners'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs) NoReturn[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

class openasce.inference.learner.XLearner(*, models: List, cate_models: List = None, propensity_model=LogisticRegression(), categories: Union[str, list] = 'auto')[source]

Bases: XLearner, InferenceModel

Initialize XLearner

Parameters
  • models (List) – outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • cate_models (List) – estimator for pseudo-treatment effects on control and treatments, all models predictions result must contain prediction_key.

  • propensity_model – estimator for the propensity function, propensity_model predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – list of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__init__(*, models: List, cate_models: List = None, propensity_model=LogisticRegression(), categories: Union[str, list] = 'auto') None[source]

Initialize XLearner

Parameters
  • models (List) – outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • cate_models (List) – estimator for pseudo-treatment effects on control and treatments, all models predictions result must contain prediction_key.

  • propensity_model – estimator for the propensity function, propensity_model predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – list of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__module__ = 'openasce.inference.learner.metalearners'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs) NoReturn[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

Submodules

openasce.inference.learner.dml module

class openasce.inference.learner.dml.DML(*, model_y, model_t, model_final, featurizer=None, treatment_featurizer=None, fit_cate_intercept=True, linear_first_stages=False, discrete_treatment=False, categories='auto', cv=2, mc_iters=None, mc_agg='mean', random_state=None)[source]

Bases: DML, InferenceModel

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__module__ = 'openasce.inference.learner.dml'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs)[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

openasce.inference.learner.dml_test module

openasce.inference.learner.drlearner module

class openasce.inference.learner.drlearner.DRLearner(*, model_propensity='auto', model_regression='auto', model_final=StatsModelsLinearRegression(), multitask_model_final=False, featurizer=None, min_propensity=1e-06, categories='auto', cv=2, mc_iters=None, mc_agg='mean', random_state=None)[source]

Bases: DRLearner, InferenceModel

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__module__ = 'openasce.inference.learner.drlearner'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs)[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

openasce.inference.learner.drlearner_test module

openasce.inference.learner.metalearners module

class openasce.inference.learner.metalearners.SLearner(*, models: List, categories: Union[str, list] = 'auto')[source]

Bases: SLearner, InferenceModel

Initialize SLearner

Parameters
  • models – Outcome estimators for all units, only need one model.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__init__(*, models: List, categories: Union[str, list] = 'auto') None[source]

Initialize SLearner

Parameters
  • models – Outcome estimators for all units, only need one model.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__module__ = 'openasce.inference.learner.metalearners'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs) NoReturn[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

class openasce.inference.learner.metalearners.TLearner(*, models: List, categories: Union[str, list] = 'auto')[source]

Bases: TLearner, InferenceModel

Initialize TLearner

Parameters
  • models (List) – List of outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__init__(*, models: List, categories: Union[str, list] = 'auto') None[source]

Initialize TLearner

Parameters
  • models (List) – List of outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – List of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__module__ = 'openasce.inference.learner.metalearners'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs) NoReturn[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

class openasce.inference.learner.metalearners.XLearner(*, models: List, cate_models: List = None, propensity_model=LogisticRegression(), categories: Union[str, list] = 'auto')[source]

Bases: XLearner, InferenceModel

Initialize XLearner

Parameters
  • models (List) – outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • cate_models (List) – estimator for pseudo-treatment effects on control and treatments, all models predictions result must contain prediction_key.

  • propensity_model – estimator for the propensity function, propensity_model predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – list of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__doc__ = None
__init__(*, models: List, cate_models: List = None, propensity_model=LogisticRegression(), categories: Union[str, list] = 'auto') None[source]

Initialize XLearner

Parameters
  • models (List) – outcome estimators for both control units and treatment units, all models predictions result must contain prediction_key.

  • cate_models (List) – estimator for pseudo-treatment effects on control and treatments, all models predictions result must contain prediction_key.

  • propensity_model – estimator for the propensity function, propensity_model predictions result must contain prediction_key.

  • categories (List[Union[int, float]]) – list of treatments values(like [0,1], 0 is for control). The first category will be treated as the control treatment.

__module__ = 'openasce.inference.learner.metalearners'
_abc_impl = <_abc._abc_data object>
estimate(*, X: Iterable[ndarray]) NoReturn[source]

Feed the sample data and estimate the effect on the samples

Parameters

X – Features of the samples.

Returns:

fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs) NoReturn[source]

Feed the sample data and train the model used to effect on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • T – Treatments of the samples.

Returns:

todo(idx: int, total_num: int, param: Any, dataset: Iterable) Any[source]

Contain the function from the sub-class, and run it in workers

The sub-class should implement this routine and runtime invokes it.

Arguments:

Returns:

openasce.inference.learner.metalearners_test module