Package: innsight 0.3.2.9000

Niklas Koenen

innsight: Get the Insights of Your Neural Network

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 ('DeepLIFT') described by Shrikumar et al. (2017) <doi:10.48550/arXiv.1704.02685> and gradient-based methods like 'SmoothGrad' described by Smilkov et al. (2017) <doi:10.48550/arXiv.1706.03825>, 'Gradient x Input' or 'Vanilla Gradient'. Details can be found in the accompanying scientific paper: Koenen & Wright (2024, Journal of Statistical Software, <doi:10.18637/jss.v111.i08>).

Authors:Niklas Koenen [aut, cre], Raphael Baudeu [ctb]

innsight_0.3.2.9000.tar.gz
innsight_0.3.2.9000.zip(r-4.7)innsight_0.3.2.9000.zip(r-4.6)innsight_0.3.2.9000.zip(r-4.5)
innsight_0.3.2.9000.tgz(r-4.6-any)innsight_0.3.2.9000.tgz(r-4.5-any)
innsight_0.3.2.9000.tar.gz(r-4.7-any)innsight_0.3.2.9000.tar.gz(r-4.6-any)
innsight_0.3.2.9000.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
innsight/json (API)

# Install 'innsight' in R:
install.packages('innsight', repos = c('https://bips-hb.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/bips-hb/innsight/issues

Pkgdown/docs site:https://bips-hb.github.io

On CRAN:

Conda:

7.43 score 31 stars 1 packages 39 scripts 789 downloads 33 exports 32 dependencies

Last updated from:bc63149b2b. Checks:4 OK, 5 NOTE. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK185
source / vignettesOK279
linux-release-x86_64OK160
macos-release-arm64NOTE131
macos-oldrel-arm64NOTE155
windows-develNOTE183
windows-releaseNOTE188
windows-oldrelNOTE227
wasm-releaseOK131

Exports:AgnosticWrapperas_innsight_resultConnectionWeightsconvertConverterDeepLiftDeepSHAPExpectedGradientget_resultGradientIntegratedGradientLIMELRPplotplot_globalprintrun_cwrun_deepliftrun_deepshaprun_expgradrun_gradrun_intgradrun_limerun_lrprun_shaprun_smoothgradSHAPshowSmoothGradtorch_expgradtorch_gradtorch_intgradtorch_smoothgrad

Dependencies:backportsbitbit64callrcheckmateclicorocpp11descfarverggplot2gluegtableisobandjsonlitelabelinglifecyclemagrittrotelprocessxpsR6RColorBrewerRcpprlangS7safetensorsscalestorchvctrsviridisLitewithr

Direct Torch Gradient Methods
Introduction | Available Methods | Basic Usage | Vanilla Gradient | Gradient×Input | Integrated Gradients | SmoothGrad | Expected Gradients | Working with Real Data | Selecting Output Nodes | Data Type Support | When to Use Which Method? | Comparison with Converter Methods | Using Results as innsight Objects | Getting Results as Objects | Plotting with Objects | Summary

Last update: 2026-02-22
Started: 2026-02-22

Example 2: Penguin dataset with torch and luz
Explore the dataset | Step 0: Train a model | Data preparation | Create and train the model | Step 1: Convert the model | Step 2: Apply methods | Separated categorical variables | Summarized categorical variables | Step 3: Visualization | Plot individual results | Plot summarized results

Last update: 2025-03-28
Started: 2023-02-01

In-depth explanation
Step 1: The Converter | Argument model | Package torch | Package keras | Package neuralnet | Model as named list | Adding layers to your list-model | Argument input_dim | Argument input_names | Argument output_names | Other arguments | Argument dtype | Argument save_model_as_list | Fields | Step 2: Apply selected method | Arguments | Argument converter | Argument data | Argument channels_first | Argument output_idx | Argument output_label | Argument ignore_last_act | Argument dtype | Methods | Vanilla Gradient | SmoothGrad | Gradient$\times$Input and SmoothGrad$\times$Input | Layer-wise Relevance Propagation (LRP) | Deep Learning Important Features (DeepLift) | Apply method DeepLift with rescale rule | Get result | Integrated Gradients | Apply method IntegratedGradient | Crate model with package 'neuralnet' | Step 1: Create 'Converter' | Step 2: Apply Expected Gradient | Verify exact decomposition | Show the error between both | Show the result | Step 3: Show and plot the results | Get results | Array (type = 'array') | Show the result for datapoint 1 and 10 | Torch Tensor (type = 'torch_tensor') | Data.Frame (type = 'data.frame') | get the result from the tabular model | calculate mean absolute gradient | Plot summarized results plot_global() | Advanced plotting | Create model with tabular data as inputs and one output layer | Create model with images as inputs and two output layers | Create model with images and tabular data as inputs and two | output layers | Now we can add geoms, themes and scales as usual for ggplot2 objects | This object is still an 'innsight_ggplot2' object... | ... but all ggplot2 geoms, themes and scales are added | If the respective plot allows it, you can also use the already existing | mapping function and data: | Show the whole plot | Now you can select a single plot by passing the row and column index, | e.g. the plot for output "Y1" and data point 3 | This time a ggplot2 object is returned | Show the new plot | Results for multiple input and/or output layers | Select a restyled subplot (default) | The same plot as shown in the whole plot | Remove colorbar in the plot for data point 3 and output 'Y1' in output | layer 1 (in such situations the restyle argument is useful) | Change colorscale in the plot for data point 1 and output 'Y2' in output | layer 2 | Change the theme in all plots for data point 3 | Show the result with all changes | e.g. the plot for output "Y1", data point 3 and the second input layer | It's a plotly object | Show the plot | All methods behave the same and return a plotly object | You can also pass additional arguments to the method 'plotly::subplot', | e.g. the margins

Last update: 2025-03-28
Started: 2023-02-01

Introduction to innsight
Why innsight? | How to use | Step 1: Model creation and converting | Usage with torch models | Create model | Convert the model | Convert model with input and output names | Usage with neuralnet models | Convert model | Step 2: Apply selected method | You can also use the helper function run_grad | Apply method 'Gradient x Input' for CNN | Apply method 'IntegratedGradient' for CNN with the average baseline | Apply method 'LRP' for CNN with alpha-beta-rule | Apply local method 'ConnectionWeights' for a CNN | Note: This variant requires input data | Step 3: Show and plot the results | Get results | or with the S3 method | Show the result for data point 1 and 71 | Show for datapoint 1 and 71 the result

Last update: 2025-03-28
Started: 2021-11-22

Example 1: Iris dataset with torch
Step 0: Train a model | Step 1: Convert the model | Step 2: Apply methods | Step 3: Visualization | Plot individual results | ggplot2-based plot | plotly-based plot | Plot summarized results

Last update: 2023-12-21
Started: 2023-02-01

Readme and manuals

Help Manual

Help pageTopics
Get the insight of your neural networkinnsight-package innsight
Indexing plots of 'innsight_ggplot2'[,innsight_ggplot2-method [.innsight_ggplot2 [<-,innsight_ggplot2-method [<-.innsight_ggplot2 [[,innsight_ggplot2-method [[.innsight_ggplot2 [[<-,innsight_ggplot2-method [[<-.innsight_ggplot2
Indexing plots of 'innsight_plotly'[,innsight_plotly-method [.innsight_plotly [[,innsight_plotly-method [[.innsight_plotly
Generic add function for 'innsight_ggplot2'+,innsight_ggplot2,ANY-method +.innsight_ggplot2
Super class for model-agnostic interpretability methodsAgnosticWrapper
Convert gradient results to an innsight result objectas_innsight_result
Connection weights methodConnectionWeights
Converted torch-based modelConvertedModel
Converter of an artificial neural networkConverter
Deep learning important features (DeepLift)DeepLift
Deep Shapley additive explanations (DeepSHAP)DeepSHAP
Expected GradientsExpectedGradient
Get the result of an interpretation methodget_result
Vanilla Gradient and Gradient\timesInputGradient
Super class for gradient-based interpretation methodsGradientBased
S4 class for ggplot2-based plotsinnsight_ggplot2
S4 class for plotly-based plotsinnsight_plotly
Syntactic sugar for object constructionconvert innsight_sugar run_cw run_deeplift run_deepshap run_expgrad run_grad run_intgrad run_lime run_lrp run_shap run_smoothgrad
Integrated GradientsIntegratedGradient
Super class for interpreting methodsInterpretingMethod
Local interpretable model-agnostic explanations (LIME)LIME
Layer-wise relevance propagation (LRP)LRP
Get the result of an interpretation methodplot_global
Generic print, plot and show for 'innsight_ggplot2'plot,innsight_ggplot2-method plot.innsight_ggplot2 print,innsight_ggplot2-method print.innsight_ggplot2 show,innsight_ggplot2-method show.innsight_ggplot2
Generic print, plot and show for 'innsight_plotly'plot,innsight_plotly-method plot.innsight_plotly print,innsight_plotly-method print.innsight_plotly show,innsight_plotly-method show.innsight_plotly
Shapley valuesSHAP
SmoothGrad and SmoothGrad\timesInputSmoothGrad
Direct Expected Gradients for torch modelstorch_expgrad
Direct gradient calculation for torch modelstorch_grad
Direct Integrated Gradients for torch modelstorch_intgrad
Direct SmoothGrad for torch modelstorch_smoothgrad