Skip to content

Commit

Permalink
finish render chapter 10
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Sep 25, 2021
1 parent 7f56d72 commit 9167071
Show file tree
Hide file tree
Showing 33 changed files with 992 additions and 654 deletions.
11 changes: 8 additions & 3 deletions 10_dl_cnn.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ knit_hooks$set(output = function(x, options) {

```{r include = FALSE, eval = !julias_computer}
library(keras)
knitr::opts_chunk$set(message = FALSE,
warning = FALSE, error = TRUE)
tensorflow::tf$random$set_seed(1234)
junk <- keras_model_sequential()
hook_output = knit_hooks$get('output')
knit_hooks$set(output = function(x, options) {
# this hook is used only when the linewidth option is not NULL
Expand Down Expand Up @@ -608,7 +613,7 @@ explanation

The output comes in a tibble format where `feature` and `feature_weight` are included, but fortunately lime contains some functions to visualize these weights. Figure \@ref(fig:limeplotfeatures) shows the result of using `plot_features()`, with each facet containing an observation-label pair and the bars showing the weight of the different tokens. Bars in the positive direction (darker) indicate that the weights _support_ the prediction and bars in the negative direction (lighter) indicate _contradictions_. This chart is great for finding the most prominent features in an observation.

```{r, eval=FALSE}
```{r}
plot_features(explanation)
```

Expand All @@ -621,7 +626,7 @@ plot_features(explanation) +

\index{models!explainability}Figure \@ref(fig:limeplottextexplanations) shows the weights by highlighting the words directly in the text. This gives us a way to see if any local patterns contain a lot of weight.

```{r, eval=FALSE}
```{r}
plot_text_explanations(explanation)
```

Expand Down Expand Up @@ -684,7 +689,7 @@ explanation <- explain(

Explanations based on these two sentences are fairly similar as we can see in Figure \@ref(fig:robustlimeplottextexplanations). However, notice how the removal of the word "whole" affects the weights of the other words in the examples, in some cases switching the sign from supporting to contradicting.

```{r, eval=FALSE}
```{r}
plot_text_explanations(explanation)
```

Expand Down
276 changes: 173 additions & 103 deletions docs/10_dl_cnn.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/10_dl_cnn_files/figure-html/allcnnroccurve-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/10_dl_cnn_files/figure-html/bpeheatmap-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/10_dl_cnn_files/figure-html/cnnfinalroc-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/10_dl_cnn_files/figure-html/cnnheatmap-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/10_dl_cnn_files/figure-html/cnnheatmapfinal-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/10_dl_cnn_files/figure-html/cnnroccurve-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9167071

Please sign in to comment.