Skip to content

Commit

Permalink
Merge pull request #13 from HelmholtzAI-Consultants-Munich/neuronflow…
Browse files Browse the repository at this point in the history
…-patch-4

Neuronflow patch 4
  • Loading branch information
lisa-sousa committed Dec 4, 2023
2 parents ce1566e + 4414da6 commit 05601be
Show file tree
Hide file tree
Showing 21 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Tutorials for eXplainable Artificial Intelligence (XAI) methods

This repository contains a collection of self-explanatory tutorials for different model-agnostic and model-specific XAI methods.
Each tutorial comes in a Jupyter Notebook, which contains a short video lecture and practical exercises.
Each tutorial comes in a Jupyter Notebook, containing a short video lecture and practical exercises.
The material has already been used in the context of two courses: the Zero to Hero Summer Academy (fully online) and ml4hearth (hybrid setting).
The course material can be adjusted according to the available time frame and the schedule.
The material is self-explanatory and can also be consumed offline.
Expand All @@ -17,7 +17,7 @@ The learning objectives are:
- understand the importance of interpretability
- discover the existing model-agnostic and model-specific XAI methods
- learn how to interpret the outputs and graphs of those methods with hands-on exercises
- learn to choose which method is suitable for a specific task
- learn to chose which method is suitable for a specific task

