actableai.causal.models.AAICausalEstimator(model_params: Optional[dict] = None, scorer: Optional[list] = None, has_categorical_treatment: bool = False, has_binary_outcome: bool = False)¶Bases: object
effect(X: Optional[numpy.ndarray] = None, T0: Optional[numpy.ndarray] = None, T1: Optional[numpy.ndarray] = None, alpha: float = 0.05)¶Compute heterogeneous treatment effect
fit(Y: numpy.ndarray, T: numpy.ndarray, X: Optional[numpy.ndarray] = None, W: Optional[numpy.ndarray] = None, Z: Optional[numpy.ndarray] = None, label_t: str = 't', label_y: str = 'y', target_units: str = 'ate', trials: int = 3, tune_params=None, cv: Union[str, int] = 'auto', feature_importance: bool = False, model_directory: Optional[str] = None, hyperparameters_t: Optional[dict] = None, hyperparameters_y: Optional[dict] = None, hyperparameters_auto: Optional[bool] = True, presets: str = 'medium_quality_faster_train', random_state: Optional[int] = None, mc_iters: str = 'auto', remove_outliers: bool = True, contamination: float = 0.05, num_gpus: int = 0, drop_unique: bool = True, drop_useless_features: bool = True, hyperparameter_tune_kwargs: Optional[dict] = None, dml_estimator: Optional[actableai.models.causal_inference_estimators.base.EstimatorBaseParams] = None)¶Function fits a causal model with a single deterministic model.
fit_search(Y, T, X=None, W=None, Z=None, target_units='ate', validation_ratio=0.2, trials=3, tune_params=None, max_concurrent=None, scheduler=None, stopper=None, cv=10)¶Fit casaul model with model and hyper-parameter search.
actableai.causal.models.PolynomialLinearPredictor(path: Optional[str] = None, name: Optional[str] = None, problem_type: Optional[str] = None, eval_metric: Optional[Union[str, autogluon.core.metrics.Scorer]] = None, hyperparameters=None)¶Bases: autogluon.core.models.abstract.abstract_model.AbstractModel
actableai.causal.models.UnsupportedTargetUnitsIVMethods¶Bases: ValueError
actableai.causal.models.UnsupportedTargetUnitsMultipleTreatments¶Bases: ValueError
actableai.causal.models.UntrainedModelException¶Bases: ValueError
actableai.causal.params.BaseCausalEstimatorParams¶Bases: abc.ABC
build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.CausalForestDMLSingleContTreatmentParams(model_y='RandomForestRegressor', model_t='RandomForestRegressor', criterion='mse', n_estimators=(100, 2000), min_impurity_decrease=(0.0005, 0.005), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'CausalForestDMLSingleContTreatment'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.DRLearnerSingleBinaryTreatmentParams(model_propensity='RandomForestClassifier', model_regression='RandomForestRegressor', model_final='RandomForestRegressor', min_samples_leaf=(5, 20), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'DRLearnerSingleBinaryTreatmentParams'¶build_estimator(params)¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.DeepIVParams(num_instruments, num_effect_modifiers, num_treatments, num_gaussian_mixtures=(2, 12), num_keras_fit_epoch=(20, 50), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'DeepIVParams'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.DomainAdaptationLearnerSingleBinaryTreatmentParams(models='RandomForestRegressor', final_models='RandomForestRegressor', propensity_model='RandomForestClassifier', min_samples_leaf=(5, 20), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'DomainAdaptationLearnerSingleBinaryTreatmentParams'¶build_estimator(params)¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLCategoricalOutcomeAGParams(label_t, label_y, model_directory, hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLCategoricalOutcomeAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLCategoricalOutcomeParams(model_y='MultiTaskElasticNetCV', model_t='RandomForestRegressor', l1_ratio=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLCategoricalOutcome'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLCategoricalTreatmentAGParams(label_t, label_y, model_directory, hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLCategoricalTreatmentAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLCategoricalTreatmentAndOutcomeAGParams(label_t, label_y, model_directory, hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLCategoricalTreatmentAndOutcomeAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLCategoricalTreatmentAndOutcomeParams(model_y='MultiTaskElasticNetCV', model_t='MultiTaskElasticNetCV', l1_ratio_y=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), l1_ratio_t=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLCategoricalTreatmentAndOutcome'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLCategoricalTreatmentParams(model_y='RandomForestRegressor', model_t='MultiTaskElasticNetCV', l1_ratio=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLCategoricalTreatment'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLSingleBinaryOutcomeAGParams(label_t, label_y, model_directory, hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLSingleBinaryOutcomeAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLSingleBinaryOutcomeParams(model_y='RandomForestClassifier', model_t='RandomForestRegressor', min_samples_leaf=(5, 20), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLSingleBinaryOutcome'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLSingleBinaryTreatmentAGParams(label_t, label_y, model_directory, hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLSingleBinaryTreatmentAGParams'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLSingleBinaryTreatmentParams(model_y='RandomForestRegressor', model_t='RandomForestClassifier', min_samples_leaf=(5, 20), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLSingleBinaryTreatment'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLSingleContTreatmentAGParams(label_t, label_y, model_directory, hyperparameters=None, random_state=123, presets='best_quality', cv=10, featurizer=None)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLSingleContTreatmentAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.LinearDMLSingleContTreatmentParams(model_y='RandomForestRegressor', model_t='RandomForestRegressor', random_state=123, cv=5, mc_iters=None)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'LinearDMLSingleContTreatment'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLCategoricalOutcomeAGParams(label_t, label_y, model_directory, polyfeat_degree=(1, 4), hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLCategoricalOutcomeAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLCategoricalOutcomeParams(model_y='RandomForestRegressor', model_t='MultiTaskElasticNetCV', polyfeat_degree=(1, 4), l1_ratio=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLCategoricalOutcome'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLCategoricalTreatmentAGParams(label_t, label_y, model_directory, polyfeat_degree=(1, 4), hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLCategoricalTreatmentAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLCategoricalTreatmentAndOutcomeAGParams(label_t, label_y, model_directory, polyfeat_degree=(1, 4), hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLCategoricalTreatmentAndOutcomeAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLCategoricalTreatmentAndOutcomeParams(model_y='MultiTaskElasticNetCV', model_t='MultiTaskElasticNetCV', polyfeat_degree=(1, 4), l1_ratio_y=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), l1_ratio_t=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLCategoricalTreatmentAndOutcome'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLCategoricalTreatmentParams(model_y='RandomForestRegressor', model_t='MultiTaskElasticNetCV', polyfeat_degree=(1, 4), l1_ratio=(0.1, 0.5, 0.7, 0.9, 0.95, 0.99, 1), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLCategoricalTreatment'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLSingleBinaryOutcomeAGParams(label_t, label_y, model_directory, polyfeat_degree=(1, 4), hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLSingleBinaryOutcomeAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLSingleBinaryOutcomeParams(model_y='RandomForestClassifier', model_t='RandomForestRegressor', min_samples_leaf=(5, 20), polyfeat_degree=(1, 4), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLSingleBinaryOutcome'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLSingleBinaryTreatmentAGParams(label_t, label_y, model_directory, polyfeat_degree=(1, 4), hyperparameters=None, random_state=123, presets='best_quality', cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLSingleBinaryTreatmentAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLSingleBinaryTreatmentParams(model_y='RandomForestRegressor', model_t='RandomForestClassifier', min_samples_leaf=(5, 20), polyfeat_degree=(1, 4), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLSingleBinaryTreatment'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLSingleContTreatmentAGParams(label_t, label_y, model_directory, polyfeat_degree=4, hyperparameters=None, presets='best_quality', random_state=123, cv=10)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLSingleContTreatmentAG'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.SparseLinearDMLSingleContTreatmentParams(model_y='RandomForestRegressor', model_t='RandomForestRegressor', polyfeat_degree=(1, 4), random_state=123)¶Bases: actableai.causal.params.BaseCausalEstimatorParams
MODEL_NAME = 'SparseLinearDMLSingleContTreatment'¶build_estimator(params={})¶Returns an estimator object given model config dictionary
tune_config()¶Returns a configuration dictionary of the model parameters
actableai.causal.params.UnsupportedCausalScenario¶Bases: ValueError
actableai.causal.params.get_model_params(is_single_treatment, has_categorical_treatment, is_single_binary_treatment, is_single_outcome, has_categorical_outcome, is_single_binary_outcome, has_effect_modifiers_and_common_causes, label_t, label_y, model_directory, hyperparameters=None, presets='best_quality', cv=10, featurizer=None, mc_iters=None)¶actableai.causal.params.get_rscorer(is_single_treatment, has_categorical_treatment, is_single_binary_treatment, is_single_outcome, has_categorical_outcome, is_single_binary_outcome)¶actableai.causal.predictors.DataFrameTransformer(column_names: Optional[List[str]] = None)¶Bases: sklearn.base.TransformerMixin, sklearn.base.BaseEstimator
fit(X)¶fit_transform(X, y=None, **fit_params)¶Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
X_new – Transformed array.
ndarray array of shape (n_samples, n_features_new)
transform(X)¶actableai.causal.predictors.LinearRegressionWrapper(*, fit_intercept=True, normalize='deprecated', copy_X=True, n_jobs=None, positive=False)¶Bases: sklearn.linear_model._base.LinearRegression
score(X, y, sample_weight=None)¶Return the coefficient of determination of the prediction.
The coefficient of determination \(R^2\) is defined as
\((1 - \frac{u}{v})\), where \(u\) is the residual
sum of squares ((y_true - y_pred)** 2).sum() and \(v\)
is the total sum of squares ((y_true - y_true.mean()) ** 2).sum().
The best possible score is 1.0 and it can be negative (because the
model can be arbitrarily worse). A constant model that always predicts
the expected value of y, disregarding the input features, would get
a \(R^2\) score of 0.0.
(n_samples, n_samples_fitted), where n_samples_fitted
is the number of samples used in the fitting for the estimator.score – \(R^2\) of self.predict(X) wrt. y.
float
Notes
The \(R^2\) score used when calling score on a regressor uses
multioutput='uniform_average' from version 0.23 to keep consistent
with default value of r2_score().
This influences the score method of all the multioutput
regressors (except for
MultiOutputRegressor).
actableai.causal.predictors.SKLearnMultilabelWrapper(ag_predictor, x_w_columns: Optional[List] = None, hyperparameters: Optional[Union[List, Dict]] = None, presets: Optional[str] = 'best_quality', ag_args_fit: Optional[Dict] = None, feature_generator: Optional[autogluon.features.generators.abstract.AbstractFeatureGenerator] = None, holdout_frac: Optional[float] = None)¶Bases: actableai.causal.predictors.SKLearnWrapper
add_output(train_data, y)¶Method to add the output to the train_data. Necessary for AutoGLuon
Original DataFrame with target added
pd.DataFrame
feature_importance() pandas.core.frame.DataFrame¶Feature importance of the model
score(X, y, sample_weight=None) Dict[str, Any]¶Score for the model
UnsupportedProblemType – If the problem_type of the TabularPredictor is not right
Dict
set_sample_weight(sample_weight=None)¶Set samples weight for the model
actableai.causal.predictors.SKLearnTabularWrapper(ag_predictor: autogluon.tabular.predictor.predictor.TabularPredictor, x_w_columns: Optional[List] = None, hyperparameters: Optional[Union[List, Dict]] = None, presets: Optional[str] = 'best_quality', ag_args_fit: Optional[Dict] = None, feature_generator: Optional[autogluon.features.generators.abstract.AbstractFeatureGenerator] = None, holdout_frac: Optional[float] = None, hyperparameter_tune_kwargs: Optional[Dict] = None, num_gpus: Optional[int] = 0)¶Bases: actableai.causal.predictors.SKLearnWrapper
add_output(train_data: pandas.core.frame.DataFrame, y) pandas.core.frame.DataFrame¶Method to add the output to the train_data. Necessary for AutoGLuon
Original DataFrame with target added
pd.DataFrame
feature_importance() pandas.core.frame.DataFrame¶Feature importance of the model
score(X, y, sample_weight=None) Dict[str, Any]¶Score for the model
UnsupportedProblemType – If the problem_type of the TabularPredictor is not right
Dict
set_sample_weight(sample_weight=None) None¶Set samples weight for the model
actableai.causal.predictors.SKLearnWrapper(ag_predictor: Union[actableai.utils.multilabel_predictor.MultilabelPredictor, autogluon.tabular.predictor.predictor.TabularPredictor], x_w_columns: Optional[List] = None, hyperparameters: Optional[Union[List, Dict]] = None, presets: Optional[str] = 'best_quality', ag_args_fit: Optional[Dict] = None, feature_generator: Optional[autogluon.features.generators.abstract.AbstractFeatureGenerator] = None, holdout_frac: Optional[float] = None, hyperparameter_tune_kwargs: Optional[Dict] = None, num_gpus: Optional[int] = 0)¶Bases: abc.ABC
add_output(train_data: pandas.core.frame.DataFrame, y: numpy.ndarray) pandas.core.frame.DataFrame¶Method to add the output to the train_data. Necessary for AutoGLuon
Original DataFrame with target added
pd.DataFrame
feature_importance() pandas.core.frame.DataFrame¶Feature importance of the model
fit(X: Union[pandas.core.frame.DataFrame, numpy.ndarray], y: Union[pandas.core.series.Series, numpy.ndarray], sample_weight: Optional[List] = None) actableai.causal.predictors.SKLearnWrapper¶Fit the model
The fitted SKLearnWrapper
self
predict(X: Union[pandas.core.frame.DataFrame, numpy.ndarray]) Union[pandas.core.frame.DataFrame, pandas.core.series.Series]¶Infer the result from the data
predict_proba(X: pandas.core.frame.DataFrame) numpy.ndarray¶score(X: Union[pandas.core.frame.DataFrame, numpy.ndarray], y: numpy.ndarray, sample_weight: Optional[Iterable] = None) Dict[str, Any]¶Score for the model
UnsupportedProblemType – If the problem_type of the TabularPredictor is not right
Dict
set_sample_weight(sample_weight: Optional[Iterable] = None) None¶Set samples weight for the model
actableai.causal.predictors.UnsupportedPredictorType¶Bases: ValueError
Raised when the predictor type is not supported.
actableai.causal.predictors.UnsupportedProblemType¶Bases: ValueError
Raised when the problem type is not supported.
actableai.causal.tree_utils.Node(left: Optional[actableai.causal.tree_utils.Node] = None, right: Optional[actableai.causal.tree_utils.Node] = None, label: Optional[str] = None, conditions: list = [], is_right_child: bool = False, num_right_ancestors: int = 0)¶Bases: object
actableai.causal.tree_utils.convert_label_to_categorical(root_node, cat_name, cat_vals)¶cat_name: name of the categorical variable cat_vals: mapping of numeric to categorical value
actableai.causal.tree_utils.get_cat_constraint(cat_name, cat_vals, constraints)¶cat_name: name of categorical variables cat_vals: dictionary mapping numeric to categorical values constraints: list of conditions
actableai.causal.tree_utils.make_pretty_tree(tree_dot: str, cat_names: list[str], cat_vals_list: list[dict]) str¶Make a pretty tree from a tree_dot.
_description_
_type_
actableai.causal.tree_utils.negate_condition(condition: str) Optional[str]¶Converts a condition to its negation.
actableai.causal.tree_utils.parse_tree_dot(tree_dot: str) Tuple[str, dict]¶Parser for tree_dot.
actableai.causal.OneHotEncodingTransformer(df)¶Bases: object
fit_transform(X, y=None)¶transform(X)¶actableai.causal.autogluon_hyperparameters()¶actableai.causal.has_categorical_column(df, columns)¶actableai.causal.prepare_sanitize_data(pd_table: pandas.core.frame.DataFrame, treatments: List[str], outcomes: List[str], effect_modifiers: List[str], common_causes: List[str]) pandas.core.frame.DataFrame¶Drop NAN rows for treatments and outcomes then impute effect_modifiers and common_causes
New table sanitized and imputed
pd.DataFrame