diff --git a/README.md b/README.md index aa35911f..a672e3b7 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ explanation = dianna.explain_timeseries(model_path, timeseries_data=timeseries_i ``` -For visualization of the heatmap please refer to the [tutorial](https://github.com/dianna-ai/dianna/blob/main/tutorials/lime_timeseries_coffee.ipynb) +For visualization of the heatmap please refer to the [tutorial](https://github.com/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_timeseries_coffee.ipynb) ### Tabular example: @@ -216,6 +216,10 @@ plot_tabular(explanation, X_test.columns, num_features=10) # display 10 most sa ![image](https://github.com/dianna-ai/dianna/assets/25911757/ce0b76b8-f00c-468a-9732-c21704e289f6) +### IMPORTANT: Sensitivity to hyperparameters +The XAI methods (explainers) are sensitive to the choice of their hyperparameters! In this [work](https://staff.fnwi.uva.nl/a.s.z.belloum/MSctheses/MScthesis_Willem_van_der_Spec.pdf), this sensitivity to hyperparameters is researched and useful conclusions are drawn. +The default hyperparameters used in DIANNA for each explainer as well as the values for our tutorial examples are given in the Tutorials [README](./tutorials/README.md#important-hyperparameters). + ## Dashboard Explore the explanations of your trained model using the DIANNA dashboard (for now images, text and time series classification is supported). @@ -305,7 +309,7 @@ And here are links to notebooks showing how we created our models on the benchma ## Tutorials -DIANNA supports different data modalities and XAI methods. The table contains links to the relevant XAI method's papers (for some explanatory videos on the methods, please see [tutorials](./tutorials)). The DIANNA [tutorials](./tutorials) cover each supported method and data modality on a least one dataset. Our future plans to expand DIANNA with more data modalities and XAI methods are given in the [ROADMAP](https://dianna.readthedocs.io/en/latest/ROADMAP.html). +DIANNA supports different data modalities and XAI methods. The table below contains links to the relevant XAI method's papers (for some explanatory videos on the methods, please see [tutorials](./tutorials)). The DIANNA [tutorials](./tutorials) cover each supported method and data modality on a least one dataset using the default or tuned [hyperparameters](./tutorials/README.md#important-hyperparameters). Our future plans to expand DIANNA with more data modalities and XAI methods are given in the [ROADMAP](https://dianna.readthedocs.io/en/latest/ROADMAP.html). diff --git a/tutorials/README.md b/tutorials/README.md index deb1a693..1013b16e 100644 --- a/tutorials/README.md +++ b/tutorials/README.md @@ -10,36 +10,61 @@ pip install .[notebooks] For *general demonstration of DIANNA* click on the logo [Logo_ER10](https://github.com/dianna-ai/dianna/blob/main/tutorials/demo.ipynb) or run it in Colab: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/demo.ipynb). -For *tutorials on how to convert* an [Keras](https://keras.io/), [PyTorch](https://pytorch.org/), [Scikit-learn](https://scikit-learn.org/stable/) or [Tensorflow](https://www.tensorflow.org/) model to [ONNX](https://onnx.ai/), please see the [conversion tutorials](https://github.com/dianna-ai/dianna/blob/main/tutorials/conversion_onnx/). +For *tutorials on how to convert* an [Keras](https://keras.io/), [PyTorch](https://pytorch.org/), [Scikit-learn](https://scikit-learn.org/stable/) or [Tensorflow](https://github.com/tensorflow/) model to [ONNX](https://onnx.ai/), please see the [conversion tutorials](https://github.com/dianna-ai/dianna/blob/main/tutorials/conversion_onnx/). For *specific XAI methods (explainers)*: * Click on the explainer names to watch explanatory videos for the respective method. * Click on the logos below for direct access to a tutorial notebook for a combination of explainer and data modality/dataset. -Run the tutorials directly in Google Colab by clicking on the Colab buttons below: +The **datasets** and the **tasks** used in the tutorials are represented with their respective logos: +|*Data modality*|Dataset|*Task*|Logo| +|:------------|:------|:---|:----| +|*Images*|Binary MNIST | Binary digit *classification*| mnist_zero_and_one_half_size| +||[Simple Geometric (circles and triangles)](https://doi.org/10.5281/zenodo.5012824)| Binary shape *classificaiton* |SimpleGeometric Logo| +||[Simple Scientific (LeafSnap30)](https://zenodo.org/record/5061353/)| $30$ tree species leaves *classification* | LeafSnap30 Logo | +||[Imagenet](https://image-net.org/download.php) |$1000$ classes natural images *classificaiton* | ImageNet_autocrop| +|*Text*| [Stanford sentiment treebank](https://nlp.stanford.edu/sentiment/index.html) |Positive or negative movie reviews sentiment *classificaiton* | nlp-logo_half_size| +|*Timeseries* | [Coffee dataset](https://timeseriesclassification.com/description.php?Dataset=Coffee) | Binary *classificaiton* of Robusta and Aribica coffee beans| Coffe Logo| +| | [Weather dataset](https://zenodo.org/record/7525955) |Binary *classification* (summer/winter) of temperature time-series |Weather Logo| +| | Fast Radio Burst (FRB) dataset (not publicly available) | Binary *classificaiton* of Fast Radio Burst (FRB) timeseries data : noise or a real FRB. | FRB logo| +|*Tabular*| [Penguin dataset](https://www.kaggle.com/code/parulpandey/penguin-dataset-the-new-iris)| $3$ penguin spicies (Adele, Chinstrap, Gentoo) *classificaiton* | Penguin Logo | | +| | [Weather dataset](https://zenodo.org/record/7525955) | Next day sunshine hours prediction (*regression*) | Weather Logo| + +The **ONNX models** used in the tutorials are available at [dianna/models](https://github.com/dianna-ai/dianna/tree/main/dianna/models), or linked from their respective tutorial notebooks. + +Run the **tutorials** directly in Google Colab by clicking on the Colab buttons below: |*Modality* \ Method|RISE|[LIME](https://youtu.be/d6j6bofhj2M)|Kernel[SHAP](https://youtu.be/9haIOplEIGM)| |:-----|:---|:---|:---| -|*Images*|[mnist_zero_and_one_half_size](/explainers/RISE/rise_mnist.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_mnist.ipynb) | [LeafSnap30 Logo](/explainers/LIME/lime_images.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_images.ipynb) | [mnist_zero_and_one_half_size](/explainers/KernelSHAP/kernelshap_mnist.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/KernelSHAP/kernelshap_mnist.ipynb) | -| | [ImageNet_autocrop](/explainers/RISE/rise_imagenet.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_imagenet.ipynb) | | [SimpleGeometric Logo](/explainers/KernelSHAP/kernelshap_geometric_shapes.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/KernelSHAP/kernelshap_geometric_shapes.ipynb)| -|*Text* |[nlp-logo_half_size](/explainers/RISE/rise_text.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_text.ipynb) |[nlp-logo_half_size](/explainers/LIME/lime_text.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_text.ipynb) |[]()| -| *Time series*| [Weather Logo](/explainers/RISE/rise_timeseries_weather.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_timeseries_weather.ipynb)| [Weather Logo](/explainers/LIME/lime_timeseries_weather.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_timeseries_weather.ipynb)| | -| | [FRB logo](rise_timeseries_frb.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_timeseries_frb.ipynb) | [Coffee Logo](/explainers/LIME/lime_timeseries_coffee.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_timeseries_coffee.ipynb) | | -| *Tabular* | | [Penguin Logo](/explainers/LIME/lime_tabular_penguin.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_tabular_penguin.ipynb) | | -| | | [Weather Logo](/explainers/LIME/lime_tabular_weather.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_tabular_weather.ipynb)| | - -The datasets used in the tutorials are represented with their respective logos: -|Data modality|Dataset|Logo| -|:------------|:------|:---| -|*Images*|Binary MNIST | mnist_zero_and_one_half_size| -||[Simple Geometric (circles and triangles)](https://doi.org/10.5281/zenodo.5012824)| SimpleGeometric Logo| -||[Simple Scientific (LeafSnap30)](https://zenodo.org/record/5061353/)| LeafSnap30 Logo | -||[Imagenet](https://image-net.org/download.php) | ImageNet_autocrop| -|*Text*| [Stanford sentiment treebank](https://nlp.stanford.edu/sentiment/index.html) | nlp-logo_half_size| -|*Timeseries* | [Coffee dataset](https://timeseriesclassification.com/description.php?Dataset=Coffee) | Coffe Logo| -| | [Weather dataset](https://zenodo.org/record/7525955) | Weather Logo| -| | FRB dataset (not publicly available) | FRB logo| -|*Tabular*| [Penguin dataset](https://www.kaggle.com/code/parulpandey/penguin-dataset-the-new-iris)| Penguin Logo | | -| | [Weather dataset](https://zenodo.org/record/7525955) | Weather Logo| - -The ONNX models used in the tutorials are available at [dianna/models](https://github.com/dianna-ai/dianna/tree/main/dianna/models), or linked from their respective tutorial notebooks. +|*Images*|[mnist_zero_and_one_half_size](./explainers/RISE/rise_mnist.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_mnist.ipynb) | [LeafSnap30 Logo](./explainers/LIME/lime_images.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_images.ipynb) | [mnist_zero_and_one_half_size](./explainers/KernelSHAP/kernelshap_mnist.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/KernelSHAP/kernelshap_mnist.ipynb) | +| | [ImageNet_autocrop](./explainers/RISE/rise_imagenet.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_imagenet.ipynb) | | [SimpleGeometric Logo](./explainers/KernelSHAP/kernelshap_geometric_shapes.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/KernelSHAP/kernelshap_geometric_shapes.ipynb)| +|*Text* |[nlp-logo_half_size](./explainers/RISE/rise_text.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_text.ipynb) |[nlp-logo_half_size](./explainers/LIME/lime_text.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_text.ipynb) |[]()| +| *Time series*| [Weather Logo](./explainers/RISE/rise_timeseries_weather.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_timeseries_weather.ipynb)| [Weather Logo](./explainers/LIME/lime_timeseries_weather.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_timeseries_weather.ipynb)| | +| | [FRB logo](./explainers/RISE/rise_timeseries_frb.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/RISE/rise_timeseries_frb.ipynb) | [Coffee Logo](./explainers/LIME/lime_timeseries_coffee.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_timeseries_coffee.ipynb) | | +| *Tabular* | | [Penguin Logo](./explainers/LIME/lime_tabular_penguin.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_tabular_penguin.ipynb) | | +| | | [Weather Logo](./explainers/LIME/lime_tabular_weather.ipynb) or [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dianna-ai/dianna/blob/main/tutorials/explainers/LIME/lime_tabular_weather.ipynb)| | + + +### IMPORTANT: Hyperparameters +The XAI methods (explainers) are sensitive to the choice of their hyperparameters! In this [master Thesis](https://staff.fnwi.uva.nl/a.s.z.belloum/MSctheses/MScthesis_Willem_van_der_Spec.pdf), this sensitivity is researched and useful conclusions are drawn. +The default hyperparameters used in DIANNA for each explainer as well as the choices for some tutorials and their data modality (*i* - images, *txt* - text, *ts* - time series and *tab* - tabular) are given below: + +#### RISE +| Hyperparameter | Default value | ImageNet_autocrop (*i*)| mnist_zero_and_one_half_size(*i*) | nlp-logo_half_size (*txt*) | Weather Logo (*ts*)| FRB logo (*ts*)| +| ------------- | ------------- | -------------------|-----------------------------| ---------------------------------|---------------------------------|---------------------------------| +| $n_{masks}$ |**$1000$** | default | $5000$ | default | $10000$ |$5000$ | +| $p_{keep}$ | **optimized** (*i*, *txt*), **$0.5$** (*ts*) | $0.1$| $0.1$ | default | $0.1$| $0.1$| +| $n_{features}$ |**$8$** | $6$ |default | default | default | $16$ | +#### LIME +| Hyperparameter | Default value | LeafSnap30 Logo (*i*) |Weather Logo (*ts*)| Coffe Logo(*ts*)| +| ------------- | ------------- |--------| -----| -----| +| $n_{samples}$ | **$5000$** | $1000$ | $10 000$| $500$| +| Kernel Width | **$25$**| default | default| default| +| $n_{features}$ | **$10$** | $30$ | default| default| + +#### KernalSHAP +| Hyperparameter | Default value | mnist_zero_and_one_half_size (*i*)| SimpleGeometric Logo (*i*)| +| ------------- | ------------- |------------- |------------- | +| $n_{samples}$ | **auto/int** | $1000$| $2000$ | +| $n_{segments}$ | **$100$** |$200$ |$200$ | +