How to use the causallib.evaluation.weight_evaluator.WeightEvaluator function in causallib

To help you get started, we’ve selected a few causallib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / causallib / causallib / evaluation / weight_evaluator.py View on Github external
    @property
    def propensity(self):
        propensity = self._extract_vector_from_matrix(self.propensity_matrix,
                                                      self._treatment_assignment)
        return propensity

    @property
    def propensity_by_treatment_assignment(self):
        # TODO: remove propensity_by_treatment if expected-ROC is not to be used.
        propensity_by_treatment_assignment = self._extract_vector_from_matrix(self.propensity_matrix,
                                                                              self._treatment_assignment.max())
        return propensity_by_treatment_assignment


class PropensityEvaluator(WeightEvaluator):
    def __init__(self, estimator):
        """
        Args:
            estimator (PropensityEstimator):
        """
        if not isinstance(estimator, PropensityEstimator):
            raise TypeError("PropensityEvaluator should be initialized with PropensityEstimator, got ({}) instead."
                            .format(type(estimator)))
        super(PropensityEvaluator, self).__init__(estimator)

    def _estimator_predict(self, X, a):
        """Predict on data.

        Args:
            X (pd.DataFrame): Covariates.
            a (pd.Series): Target variable - treatment assignment
github IBM / causallib / causallib / evaluation / weight_evaluator.py View on Github external
def __init__(self, estimator):
        """
        Args:
            estimator (WeightEstimator):
        """
        if not isinstance(estimator, WeightEstimator):
            raise TypeError("WeightEvaluator should be initialized with WeightEstimator, got ({}) instead."
                            .format(type(estimator)))
        super(WeightEvaluator, self).__init__(estimator)
        self._plot_functions.update({"weight_distribution": plot_propensity_score_distribution_folds,
                                     "covariate_balance_love": plot_mean_features_imbalance_love_folds,
                                     "covariate_balance_slope": plot_mean_features_imbalance_slope_folds})

causallib

A Python package for flexible and modular causal inference modeling

Apache-2.0
Latest version published 9 months ago

Package Health Score

73 / 100
Full package analysis

Similar packages