\ No newline at end of file
diff --git a/docs/_modules/xaib/base/base.html b/docs/_modules/xaib/base/base.html
index f666666..f8f6afd 100644
--- a/docs/_modules/xaib/base/base.html
+++ b/docs/_modules/xaib/base/base.html
@@ -1,4 +1,4 @@
- xaib.base.base — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.base.base
+ xaib.base.base — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.base.base
fromtypingimportUnion,List,Dict,Any,Callablefromcascadeimportdataascddfromcascadeimportmodelsascdm
@@ -9,6 +9,7 @@
Dataset is a wrapper around any collection of items to put in the ML model for inference """
+
@@ -22,6 +23,7 @@
Model is a wrapper around any inference of ML or other solution in the form y = f(x) it implements method `predict` that given certain data x returns the response y """
+
@@ -35,6 +37,7 @@
Explainer is a special kind of Model e = g(f, x) that accepts another Model and data as input and also returns a response e - an explanation """
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/datasets/synthetic_dataset.html b/docs/_modules/xaib/datasets/synthetic_dataset.html
new file mode 100644
index 0000000..2e3953c
--- /dev/null
+++ b/docs/_modules/xaib/datasets/synthetic_dataset.html
@@ -0,0 +1,32 @@
+ xaib.datasets.synthetic_dataset — xai-benchmark 0.2.0-alpha documentation Skip to content
[docs]classCovariateRegularity(Metric):
+"""
+ Measures how noisy the features in the examples provided
+ by the method.
+
+ More simple explanations are considered better.
+ This is measured by average Shannon entropy over batch-normalized explanations.
+
+ **The less the better**
+
+ - **Worst case:** constant explainer that gives examples with same importance to each feature, that is equal to 1/N where N is the number of features
+ - **Best case:** constant explainer that gives examples with one feature with maximum value and others zero
+ """
+
+
[docs]defcompute(
+ self,
+ expl:Explainer,
+ batch_size:int=1,
+ expl_kwargs:Union[Dict[Any,Any],None]=None,
+ )->None:
+ ifexpl_kwargsisNone:
+ expl_kwargs={}
+
+ # Obtain all the labels
+ labels=np.asarray(
+ [
+ item["label"]
+ foritemintqdm(self._ds,desc="Obtaining labels",leave=False)
+ ]
+ )
+
+ # Determine how much of an intersection different labels have
+ unique_labels,counts=np.unique(labels,return_counts=True)
+ min_len=np.min(counts)
+
+ # For each label get indexes of its items
+ coords={u:np.argwhere(labels==u).T[0][:min_len]foruinunique_labels}
+
+ # Obtain all explanations by batches
+ explanations={u:[]foruinunique_labels}
+ foruinunique_labels:
+ dl=SimpleDataloader(Filter(self._ds,coords[u]),batch_size=batch_size)
+ forbatchintqdm(dl):
+ ex=expl.predict(batch["item"],self._model,**expl_kwargs)
+ ex=minmax_normalize(ex)
+
+ explanations[u]+=ex.tolist()
+
+ # Compare explanations of different labels
+ entropies_of_features={u:[]foruinunique_labels}
+ foruinunique_labels:
+ expls=np.asarray(explanations[u])
+ forfinrange(expls.shape[1]):
+ e=entropy(expls[:,f])
+ entropies_of_features[u].append(e)
+
+ returnnp.nanmean([entropies_of_features[u]foruinentropies_of_features])
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/example_selection/parameter_randomization_check.html b/docs/_modules/xaib/metrics/example_selection/parameter_randomization_check.html
new file mode 100644
index 0000000..419f2a7
--- /dev/null
+++ b/docs/_modules/xaib/metrics/example_selection/parameter_randomization_check.html
@@ -0,0 +1,68 @@
+ xaib.metrics.example_selection.parameter_randomization_check — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.example_selection.parameter_randomization_check
[docs]classParameterRandomizationCheck(Metric):
+"""
+ Parameter randomization check is a sanity-check.
+ To ensure that the model influence explanations the
+ following is done. The model is changed and it is expected that
+ explanations should not stay the same is model changed.
+ This check uses random model baselines instead of same models
+ with randomized internal states.
+ Then the explanations on the original data are obtained.
+ They are compared with explanations done with the original model by
+ counting how many examples were the same for same data points.
+ The less the better.
+
+ **The less the better**
+ - **Worst case:** explanations are the same, so it is Constant explainer
+ - **Best case:** is reached when explanations are the opposite,
+ distance between them maximized.
+ The problem with this kind of metric is
+ with its maximization. It seems redundant to maximize it because more
+ different explanations on random states do not mean that the model is
+ more correct.
+ It is difficult to define best case explainer in this case - the metric has no maximum value.
+ """
+
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/example_selection/small_noise_check.html b/docs/_modules/xaib/metrics/example_selection/small_noise_check.html
new file mode 100644
index 0000000..b24f6a5
--- /dev/null
+++ b/docs/_modules/xaib/metrics/example_selection/small_noise_check.html
@@ -0,0 +1,63 @@
+ xaib.metrics.example_selection.small_noise_check — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.example_selection.small_noise_check
[docs]classSmallNoiseCheck(Metric):
+"""
+ Since the nature of example selection methods is discrete - we choose an example
+ from finite set, the use of RMSE measure may be not appropriate.
+ This means that the metric that is similar to the one that was used in feature
+ importance case is not suitable.
+ More appropriate metric could be the following: take the test dataset and add
+ small amount of noise to the items as was done in the feature importance case.
+ Then count the number of item pairs when the example provided didn't change and
+ divide by the total number of items.
+ This ratio then is how continuous example generator is - if it provides the same
+ examples for slightly changed inputs, then it is continuous.
+
+ **The less the better**
+ - **Worst case:** Constant explainer
+ - **Best case:** Random explainer
+ """
+
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/example_selection/target_discriminativeness.html b/docs/_modules/xaib/metrics/example_selection/target_discriminativeness.html
new file mode 100644
index 0000000..ea43c59
--- /dev/null
+++ b/docs/_modules/xaib/metrics/example_selection/target_discriminativeness.html
@@ -0,0 +1,51 @@
+ xaib.metrics.example_selection.target_discriminativeness — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.example_selection.target_discriminativeness
[docs]classTargetDiscriminativeness(Metric):
+"""
+ Given true labels and explanations in form of the examples, train another model to discriminate between labels.
+ The quality of the model on the examples given describes the quality of the explanations.
+ The quality can be measured by any performance metric,
+ but it is better to adopt to imbalanced data and use F1-measure for example.
+
+ **The greater the better**
+
+ **Best case:** examples are descriptive of labels so that the model reaches best performance
+ **Worst case:** constant or random baseline - giving insufficient information to grasp labels
+ """
+
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/feature_importance/covariate_regularity.html b/docs/_modules/xaib/metrics/feature_importance/covariate_regularity.html
new file mode 100644
index 0000000..5d748f6
--- /dev/null
+++ b/docs/_modules/xaib/metrics/feature_importance/covariate_regularity.html
@@ -0,0 +1,54 @@
+ xaib.metrics.feature_importance.covariate_regularity — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.feature_importance.covariate_regularity
[docs]classCovariateRegularity(Metric):
+"""
+ Covariate Regularity using entropy over explanations
+
+ This measures how comprehensible the explanations are in average.
+ More simple explanations are considered better.
+ This is measured by average Shannon entropy over batch-normalized explanations.
+
+ **The less the better**
+ - **Worst case:** constant explainer that gives same importance to each feature, that is equal to 1/N where N is the number of features
+ - **Best case:** constant explainer that gives one feature maximum value and others zero
+ """
+
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/feature_importance/label_difference.html b/docs/_modules/xaib/metrics/feature_importance/label_difference.html
new file mode 100644
index 0000000..b67945d
--- /dev/null
+++ b/docs/_modules/xaib/metrics/feature_importance/label_difference.html
@@ -0,0 +1,81 @@
+ xaib.metrics.feature_importance.label_difference — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.feature_importance.label_difference
[docs]classLabelDifference(Metric):
+"""
+ Obtain explanations for all targets and compare them.
+ In binary case one metric can be computed - the difference
+ between explanations of positive and negative targets.
+ In case of multiclass classification we can compare one explanation
+ to explanations of all other classes and obtain a number of metrics
+ which can be averaged.
+
+ **The more the better**
+
+ - **Worst case:** same explanations for different targets - constant explainer
+ - **Best case:** different explanations for different targets
+ """
+
+
[docs]defcompute(
+ self,
+ expl:Explainer,
+ batch_size:int=1,
+ expl_kwargs:Union[Dict[Any,Any],None]=None,
+ )->None:
+ ifexpl_kwargsisNone:
+ expl_kwargs={}
+
+ # Obtain all the labels
+ labels=np.asarray(
+ [
+ item["label"]
+ foritemintqdm(self._ds,desc="Obtaining labels",leave=False)
+ ]
+ )
+
+ # Determine how much of an intersection different labels have
+ unique_labels,counts=np.unique(labels,return_counts=True)
+ min_len=np.min(counts)
+
+ # For each label get indexes of its items
+ coords={u:np.argwhere(labels==u).T[0][:min_len]foruinunique_labels}
+
+ # Obtain all explanations by batches
+ explanations={u:[]foruinunique_labels}
+ foruinunique_labels:
+ dl=SimpleDataloader(Filter(self._ds,coords[u]),batch_size=batch_size)
+ forbatchintqdm(dl):
+ ex=expl.predict(batch["item"],self._model,**expl_kwargs)
+ ex=minmax_normalize(ex)
+ explanations[u].append(ex)
+
+ # Compare explanations of different labels
+ diffs={u:[]foruinunique_labels}
+ foruinunique_labels:
+ forother_labelinunique_labels:
+ ifu==other_label:
+ continue
+
+ forbatch,other_batchinzip(
+ explanations[u],explanations[other_label]
+ ):
+ rmse=batch_rmse(batch,other_batch)
+ diffs[u]+=list(rmse)
+ foruinunique_labels:
+ diffs[u]=np.nanmean(diffs[u])
+
+ returnnp.nanmean([diffs[u]foruindiffs])
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/feature_importance/other_disagreement.html b/docs/_modules/xaib/metrics/feature_importance/other_disagreement.html
new file mode 100644
index 0000000..7445d64
--- /dev/null
+++ b/docs/_modules/xaib/metrics/feature_importance/other_disagreement.html
@@ -0,0 +1,57 @@
+ xaib.metrics.feature_importance.other_disagreement — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.feature_importance.other_disagreement
[docs]classOtherDisagreement(Metric):
+"""
+ Measures how distant explanations on the same data points for
+ this particular method from explanations of all others.
+ Average RMSE is used as a metric.
+ **The less the better**
+ """
+
+
[docs]defcompute(
+ self,
+ expl:Explainer,
+ batch_size:int=1,
+ expls:Union[List[Explainer],None]=None,
+ expl_kwargs:Union[Dict[Any,Any],None]=None,
+ expls_kwargs:Union[List[Dict[Any,Any]],None]=None,
+ )->None:
+ # Default initialization in case of empty
+ # parameter to not to break default argument order
+ # TODO: can revise this later
+ ifexplsisNone:
+ expls=[expl]
+ ifexpl_kwargsisNone:
+ expl_kwargs={}
+ ifexpls_kwargsisNone:
+ expls_kwargs=[{}for_inrange(len(expls))]
+
+ diffs=[]
+ forbatchintqdm(SimpleDataloader(self._ds,batch_size)):
+ item=batch["item"]
+
+ e=expl.predict(item,self._model,**expl_kwargs)
+ e=minmax_normalize(e)
+ other_e=[
+ minmax_normalize(other_expl.predict(item,self._model,**other_kwargs))
+ forother_expl,other_kwargsinzip(expls,expls_kwargs)
+ ]
+
+ foroeinother_e:
+ diffs+=batch_rmse(e,oe)
+
+ returnnp.nanmean(diffs)
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/feature_importance/parameter_randomization_check.html b/docs/_modules/xaib/metrics/feature_importance/parameter_randomization_check.html
new file mode 100644
index 0000000..851c397
--- /dev/null
+++ b/docs/_modules/xaib/metrics/feature_importance/parameter_randomization_check.html
@@ -0,0 +1,67 @@
+ xaib.metrics.feature_importance.parameter_randomization_check — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.feature_importance.parameter_randomization_check
[docs]classParameterRandomizationCheck(Metric):
+"""
+ Parameter randomization check is a sanity-check.
+ To ensure that the model influence explanations the
+ following is done. The model is changed and it is expected that
+ explanations should not stay the same is model changed.
+ This check uses random model baselines instead of same models
+ with randomized internal states.
+ Then the explanations on the original data are obtained.
+ They are compared with explanations done with the original model using
+ average RMSE on the whole dataset.
+ The further original explanations from the explanations on
+ the randomized model the better.
+
+ **The less the better**
+ - **Worst case:** explanations are the same, so it is Constant explainer.
+ - **Best case:** is reached when explanations are the opposite, distance between them maximized. The problem with this kind of metric is with its maximization. It seems redundant to maximize it because more different explanations on random states do not mean that the model is more correct.
+ It is difficult to define best case explainer in this case - the metric has no maximum value.
+ """
+
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/feature_importance/small_noise_check.html b/docs/_modules/xaib/metrics/feature_importance/small_noise_check.html
new file mode 100644
index 0000000..bb87ca0
--- /dev/null
+++ b/docs/_modules/xaib/metrics/feature_importance/small_noise_check.html
@@ -0,0 +1,58 @@
+ xaib.metrics.feature_importance.small_noise_check — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.feature_importance.small_noise_check
[docs]classSmallNoiseCheck(Metric):
+"""
+ Apply noise of small magnitude to the input data.
+ Obtain original and perturbed explanations.
+ Compare them using RMSE and average.
+ **The less the better**
+ - **Worst case:** is when explanations are hugely changed by the small variations in input
+ - **Best case:** is no variations, so constant explainer should achieve best results
+ """
+
+
\ No newline at end of file
diff --git a/docs/_modules/xaib/metrics/feature_importance/sparsity.html b/docs/_modules/xaib/metrics/feature_importance/sparsity.html
new file mode 100644
index 0000000..06b5048
--- /dev/null
+++ b/docs/_modules/xaib/metrics/feature_importance/sparsity.html
@@ -0,0 +1,50 @@
+ xaib.metrics.feature_importance.sparsity — xai-benchmark 0.2.0-alpha documentation Skip to content
Source code for xaib.metrics.feature_importance.sparsity
[docs]classSparsity(Metric):
+"""
+ Considering Gini-index as a measure of sparsity, one can give an
+ average of it as a measure of sparsity for explanations.
+ **The greater the better**
+ - **Worst case:** is achieved by constant explainer that gives same
+ importance to each feature that is equal to 1/N where N is the number
+ of features will obtain best gini index and hence worst sparsity
+ - **Best case:** is when explainer is constant and gives one feature
+ maximum value and others zero, which is the most unequal distribution
+ and is the sparsest explanation that can be given
+
+ """
+
+
Until that, consider reading reference on datasets.
\ No newline at end of file
diff --git a/docs/genindex.html b/docs/genindex.html
index 4cc3064..41b317a 100644
--- a/docs/genindex.html
+++ b/docs/genindex.html
@@ -1 +1 @@
- Index — xai-benchmark 0.2.0-alpha documentation Skip to content
Model is a wrapper around any inference of ML or other solution in the form y = f(x) it implements method predict that given certain data x returns the response y
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Model is a wrapper around any inference of ML or other solution in the form y = f(x) it implements method predict that given certain data x returns the response y
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
\ No newline at end of file
+ xaib.cases.example_selection — xai-benchmark 0.2.0-alpha documentation Skip to content
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
\ No newline at end of file
diff --git a/docs/xaib/cases.feature_importance.html b/docs/xaib/cases.feature_importance.html
index 699f550..cfa69d8 100644
--- a/docs/xaib/cases.feature_importance.html
+++ b/docs/xaib/cases.feature_importance.html
@@ -1 +1 @@
- xaib.cases.feature_importance — xai-benchmark 0.2.0-alpha documentation Skip to content
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
\ No newline at end of file
+ xaib.cases.feature_importance — xai-benchmark 0.2.0-alpha documentation Skip to content
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
\ No newline at end of file
diff --git a/docs/xaib/cases.html b/docs/xaib/cases.html
index 20202d6..0aff67e 100644
--- a/docs/xaib/cases.html
+++ b/docs/xaib/cases.html
@@ -1 +1 @@
- xaib.cases — xai-benchmark 0.2.0-alpha documentation Skip to content
\ No newline at end of file
diff --git a/docs/xaib/datasets.html b/docs/xaib/datasets.html
new file mode 100644
index 0000000..e92936f
--- /dev/null
+++ b/docs/xaib/datasets.html
@@ -0,0 +1 @@
+ xaib.datasets — xai-benchmark 0.2.0-alpha documentation Skip to content
classxaib.explainers.example_selection.constant_explainer.ConstantExplainer(train_ds, example, **kwargs)[source]¶
__init__(train_ds, example, **kwargs)→None[source]¶
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
classxaib.explainers.example_selection.constant_explainer.ConstantExplainer(train_ds, example, **kwargs)[source]¶
__init__(train_ds, example, **kwargs)→None[source]¶
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
\ No newline at end of file
diff --git a/docs/xaib/metrics.example_selection.html b/docs/xaib/metrics.example_selection.html
new file mode 100644
index 0000000..2039c0a
--- /dev/null
+++ b/docs/xaib/metrics.example_selection.html
@@ -0,0 +1 @@
+ xaib.metrics.example_selection — xai-benchmark 0.2.0-alpha documentation Skip to content
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Parameter randomization check is a sanity-check. To ensure that the model influence explanations the following is done. The model is changed and it is expected that explanations should not stay the same is model changed. This check uses random model baselines instead of same models with randomized internal states. Then the explanations on the original data are obtained. They are compared with explanations done with the original model by counting how many examples were the same for same data points. The less the better.
The less the better
Worst case: explanations are the same, so it is Constant explainer
Best case: is reached when explanations are the opposite,
distance between them maximized.
The problem with this kind of metric is with its maximization. It seems redundant to maximize it because more different explanations on random states do not mean that the model is more correct. It is difficult to define best case explainer in this case - the metric has no maximum value.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Since the nature of example selection methods is discrete - we choose an example from finite set, the use of RMSE measure may be not appropriate. This means that the metric that is similar to the one that was used in feature importance case is not suitable. More appropriate metric could be the following: take the test dataset and add small amount of noise to the items as was done in the feature importance case. Then count the number of item pairs when the example provided didn’t change and divide by the total number of items. This ratio then is how continuous example generator is - if it provides the same examples for slightly changed inputs, then it is continuous.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Given true labels and explanations in form of the examples, train another model to discriminate between labels. The quality of the model on the examples given describes the quality of the explanations. The quality can be measured by any performance metric, but it is better to adopt to imbalanced data and use F1-measure for example.
The greater the better
Best case: examples are descriptive of labels so that the model reaches best performance Worst case: constant or random baseline - giving insufficient information to grasp labels
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
\ No newline at end of file
diff --git a/docs/xaib/metrics.feature_importance.html b/docs/xaib/metrics.feature_importance.html
new file mode 100644
index 0000000..8572363
--- /dev/null
+++ b/docs/xaib/metrics.feature_importance.html
@@ -0,0 +1 @@
+ xaib.metrics.feature_importance — xai-benchmark 0.2.0-alpha documentation Skip to content
Covariate Regularity using entropy over explanations
This measures how comprehensible the explanations are in average. More simple explanations are considered better. This is measured by average Shannon entropy over batch-normalized explanations.
The less the better
Worst case: constant explainer that gives same importance to each feature, that is equal to 1/N where N is the number of features
Best case: constant explainer that gives one feature maximum value and others zero
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Obtain explanations for all targets and compare them. In binary case one metric can be computed - the difference between explanations of positive and negative targets. In case of multiclass classification we can compare one explanation to explanations of all other classes and obtain a number of metrics which can be averaged.
The more the better
Worst case: same explanations for different targets - constant explainer
Best case: different explanations for different targets
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Measures how distant explanations on the same data points for this particular method from explanations of all others. Average RMSE is used as a metric. The less the better
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Parameter randomization check is a sanity-check. To ensure that the model influence explanations the following is done. The model is changed and it is expected that explanations should not stay the same is model changed. This check uses random model baselines instead of same models with randomized internal states. Then the explanations on the original data are obtained. They are compared with explanations done with the original model using average RMSE on the whole dataset. The further original explanations from the explanations on the randomized model the better.
The less the better
Worst case: explanations are the same, so it is Constant explainer.
Best case: is reached when explanations are the opposite, distance between them maximized. The problem with this kind of metric is with its maximization. It seems redundant to maximize it because more different explanations on random states do not mean that the model is more correct.
It is difficult to define best case explainer in this case - the metric has no maximum value.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
Considering Gini-index as a measure of sparsity, one can give an average of it as a measure of sparsity for explanations. The greater the better
Worst case: is achieved by constant explainer that gives same
importance to each feature that is equal to 1/N where N is the number of features will obtain best gini index and hence worst sparsity - Best case: is when explainer is constant and gives one feature maximum value and others zero, which is the most unequal distribution and is the sparsest explanation that can be given
Should be called in any successor - initializes default meta needed. Arguments passed in it should be related to model’s hyperparameters, architecture. All additional arguments should have defaults - to be able to create model and then load. Successors may pass all of their parameters to superclass for it to be able to log them in meta. Everything that is worth to document about model and data it was trained on can be either in params or meta_prefix.
\ No newline at end of file
diff --git a/docs/xaib/metrics.html b/docs/xaib/metrics.html
new file mode 100644
index 0000000..194d839
--- /dev/null
+++ b/docs/xaib/metrics.html
@@ -0,0 +1 @@
+ xaib.metrics — xai-benchmark 0.2.0-alpha documentation Skip to content
\ No newline at end of file
diff --git a/docs/xaib/models.html b/docs/xaib/models.html
new file mode 100644
index 0000000..776fa2d
--- /dev/null
+++ b/docs/xaib/models.html
@@ -0,0 +1 @@
+ xaib.models — xai-benchmark 0.2.0-alpha documentation Skip to content