tic.interpret package¶
Submodules¶
tic.interpret.feature_importance module¶
-
tic.interpret.feature_importance.
explain_global
(clf: sklearn.base.BaseEstimator, feature_names: List, absolute_values: Optional[bool] = False, sort: Optional[bool] = True, num_features: Optional[int] = None)[source]¶ Uses built-in methods from the classifier object to extract feature importances in form of Gini coefficients (for tree based models) and coefficients (for linear models).
- Args:
- clf: fitted classifier object as input feature_names: feature names as fed to the fitting function of clf absolute_values: whether absolute values should be returned (exp) sort: whether the importances should be sorted num_features: how many importances should be reported
- Returns:
- list of feature importances with the given configuration
tic.interpret.lime module¶
-
tic.interpret.lime.
explain_global
(clf: sklearn.base.BaseEstimator, training_data: List, feature_names: List, class_names: List, explainer_kwargs: Optional[Dict] = {}, explanation_kwargs: Optional[Dict] = {})[source]¶ Creates an explainer and creates a submodular pick. Returns the explanation with the highest coverage.
- Args:
- clf : Fitted classifier from sklearn training_data: data that was used to train the classifier feature_names: name of features of dataset class_names: names of class labels explainer_kwargs: Keyword args passed during explainer initialization explanation_kwargs: Keyword args passed for submodular pick
- Returns:
- Enriched explanation with highest coverage including figure
-
tic.interpret.lime.
explain_local
(clf: sklearn.base.BaseEstimator, instance: List, training_data: List, feature_names: List, class_names: List, explainer_kwargs: Optional[Dict] = {}, explanation_kwargs: Optional[Dict] = {})[source]¶ Creates an explainer and explains the given instance using LIME.
- Args:
- clf : Fitted classifier from sklearn instance: instance to explain training_data: data that was used to train the classifier feature_names: name of features of dataset class_names: names of class labels explainer_kwargs: Keyword args passed during explainer initialization explanation_kwargs: Keyword args passed for explanation
- Returns:
- Enriched explanation including figure
tic.interpret.shap module¶
-
tic.interpret.shap.
explain_global
(clf: sklearn.base.BaseEstimator, X_train: pandas.core.frame.DataFrame, X_test: pandas.core.frame.DataFrame, class_names: List, sample_size: Optional[int] = 100, explainer_kwargs: Optional[Dict] = {}, explanation_kwargs: Optional[Dict] = {})[source]¶ Creates an explainer and explanations for a given dataset using SHAP.
- Args:
- clf : Fitted classifier from sklearn X_train: data that was used to train the classifier X_test: data that should be explained class_names: names of class labels sample_size: how many data points are used to create the SHAP values explainer_kwargs: Keyword args passed during explainer initialization explanation_kwargs: Keyword args passed for explanation
- Returns:
- Enriched SHAP explanation including interactive figure
-
tic.interpret.shap.
explain_local
(clf: sklearn.base.BaseEstimator, X_train: pandas.core.frame.DataFrame, instance: pandas.core.series.Series, class_names: List, sample_size: Optional[int] = 100, explainer_kwargs: Optional[Dict] = {}, explanation_kwargs: Optional[Dict] = {})[source]¶ Creates an explainer and explains the given instance using SHAP.
- Args:
- clf : Fitted classifier from sklearn X_train: data that was used to train the classifier instance: instance to explain class_names: names of class labels sample_size: how many data points are used to create the SHAP values explainer_kwargs: Keyword args passed during explainer initialization explanation_kwargs: Keyword args passed for explanation
- Returns:
- Enriched SHAP explanation including figure
tic.interpret.surrogate module¶
-
tic.interpret.surrogate.
explain_global
(clf: sklearn.base.BaseEstimator, surrogate_type: str, X_train: pandas.core.frame.DataFrame, num_features: int, surrogate_kwargs: Optional[Dict] = {}, feature_importances_kwargs: Optional[Dict] = {})[source]¶ Creates a surrogate model that mimics the behavior of the original model.
- Args:
- clf : Fitted classifier from sklearn surrogate_type: Type of surrogate model, linear or tree X_train: DataFrame with the original training data num_features: how many feature importances should be returned surrogate_kwargs: Keyword args passed during surrogate initialization feature_importances_kwargs: Kwargs passed for feature importance method
- Returns:
- Surrogate model with its feature importances