Table of Contents
Fetching ...

nn2poly: An R Package for Converting Neural Networks into Interpretable Polynomials

Pablo Morala, Jenny Alexandra Cifuentes, Rosa E. Lillo, Iñaki Ucar

TL;DR

NN2Poly tackles the interpretability gap of dense feed-forward networks by converting trained MLPs into polynomial surrogates of total order up to $Q_{ ext{max}}$, where neuron inputs/outputs are represented as polynomials and activations are expanded via a Taylor series around 0. The method yields coefficient terms that encode both main effects and interactions among variables, enabling transparent post-hoc explanations for tabular data and facilitating visualization of interaction terms up to order $Q_{ ext{max}}$. The R package nn2poly connects training-constrained networks in TensorFlow/Keras or Torch/Luz to their polynomial representations, providing prediction and plotting capabilities, plus efficient C++-backed computations for the combinatorial steps and internal layer polynomials when keep_layers is used. This work broadens XAI by delivering interaction-aware, interpretable polynomials as faithful surrogates to deep networks, with practical utility for regulated domains requiring explicit interaction explanations and faster, polynomial-based inference.

Abstract

The nn2poly package provides the implementation in R of the NN2Poly method to explain and interpret feed-forward neural networks by means of polynomial representations that predict in an equivalent manner as the original network.Through the obtained polynomial coefficients, the effect and importance of each variable and their interactions on the output can be represented. This capabiltiy of capturing interactions is a key aspect usually missing from most Explainable Artificial Intelligence (XAI) methods, specially if they rely on expensive computations that can be amplified when used on large neural networks. The package provides integration with the main deep learning framework packages in R (tensorflow and torch), allowing an user-friendly application of the NN2Poly algorithm. Furthermore, nn2poly provides implementation of the required weight constraints to be used during the network training in those same frameworks. Other neural networks packages can also be used by including their weights in list format. Polynomials obtained with nn2poly can also be used to predict with new data or be visualized through its own plot method. Simulations are provided exemplifying the usage of the package alongside with a comparison with other approaches available in R to interpret neural networks.

nn2poly: An R Package for Converting Neural Networks into Interpretable Polynomials

TL;DR

NN2Poly tackles the interpretability gap of dense feed-forward networks by converting trained MLPs into polynomial surrogates of total order up to , where neuron inputs/outputs are represented as polynomials and activations are expanded via a Taylor series around 0. The method yields coefficient terms that encode both main effects and interactions among variables, enabling transparent post-hoc explanations for tabular data and facilitating visualization of interaction terms up to order . The R package nn2poly connects training-constrained networks in TensorFlow/Keras or Torch/Luz to their polynomial representations, providing prediction and plotting capabilities, plus efficient C++-backed computations for the combinatorial steps and internal layer polynomials when keep_layers is used. This work broadens XAI by delivering interaction-aware, interpretable polynomials as faithful surrogates to deep networks, with practical utility for regulated domains requiring explicit interaction explanations and faster, polynomial-based inference.

Abstract

The nn2poly package provides the implementation in R of the NN2Poly method to explain and interpret feed-forward neural networks by means of polynomial representations that predict in an equivalent manner as the original network.Through the obtained polynomial coefficients, the effect and importance of each variable and their interactions on the output can be represented. This capabiltiy of capturing interactions is a key aspect usually missing from most Explainable Artificial Intelligence (XAI) methods, specially if they rely on expensive computations that can be amplified when used on large neural networks. The package provides integration with the main deep learning framework packages in R (tensorflow and torch), allowing an user-friendly application of the NN2Poly algorithm. Furthermore, nn2poly provides implementation of the required weight constraints to be used during the network training in those same frameworks. Other neural networks packages can also be used by including their weights in list format. Polynomials obtained with nn2poly can also be used to predict with new data or be visualized through its own plot method. Simulations are provided exemplifying the usage of the package alongside with a comparison with other approaches available in R to interpret neural networks.
Paper Structure (11 sections, 1 theorem, 11 equations, 1 algorithm)

This paper contains 11 sections, 1 theorem, 11 equations, 1 algorithm.

Key Result

Lemma 2.1

Let $\prescript{}{\mathrm{in}}{P}$ be a polynomial of order $Q$ in $p$ variables and $g()$ a k-times differentiable function. Applying a Taylor expansion around $0$ and up to order $q$ yields a new polynomial $\prescript{}{\mathrm{out}}{P}$ in the same variables, of order $Q \times q$, whose coeffic for all $\Vec{t} \in \mathcal{T}(p,Q \times q)$, where $\pi(\Vec{t},Q,n)$ is the set of vectors $\V

Theorems & Definitions (1)

  • Lemma 2.1