Skip to content

Commit 74bef24

Browse files
authored
Merge pull request #216 from dianna-ai/203_tutorials_docs
create links under docs/tutorials and correct header levels
2 parents 4e024ac + aeb9381 commit 74bef24

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

docs/tutorials/lime_text.nblink

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "../../tutorials/lime_text.ipynb"
3+
}

docs/tutorials/rise_text.nblink

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "../../tutorials/rise_text.ipynb"
3+
}

tutorials/lime_images.ipynb

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"id": "african-verse",
66
"metadata": {},
77
"source": [
8+
89
"<img width=\"150\" alt=\"Logo_ER10\" src=\"https://user-images.githubusercontent.com/3244249/151994514-b584b984-a148-4ade-80ee-0f88b0aefa45.png\">\n",
910
"\n",
10-
"## Interpreting a leaf identification model with LIME\n",
11+
"### Interpreting a leaf identification model with LIME\n",
12+
1113
"This notebook demonstrates the use of DIANNA with the LIME method on the [leafsnap30 image dataset](https://zenodo.org/record/5061353#.YeUwXy1Q30o). A pre-trained neural network classifier is used,\n",
1214
"which identifies the species of leaf based on an image of it. \n",
1315
"\n",
@@ -21,7 +23,7 @@
2123
"id": "a5cf6f82-c1c7-4814-ae0f-5a1c0b8578f6",
2224
"metadata": {},
2325
"source": [
24-
"## 1. Imports and paths"
26+
"#### 1. Imports and paths"
2527
]
2628
},
2729
{
@@ -57,7 +59,7 @@
5759
"id": "bad4f5b1-6097-4ef3-98c4-78432ad640b0",
5860
"metadata": {},
5961
"source": [
60-
"## 2. Loading the data\n",
62+
"#### 2. Loading the data\n",
6163
"Two files are loaded here:\n",
6264
"1. A file containg the numerical index that belongs to each class (=species of leaf). This is used so we know which output of the neural network corresponds to the class we want to run LIME on.\n",
6365
"2. An image of a leaf, belonging to the Acer Rubrum species.\n",
@@ -119,7 +121,7 @@
119121
"id": "02ccb569-a2e9-41b3-a732-f6c31a929a90",
120122
"metadata": {},
121123
"source": [
122-
"## 3. Applying LIME with DIANNA\n",
124+
"#### 3. Applying LIME with DIANNA\n",
123125
"The simplest way to run DIANNA on image data is with `dianna.explain_image`. The arguments are:\n",
124126
"* The path to the model in ONNX format\n",
125127
"* The image we want to explain\n",
@@ -159,7 +161,7 @@
159161
"id": "7e177746-3654-4518-9c1c-b7047f922273",
160162
"metadata": {},
161163
"source": [
162-
"### 4. Visualization\n",
164+
"#### 4. Visualization\n",
163165
"DIANNA includes a visualization package, capable of overlaying the explanation heatmap on the original input image. \n",
164166
"In this visualization, important superpixels are red, while less important superpixels are blue."
165167
]

tutorials/lime_text.ipynb

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"id": "african-verse",
66
"metadata": {},
77
"source": [
8+
89
"<img width=\"150\" alt=\"Logo_ER10\" src=\"https://user-images.githubusercontent.com/3244249/151994514-b584b984-a148-4ade-80ee-0f88b0aefa45.png\">\n",
910
"\n",
10-
"## Interpreting a movie review sentiment model with LIME\n",
11+
"### Interpreting a movie review sentiment model with LIME\n",
12+
1113
"This notebook demonstrates the use of DIANNA with the LIME method on the [Stanford Sentiment Treebank dataset](https://nlp.stanford.edu/sentiment/index.html) which contains one-sentence movie reviews. See also [their paper](https://nlp.stanford.edu/~socherr/EMNLP2013_RNTN.pdf). A pre-trained neural network classifier is used, which identifies whether a movie review is positive or negative.\n",
1214
"\n",
1315
"LIME (Local Interpretable Model-agnostic Explanations) is an explainable-AI method that aims to create an interpretable model that locally represents the classifier. For more details see the [LIME paper](https://arxiv.org/abs/1602.04938)."
@@ -18,7 +20,7 @@
1820
"id": "a5cf6f82-c1c7-4814-ae0f-5a1c0b8578f6",
1921
"metadata": {},
2022
"source": [
21-
"## 1. Imports and paths"
23+
"#### 1. Imports and paths"
2224
]
2325
},
2426
{
@@ -58,7 +60,7 @@
5860
"id": "bad4f5b1-6097-4ef3-98c4-78432ad640b0",
5961
"metadata": {},
6062
"source": [
61-
"## 2. Loading the model\n",
63+
"#### 2. Loading the model\n",
6264
"\n",
6365
"The classifier is stored in ONNX format. It accepts numerical tokens as input, and outputs a score between 0 and 1, where 0 means the review is negative and 1 that it is positive. \n",
6466
"Here we define a class to run the model, which accepts a sentence (i.e. string) as input instead and returns two classes: negative and positive."
@@ -136,7 +138,7 @@
136138
"id": "02ccb569-a2e9-41b3-a732-f6c31a929a90",
137139
"metadata": {},
138140
"source": [
139-
"## 3. Applying LIME with DIANNA\n",
141+
"#### 3. Applying LIME with DIANNA\n",
140142
"The simplest way to run DIANNA on text data is with `dianna.explain_text`. The arguments are:\n",
141143
"* The function that runs the model (a path to a model in ONNX format is also accepted)\n",
142144
"* The text we want to explain\n",
@@ -191,9 +193,12 @@
191193
"id": "7e177746-3654-4518-9c1c-b7047f922273",
192194
"metadata": {},
193195
"source": [
194-
"### 4. Visualization\n",
196+
197+
"#### 4. Visualization\n",
198+
195199
"DIANNA includes a visualization package, capable of highlighting the relevance of each word in the text for a chosen class. The visualization is in HTML format.\n",
196200
"Words in favour of the selected class are highlighted in red, while words against the selected class - in blue."
201+
197202
]
198203
},
199204
{

tutorials/rise_text.ipynb

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"id": "african-verse",
66
"metadata": {},
77
"source": [
8+
89
"<img width=\"150\" alt=\"Logo_ER10\" src=\"https://user-images.githubusercontent.com/3244249/151994514-b584b984-a148-4ade-80ee-0f88b0aefa45.png\">\n",
910
"\n",
10-
"## Interpreting a movie review sentiment model with RISE\n",
11+
"### Interpreting a movie review sentiment model with RISE\n",
12+
1113
"This notebook demonstrates the use of DIANNA with the RISE method on the [Stanford Sentiment Treebank dataset](https://nlp.stanford.edu/sentiment/index.html) which contains one-sentence movie reviews. See also [their paper](https://nlp.stanford.edu/~socherr/EMNLP2013_RNTN.pdf). A pre-trained neural network classifier is used, which identifies whether a movie review is positive or negative.\n",
1214
"\n",
1315
"RISE is short for Randomized Input Sampling for Explanation of Black-box Models. It estimates each word's relevance to the model's decision empirically by probing the model with randomly masked versions of the input image and obtaining the corresponding outputs. \n",
@@ -22,7 +24,7 @@
2224
"id": "a5cf6f82-c1c7-4814-ae0f-5a1c0b8578f6",
2325
"metadata": {},
2426
"source": [
25-
"## 1. Imports and paths"
27+
"#### 1. Imports and paths"
2628
]
2729
},
2830
{
@@ -62,7 +64,7 @@
6264
"id": "bad4f5b1-6097-4ef3-98c4-78432ad640b0",
6365
"metadata": {},
6466
"source": [
65-
"## 2. Loading the model\n",
67+
"#### 2. Loading the model\n",
6668
"\n",
6769
"The classifier is stored in ONNX format. It accepts numerical tokens as input, and outputs a score between 0 and 1, where 0 means the review is negative and 1 that it is positive. \n",
6870
"Here we define a class to run the model, which accepts a sentence (i.e. string) as input instead and returns two classes: negative and positive."
@@ -139,7 +141,7 @@
139141
"id": "02ccb569-a2e9-41b3-a732-f6c31a929a90",
140142
"metadata": {},
141143
"source": [
142-
"## 3. Applying RISE with DIANNA\n",
144+
"#### 3. Applying RISE with DIANNA\n",
143145
"The simplest way to run DIANNA on text data is with `dianna.explain_text`. The arguments are:\n",
144146
"* The function that runs the model (a path to a model in ONNX format is also accepted)\n",
145147
"* The text we want to explain\n",
@@ -208,9 +210,11 @@
208210
"id": "7e177746-3654-4518-9c1c-b7047f922273",
209211
"metadata": {},
210212
"source": [
211-
"### 4. Visualization\n",
213+
214+
"#### 4. Visualization\n",
212215
"DIANNA includes a visualization package, capable of highlighting each word of a text based on their relevance scores. The visualization is in HTML format.\n",
213216
"In this visualization, words in favour of the selected class are highlighted in red. Words against the selected class are not present in this example, otherwise they would be highlighted in blue."
217+
214218
]
215219
},
216220
{

0 commit comments

Comments
 (0)