Go top
Technology offer

NeuralSens: Sensitivity Analysis of Neural Networks

The NeuralSens package is designed for performing sensitivity analysis of multi-layer perceptron (MLP) neural networks in R and Python. The package calculates the partial derivatives of the output with regard to the input variables of a MLP model, which helps in evaluating variable importance and understanding the relationships between input and output variables. This is useful for both simplifying neural network models by identifying and removing irrelevant inputs and gaining deeper insights into the model's behavior.

Dr. Jaime Pizarroso Gonzalo

In the field of machine learning, understanding how input variables influence the output of a neural network model is crucial for improving model performance and interpretability. Sensitivity analysis provides insights into these relationships, allowing for the identification of key variables and the simplification of complex models.

NeuralSens is an R and Python package that facilitates sensitivity analysis of Multi-Layer Perceptron (MLP) models using the partial derivatives method. It calculates the partial derivatives of the output with respect to the input variables of a MLP model. This information is used to assess variable importance and to understand the intricate relationships between inputs and outputs.

The NeuralSens package requires the following inputs to perform sensitivity analysis:

  • Neural Network Weights: A numeric vector containing the weights of the neural network, concatenating the weights of the layers in order from the first hidden layer to the output layer. Bias weights should be included before the weights of the same layer.
  • Network Structure: A numeric vector specifying the number of neurons in each layer of the neural network, starting with the input layer and ending with the output layer.
  • Activation Functions: Functions representing the activation functions of each layer and their derivatives. If custom activation functions are used, they must be provided explicitly.
  • Dataset for Analysis: A dataset where the partial derivatives of the neural network model shall be calculated, which includes the input variables and corresponding outputs.

After the partial derivatives are calculated, the expected outputs are:

  • Sensitivity Measures: The package calculates several sensitivity measures including mean sensitivity, sensitivity standard deviation, and mean squared sensitivity for each input variable with respect to the output.
  • Sensitivity Analysis Object: An object that contains the sensitivity analysis results, including raw sensitivity data, model structure, and input-output variable names.
  • Plots and Visualizations: The package provides functions to generate various plots that visually represent the sensitivity measures, such as:
    • Graphical representation of the sensitivity measures.
    • Displays of the relationship between the sensitivities and the input variable values.
    • Visualization of the evolution of sensitivities over time, useful for time-series data.
  • Methods to summarize and print the sensitivity analysis results, providing insights into the linearity and non-linearity of the relationships between inputs and outputs.

By utilizing the NeuralSens package, users can gain a deeper understanding of their neural network models, identify key input variables, and enhance model interpretability, ultimately leading to more effective and efficient machine learning solutions.

 

NeuralSens application

To facilitate and illustrate the use of the NeuralSens library, an application based on Shiny has been developed. This application provides an easy-to-use interface to perform sensitivity analysis and visualize results without requiring advanced programming knowledge.

The application is sponsored by the Santalucía Chair of Analytics for Education at the Universidad Pontificia Comillas. You can download the app for Windows and MacOS from the following links:

To obtain more information about the Santalucía Chair of Analytics for Education, click here.

 

Projects

Development of an interactive application for data analysis using neural networks and the NeuralSens methodology for interpretability

 

Journal publications

[1] Pizarroso, J., Portela, J., & Muñoz, A. (2022). NeuralSens: Sensitivity Analysis of Neural Networks. Journal of Statistical Software, 102(7), 1–36. https://doi.org/10.18637/jss.v102.i07

[2] Pizarroso, J., Alfaya, D., Portela, J., & Muñoz, A. (2024). Metric Tools for Sensitivity Analysis. arXiv:2305.02368

 

Useful links