mini_causal.partial_counter.PartialCounterfactual

class mini_causal.partial_counter.PartialCounterfactual(model, X, y)

PartialCounterfactual is class that uses partial modeling or methods to measure the impact of features on the built-in models.

It moves away from the traditional feature importance used in machine learning algorithms towards measuring the impact of an individual feature on the model by using Causal Inference. The method sits at the intersection of both parametric and non-parametric methods. Hence it can be used for both methods.

Args:

model:

the trained model

X (pd.DataFrame):

The features stored in a dataframe format dataframe are used to simplify accessing the features for partial modeling and calculating causal metrics

y {pd.DataFrame ,np.array}:

The target values must have the same length as the X arg

partial_fit

fits the partial estimator i.e the model without the feature

individual_causal_effects

returns an array of the individual causal effects

Type:

np.ndarray

average_causal_effects

returns the average causal effect float value

Type:

np.ndarray

References

ML and AI https://causalml-book.org/ .. [3] Wikipedia ,Partial Linear Regression , https://en.wikipedia.org/wiki/Partial_least_squares_regression .. [4] ELIFE OZTURK KIYAK el al. Partial Decision Tree Forest,A Machine Learning Model For GeoScience,

__init__(model, X, y)

Methods

__init__(model, X, y)

average_causal_effect(X, feature)

The average causal effect

individual_causal_effects(X, feature)

The individual causal effects of the predicted

partial_model(feature)

Clone the parameters from the fitted model Then build a partial model from the scratch