## Venue
The course will be fully online:
Expand Down Expand Up @@ -80,7 +80,7 @@ Homework 1: Comparison notebook - [Tutorial_XAI_for_ImageAnalysis](https://githu

## Requirements and Setup

Executing the notebooks on the browser is possible, by clicking the 'Open in Colab' button. This option doesn't require any further installation, but the user must have access to a Google account.
It is possible to either create an environment and install all the necessary packages locally (using the requirements.txt file) or to execute the notebooks on the browser, by clicking the 'Open in Colab' button. This second option doesn't require any further installation, but the user must have access to a Google account.

If you prefer to run the notebooks on your device, create a virtual environment using the requirements.txt file:
```
Expand All @@ -92,7 +92,7 @@ pip install -r requirements.txt
Once your environment is created, clone `Juelich-2023` brach branch of the repo using the following command:

```
git clone --branch SummerAcademy-2023 https://github.com/HelmholtzAI-Consultants-Munich/XAI-Tutorials.git
git clone --branch Juelich-2023 https://github.com/HelmholtzAI-Consultants-Munich/XAI-Tutorials.git
```

## Contributions
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
matplotlib==3.5.3
numpy==1.23.2
pandas==1.4.4
seaborn==0.11.2
seaborn
shap==0.42.1
lime==0.2.0.1
fgclustering
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 7 additions & 7 deletions xai-for-tabular-data/Tutorial_XAI_for_RandomForests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"### Setup Colab environment\n",
"\n",
"If you installed the packages and requirements on your own machine, you can skip this section and start from the import section.\n",
"Otherwise, you can follow and execute the tutorial on your browser. In order to start working on the notebook, click on the following button, this will open this page in the Colab environment and you will be able to execute the code on your own.\n",
"Otherwise, you can follow and execute the tutorial on your browser. In order to start working on the notebook, click on the following button. This will open this page in the Colab environment and you will be able to execute the code on your own.\n",
"\n",
"<a href=\"https://colab.research.google.com/github/HelmholtzAI-Consultants-Munich/Zero2Hero---Introduction-to-XAI/blob/Juelich-2023/xai-for-tabular-data/Tutorial_XAI_for_RandomForests.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
Expand Down Expand Up @@ -136,7 +136,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook, we will work with the **Palmer penguins dataset**, containing the information on 3 different species of penguins - Adelie, Chinstrap, and Gentoo - which were observed in the Palmer Archipelago near Palmer Station, Antarctica. The dataset consist of a total of 344 penguings, together with their size measurements, clutch observations, and blood isotope ratios. Our goal is to **predict the species** of Palmer penguins and find out the major differences among them.\n",
"In this notebook, we will work with the **Palmer penguins dataset**, containing the information on 3 different species of penguins - Adelie, Chinstrap, and Gentoo - which were observed in the Palmer Archipelago near Palmer Station, Antarctica. The datasets consist of a total of 344 penguins, together with their size measurements, clutch observations, and blood isotope ratios. Our goal is to **predict the species** of Palmer penguins and find out the major differences among them.\n",
"\n",
"<center><img src=\"https://github.com/HelmholtzAI-Consultants-Munich/XAI-Tutorials/blob/main/docs/source/_figures/dataset_penguins.png?raw=true\" width=\"500\" /></center>\n",
"\n",
Expand All @@ -147,7 +147,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In the notebook [*Dataset-Penguins.ipynb*](../data_and_models/Dataset-Penguins.ipynb), we explain how to do the exploratory data analysis, preprocess the data and in the notebook [*Model-RandomForest.ipynb*](../data_and_models/Model-RandomForest.ipynb) we train a Random Forest model with the given data. The focus of this notebook lies on the interpretation of the trained model and not on the data pre-processing or model training part. Hence, here we simply load the data and the model that we saved in the previous notebook."
"In the notebook [*Dataset-Penguins.ipynb*](../data_and_models/Dataset-Penguins.ipynb), we explain how to do the exploratory data analysis, preprocess the data and in the notebook [*Model-RandomForest.ipynb*](../data_and_models/Model-RandomForest.ipynb) we train a Random Forest model with the given data. This notebook focuses on the interpretation of the trained model and not on the data pre-processing or model training part. Hence, here we simply load the data and the model that we saved in the previous notebook."
]
},
{
Expand Down Expand Up @@ -236,7 +236,7 @@
"source": [
"#### Permutation Feature Importance\n",
"\n",
"In the [Tutorial_PermutationFeatureImportance.ipynb](../xai-model-agnostic/Tutorial_PermutationFeatureImportance.ipynb) notebook you were introduced to the model-agnostic Permutation Feature Importance. Recall, the Permutation Feature Importance is defined to be the decrease in a model score when a single feature value is randomly permuted. This procedure breaks the relationship between the feature and the target, thus the drop in the model score is indicative of how much the model depends on the feature. Lets now apply it to our penguins dataset:"
"In the [Tutorial_PermutationFeatureImportance.ipynb](../xai-model-agnostic/Tutorial_PermutationFeatureImportance.ipynb) notebook you were introduced to the model-agnostic Permutation Feature Importance. Recall, the Permutation Feature Importance is defined to be the decrease in a model score when a single feature value is randomly permuted. This procedure breaks the relationship between the feature and the target. Thus the drop in the model score is indicative of how much the model depends on the feature. Lets now apply it to our penguins dataset:"
]
},
{
Expand All @@ -245,7 +245,7 @@
"source": [
"<font color='green'>\n",
"\n",
"#### Task 1: Calculate permutation feature impotance for the trained Random Forest model. Therefore, define the appropriate scorer and compute the permutation feature importance scores by filling in the two lines below.\n"
"#### Task 1: Calculate permutation feature importance for the trained Random Forest model. Therefore, define the appropriate scorer and compute the permutation feature importance scores by filling in the two lines below.\n"
]
},
{
Expand Down Expand Up @@ -315,7 +315,7 @@
"source": [
"### Interpretation with SHAP\n",
"\n",
"In the [Tutorial_SHAP.ipynb](../xai-model-agnostic/Tutorial_SHAP.ipynb) notebook you were introduced to the model-agnostic SHAP method. Recall, with SHAP we get contrastive explanations that compare the prediction with the average prediction. The global interpretations are consistent with the local explanations, since the Shapley values are the “atomic unit” of the global interpretations."
"In the [Tutorial_SHAP.ipynb](../xai-model-agnostic/Tutorial_SHAP.ipynb) notebook you, were introduced to the model-agnostic SHAP method. Recall, with SHAP we get contrastive explanations that compare the prediction with the average prediction. The global interpretations are consistent with the local explanations, since the Shapley values are the “atomic unit” of the global interpretations."
]
},
{
Expand Down Expand Up @@ -408,7 +408,7 @@
"source": [
"<font color='green'>\n",
"\n",
"#### Task 4: Plot the summary plot as beeswarm plot for the SHAP values by filling in the line below. For multi-class calssification, there have to be plotted per class. \n",
"#### Task 4: Plot the summary plot as a beeswarm plot for the SHAP values by filling in the line below. For multi-class calssification, it has to be plotted per class. \n",
"_Hint:_ check out the SHAP Tutorial's extra material for multi-class SHAP analysis!"
]
},
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 05601be

Please sign in to comment.