omnixai.explainers.data package

class omnixai.explainers.data.DataAnalyzer(explainers, mode, data, params=None)

Bases: AutoExplainerBase

The class derived from AutoExplainerBase for data analysis, allowing users to choose multiple explainers and generate different explanations at the same time.

explainers = TabularExplainer(
    explainers=["imbalance", "mutual"],
    data=data,
    params={"imbalance": {"n_bins": 10}}
)
explanations = explainers.explain()
Parameters
  • explainers (Collection) – The names or alias of the analyzers to use, e.g., “correlation” for feature correlation analysis, “mutual” for feature importance analysis.

  • mode (str) – The task type, e.g. classification or regression.

  • data (Tabular) – The training data used to initialize explainers.

  • params (Optional[Dict]) – A dict containing the additional parameters for initializing each analyzer, e.g., params[“imbalance”] = {“param_1”: param_1, …}.

static list_explainers()

List the supported explainers.

explain(params=None)

Generates global explanations (override the explain method defined in the base class).

Parameters

params – A dict containing the additional parameters for generating explanations, e.g., params[“pdp”] = {“param_1”: param_1, …}.

Returns

A dict of explanation results generated by the explainers that support global explanation, e.g. {“pdp”: pdp_explanations, …}.

Return type

OrderedDict

class omnixai.explainers.data.ImbalanceAnalyzer(training_data, mode='classification', n_bins=10, **kwargs)

Bases: ExplainerBase

The class for checking feature imbalances. It counts the appearances of each feature value in different classes. For example, if the feature to analyze is “gender”, it computes the counts of “gender = male” and “gender = female” for each class separately. If the features to analyze are [“gender”, “age”], it will count the cross-feature values.

Parameters
  • training_data (Tabular) – The dataset for training an ML model.

  • mode (str) – The task type can be classification only.

  • n_bins (int) – The number of bins for discretizing continuous-valued features.

explanation_type = 'global'
alias = ['imbalance']
explain(features, **kwargs)

Computes the count for each cross-feature.

Parameters

features (Sequence) – A list of features to analyze.

Returns

The counts for each feature or cross-feature values in different classes.

Return type

ImbalanceExplanation

class omnixai.explainers.data.CorrelationAnalyzer(training_data, **kwargs)

Bases: ExplainerBase

The class for feature correlation analysis. It computes the feature correlation matrix given the input dataset.

Parameters

training_data (Tabular) – The dataset for training an ML model.

explanation_type = 'global'
alias = ['correlation']
explain(features=None, **kwargs)

Computes the correlation matrix via scipy.stats.spearmanr.

Parameters

features (Optional[Sequence]) – A list of feature to analyze or None if all the features are considered.

Returns

The feature correlation matrix.

Return type

CorrelationExplanation

class omnixai.explainers.data.MutualInformation(training_data, mode='classification', discrete=False, **kwargs)

Bases: ExplainerBase

The class for estimating mutual information. It computes the Information gain of each feature with respect to the target.

Parameters
  • training_data (Tabular) – The dataset for training an ML model.

  • mode – The task type, e.g., classification or regression.

  • discreteTrue if all the continuous-valued features are discretized or False if all the categorical features are converted into continuous-valued features.

explanation_type = 'global'
alias = ['mutual']
explain(**kwargs)

Computes the mutual information between each feature and the target.

Returns

The mutual information between each feature and the target.

Return type

GlobalFeatureImportance

class omnixai.explainers.data.ChiSquare(training_data, mode='classification', **kwargs)

Bases: ExplainerBase

The class for computing chi-squared stats between each non-negative feature and target.

Parameters
  • training_data (Tabular) – The dataset for training an ML model.

  • mode – The task type, e.g., classification or regression.

explanation_type = 'global'
alias = ['chi2', 'chi_square']
explain(**kwargs)

Computes chi-squared stats between each non-negative feature and target.

Returns

The chi-squared stats.

Return type

GlobalFeatureImportance

omnixai.explainers.data.auto module

class omnixai.explainers.data.auto.DataAnalyzer(explainers, mode, data, params=None)

Bases: AutoExplainerBase

