Skip to content

Commit

Permalink
Merge pull request #13 from bips-hb/v_0_3_0
Browse files Browse the repository at this point in the history
Version 0.3.0
  • Loading branch information
nkoenen authored Dec 21, 2023
2 parents bc72c79 + 2abfdd5 commit 6dea468
Show file tree
Hide file tree
Showing 75 changed files with 8,157 additions and 551 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (tf-${{ matrix.config.tf }}, R-${{ matrix.config.r }})
name: ${{ matrix.config.os }} (R-${{ matrix.config.r }})

strategy:
fail-fast: false
Expand All @@ -30,15 +30,15 @@ jobs:
- {os: 'ubuntu-latest', r: 'release'}
- {os: 'ubuntu-latest', r: 'oldrel-1'}
- {os: 'ubuntu-latest', r: 'oldrel-2'}
- {os: 'ubuntu-latest', r: 'oldrel-3'}
- {os: 'ubuntu-latest', r: 'oldrel-4'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
TORCH_TEST: 1
TORCH_INSTALL: 1
TORCH_COMMIT_SHA: "none"
PYTORCH_ENABLE_MPS_FALLBACK: 1
PYTORCH_MPS_HIGH_WATERMARK_RATIO: 0.0

steps:
- uses: actions/checkout@v3
Expand All @@ -62,7 +62,7 @@ jobs:
shell: Rscript {0}

- name: Install Tensorflow + Keras deps
run: keras::install_keras(tensorflow = '${{ matrix.config.tf }}-cpu')
run: keras::install_keras(tensorflow = 'default-cpu')
shell: Rscript {0}

- name: Check if torch is installed
Expand All @@ -77,4 +77,6 @@ jobs:

- uses: r-lib/actions/check-r-package@v2
with:
error-on: '"error"'
args: 'c("--no-multiarch", "--no-manual", "--as-cran")'
upload-snapshots: true
79 changes: 0 additions & 79 deletions .github/workflows/pr-commands.yaml

This file was deleted.

15 changes: 11 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
Type: Package
Package: innsight
Title: Get the Insights of Your Neural Network
Version: 0.2.1
Version: 0.3.0
Authors@R: c(
person("Niklas", "Koenen", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-4623-8271")),
person("Raphael", "Baudeu", , "[email protected]", role = "ctb")
)
Description: Interpretability methods to analyze the behavior and
individual predictions of modern neural networks. Implemented methods
are: 'Connection Weights' described by Olden et al. (2004)
Description: Interpretation methods for analyzing the behavior and individual
predictions of modern neural networks in a three-step procedure: Converting
the model, running the interpretation method, and visualizing the results.
Implemented methods are, e.g., 'Connection Weights' described by Olden et al. (2004)
<doi:10.1016/j.ecolmodel.2004.03.013>, layer-wise relevance
propagation ('LRP') described by Bach et al. (2015)
<doi:10.1371/journal.pone.0130140>, deep learning important features
Expand All @@ -32,17 +33,20 @@ Imports:
torch
Suggests:
covr,
fastshap,
GGally,
grid,
gridExtra,
gtable,
keras,
knitr,
lime,
luz,
neuralnet,
palmerpenguins,
plotly,
rmarkdown,
ranger,
spelling,
tensorflow,
testthat (>= 3.0.0)
Expand All @@ -54,6 +58,8 @@ Language: en-US
Roxygen: list(markdown = TRUE, r6 = TRUE)
RoxygenNote: 7.2.3
Collate:
'AgnosticMethods.R'
'AgnosticWrapper.R'
'ConnectionWeights.R'
'Convert_keras.R'
'Convert_neuralnet.R'
Expand All @@ -75,5 +81,6 @@ Collate:
'utils.R'
'utils_ggplot.R'
'utils_plotly.R'
'innsight_sugar.R'
'innsight_ggplot2.R'
'innsight_plotly.R'
27 changes: 23 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
# Generated by roxygen2: do not edit by hand

S3method(boxplot,ConnectionWeights)
S3method(boxplot,DeepLift)
S3method(boxplot,GradientBased)
S3method(boxplot,LRP)
S3method(boxplot,InterpretingMethod)
S3method(get_result,InterpretingMethod)
S3method(lime::model_type,innsight_agnostic_wrapper)
S3method(lime::predict_model,innsight_agnostic_wrapper)
S3method(plot_global,InterpretingMethod)
export(AgnosticWrapper)
export(ConnectionWeights)
export(Converter)
export(DeepLift)
export(DeepSHAP)
export(ExpectedGradient)
export(Gradient)
export(IntegratedGradient)
export(LIME)
export(LRP)
export(SHAP)
export(SmoothGrad)
export(convert)
export(get_result)
export(plot_global)
export(run_cw)
export(run_deeplift)
export(run_deepshap)
export(run_expgrad)
export(run_grad)
export(run_intgrad)
export(run_lime)
export(run_lrp)
export(run_shap)
export(run_smoothgrad)
exportMethods("+")
exportMethods("[")
exportMethods("[<-")
Expand Down Expand Up @@ -51,5 +69,6 @@ importFrom(methods,show)
importFrom(stats,aggregate)
importFrom(stats,ave)
importFrom(stats,median)
importFrom(stats,predict)
importFrom(stats,quantile)
importFrom(utils,packageVersion)
57 changes: 57 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
# innsight 0.3.0

This is a minor release but does contain a range of substantial new features
as well as visual changes, along with some bug fixes. For users, however,
nothing changes that is not set by default as in the previous version or made
aware by warnings. An exception to this are the graphics that are created
using `plot()`. These now contain a small box with information about the
prediction, the sum of the relevances and the goal of the method.

### Breaking changes

* By default, the `plot()` method now creates a small box within the plot
with the prediction for the instance and the corresponding class. This info
box also contains the sum of the relevances and, if available, the
decomposition target of the method. Displaying the box can be toggled with
the `show_preds` argument.

* The `boxplot()` function for the interpretation methods has been
renamed `plot_global()` due to the inappropriate name (especially for images).
The old method `boxplot()` can still be used, but throws a warning for image
data and executes the method `plot_global()` internally.

### New features

* We have now implemented the following other feature attribution methods:
* Integrated Gradients (`IntegratedGradient`)
* Expected Gradients (`ExpectedGradient`)
* DeepSHAP (`DeepSHAP`)
* and the model-agnostic approaches LIME (`LIME`) and Shapley values
(`SHAP`). Both can be applied to arbitrary models (by providing the
prediction function `pref_fun`) and wrap the suggested packages `lime` and
`fastshap`. However, they can only be applied to models with a single input
and output layer.

* We have added functions for the initialization of R6 classes. In this way,
we don't require prior knowledge of R6 syntax for our package. We implemented the
following methods:
* `convert(...)` for `Converter$new(...)`
* `run_grad(...)` for `Gradient$new(...)`
* `run_smoothgrad(...)` for `SmoothGrad$new(...)`
* `run_intgrad(...)` for `IntegratedGradient$new(...)`
* `run_expgrad(...)` for `ExpectedGradient$new(...)`
* `run_deeplift(...)` for `DeepLift$new(...)`
* `run_deepshap(...)` for `DeepSHAP$new(...)`
* `run_lrp(...)` for `LRP$new(...)`
* `run_cw(...)` for `ConnectionWeights$new(...)`
* `run_lime(...)` for `LIME$new(...)`
* `run_shap(...)` for `SHAP$new(...)`

* In addition to the output index with `output_idx`, the new argument
`output_label` for the output label can now also be specified in order to
calculate or visualize only certain output nodes.

### Documentation and vignettes

* Update documentation and vignettes according to the new features and changes

# innsight 0.2.1

* Add `if(require("pkgname"))` for suggested packages in examples
Expand Down
Loading

0 comments on commit 6dea468

Please sign in to comment.