Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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
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})