The class derived from AutoExplainerBase for data analysis, allowing users to choose multiple explainers and generate different explanations at the same time.

explainers = TabularExplainer(
    explainers=["imbalance", "mutual"],
    data=data,
    params={"imbalance": {"n_bins": 10}}
)
explanations = explainers.explain()
Parameters
  • explainers (Collection) – The names or alias of the analyzers to use, e.g., “correlation” for feature correlation analysis, “mutual” for feature importance analysis.

  • mode (str) – The task type, e.g. classification or regression.

  • data (Tabular) – The training data used to initialize explainers.

  • params (Optional[Dict]) – A dict containing the additional parameters for initializing each analyzer, e.g., params[“imbalance”] = {“param_1”: param_1, …}.

static list_explainers()

List the supported explainers.

explain(params=None)

Generates global explanations (override the explain method defined in the base class).

Parameters

params – A dict containing the additional parameters for generating explanations, e.g., params[“pdp”] = {“param_1”: param_1, …}.

Returns

A dict of explanation results generated by the explainers that support global explanation, e.g. {“pdp”: pdp_explanations, …}.

Return type

OrderedDict

omnixai.explainers.data.correlation module

The class for feature correlation analysis.

class omnixai.explainers.data.correlation.CorrelationAnalyzer(training_data, **kwargs)

Bases: ExplainerBase

The class for feature correlation analysis. It computes the feature correlation matrix given the input dataset.

Parameters

training_data (Tabular) – The dataset for training an ML model.

explanation_type = 'global'
alias = ['correlation']
explain(features=None, **kwargs)

Computes the correlation matrix via scipy.stats.spearmanr.

Parameters

features (Optional[Sequence]) – A list of feature to analyze or None if all the features are considered.

Returns

The feature correlation matrix.

Return type

CorrelationExplanation

omnixai.explainers.data.imbalance module

The class for checking feature imbalances.

class omnixai.explainers.data.imbalance.ImbalanceAnalyzer(training_data, mode='classification', n_bins=10, **kwargs)

Bases: ExplainerBase

The class for checking feature imbalances. It counts the appearances of each feature value in different classes. For example, if the feature to analyze is “gender”, it computes the counts of “gender = male” and “gender = female” for each class separately. If the features to analyze are [“gender”, “age”], it will count the cross-feature values.

Parameters
  • training_data (Tabular) – The dataset for training an ML model.

  • mode (str) – The task type can be classification only.

  • n_bins (int) – The number of bins for discretizing continuous-valued features.

explanation_type = 'global'
alias = ['imbalance']
explain(features, **kwargs)

Computes the count for each cross-feature.

Parameters

features (Sequence) – A list of features to analyze.

Returns

The counts for each feature or cross-feature values in different classes.

Return type

ImbalanceExplanation

omnixai.explainers.data.mutual_info module

The class for estimating mutual information.

class omnixai.explainers.data.mutual_info.MutualInformation(training_data, mode='classification', discrete=False, **kwargs)

Bases: ExplainerBase

The class for estimating mutual information. It computes the Information gain of each feature with respect to the target.

Parameters
  • training_data (Tabular) – The dataset for training an ML model.

  • mode – The task type, e.g., classification or regression.

  • discreteTrue if all the continuous-valued features are discretized or False if all the categorical features are converted into continuous-valued features.

explanation_type = 'global'
alias = ['mutual']
explain(**kwargs)

Computes the mutual information between each feature and the target.

Returns

The mutual information between each feature and the target.

Return type

GlobalFeatureImportance

omnixai.explainers.data.chi_square module

The class for computing chi-squared stats between each non-negative feature and target.

class omnixai.explainers.data.chi_square.ChiSquare(training_data, mode='classification', **kwargs)

Bases: ExplainerBase

The class for computing chi-squared stats between each non-negative feature and target.

Parameters
  • training_data (Tabular) – The dataset for training an ML model.

  • mode – The task type, e.g., classification or regression.

explanation_type = 'global'
alias = ['chi2', 'chi_square']
explain(**kwargs)

Computes chi-squared stats between each non-negative feature and target.

Returns

The chi-squared stats.

Return type

GlobalFeatureImportance