Skip to content

jacksoneshbaugh/lambda-linearity-score

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

λ(f): A Linearity Score for Neural Network Interpretability

This repository contains the code and datasets for the paper:

Fidelity Isn’t Accuracy: When Linearly Decodable Functions Fail to Match the Ground Truth
Jackson Eshbaugh, Lafayette College, June 2025


Overview

Neural network outputs can often be well-approximated by linear models—but what does that tell us?

This project introduces the linearity score λ(f), a simple metric that quantifies how well a regression network’s predictions can be mimicked by a linear model. We show that this output-level diagnostic reveals important interpretability characteristics of learned functions—especially when fidelity (mimicking a network) diverges from accuracy (matching the ground truth).


Paper

📄 Read the paper: paper.pdf
This is a pre-submission draft. Feedback welcomed.
Email: jacksoneshbaugh@gmail.com
More at: jacksoneshbaugh.github.io


What is λ(f)?

Let ( f ) be a trained regression network, and let ( \mathcal{L} ) be the space of affine functions. Define:

[ \lambda(f) := R^2(f, g^) = 1 - \frac{\mathbb{E}[(f(x) - g^(x))^2]}{\text{Var}(f(x))} ]

where ( g^* = \arg\min_{g \in \mathcal{L}} \mathbb{E}[(f(x) - g(x))^2] ).

In other words, λ(f) measures how well a linear model can mimic the predictions of a trained neural network. Unlike typical ( R^2 ), this score is not about matching the ground truth—it’s about measuring how linearly decodable the function learned by the network is from the input space.


Reproducing Results

All experiments and visualizations in the paper are contained in:

📓 lambda_linearity_score.ipynb

The notebook is fully self-contained and organized into:

  • A reusable experimental framework
  • Four datasets (synthetic + 3 real-world)
  • Plots and tabulated results

To use λ(f) on your own data, modify the preprocessing and build_network() function and rerun the provided pipeline.


Datasets Used


Requirements

To run the notebook, install the following Python packages:

pip install tensorflow scikit-learn matplotlib pandas seaborn kagglehub

Tested with Python 3.11.

Acknowledgements

Special thanks to Professor Jorge Silveyra for the early discussions that helped spark this project.

© 2025 Jackson Eshbaugh. Released under the MIT License.

About

A simple diagnostic for measuring how linearly decodable a neural network’s function is

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published