Skip to main content

Neural Networks with Symbolic Regression for Interpretable Machine Learning

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

InterpretSR

InterpretSR is a Python library that combines neural networks with symbolic regression for interpretable machine learning. It wraps PyTorch MLPs with PySR (Python Symbolic Regression) to automatically discover symbolic expressions that approximate the learned neural network behavior.

Features

  • Neural Network Wrapping: Seamlessly wrap any PyTorch MLP with symbolic regression capabilities
  • Automatic Discovery: Use PySR to find mathematical expressions that approximate neural network behavior
  • Interpretability: Convert black-box neural networks into human-readable symbolic expressions
  • Dynamic Switching: Switch between neural network and symbolic equation modes during inference

Installation

pip install interpretsr

Quick Start

import torch
import torch.nn as nn
from src.mlp_sr import MLP_SR

# Create a simple MLP
mlp = nn.Sequential(
    nn.Linear(5, 10),
    nn.ReLU(),
    nn.Linear(10, 1)
)

# Wrap with MLP_SR
wrapped_model = MLP_SR(mlp, "my_model")

# Train normally
inputs = torch.randn(100, 5)
outputs = wrapped_model(inputs)

# Discover symbolic expression
regressor = wrapped_model.interpret(inputs)

# Switch to symbolic equation
wrapped_model.switch_to_equation()

Documentation

Full documentation is available at ReadTheDocs.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

interpretsr-1.0.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

interpretsr-1.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file interpretsr-1.0.0.tar.gz.

File metadata

  • Download URL: interpretsr-1.0.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for interpretsr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3b0b86eca1b7a7c3982d05517a6a8ebfcea30c977acaf5bcd7077b8795db1456
MD5 1b0952f94311d5adf7686b6be71734db
BLAKE2b-256 369fc8ac3da0a4c5f67a4698697459a2cdda7346cd746afcc96b8bdc580080e7

See more details on using hashes here.

File details

Details for the file interpretsr-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: interpretsr-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for interpretsr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 283f394578ad5fd25fe0e8d05b558bac98fd09bfe4786b3a0d75287e1f55162c
MD5 69b02449f1cf7fdad647641eebfa2718
BLAKE2b-256 68200972087c660dd4a239b94c9441101de9a11410cd190b995b899d414eee73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page