Skip to main content

Kolmogorov-Arnold Networks: clean and interpretable neural architectures

Project description

Kolmarn

Clean and interpretable implementation of Kolmogorov-Arnold Networks (KANs).

KolmArn provides smooth univariate spline layers with visualization and regularization tools designed for scientific machine learning, forecasting, and high-stakes decision applications.


Motivation

Many neural networks achieve accuracy at the expense of transparency.
KolmArn enables explicit functional decomposition:

Any multivariate function can be represented as sums of univariate nonlinearities.

KolmArn implements this principle to deliver:

  • Explicit learned functions per input feature
  • Smooth basis expansions for stability
  • Visualization utilities for model interpretation
  • Compact architectures effective with limited data

This makes KolmArn well-suited for:

  • Econometrics and macroeconomic forecasting
  • Financial modeling and risk systems
  • Scientific ML and physical systems
  • Settings requiring model accountability

Installation

Local development:

git clone https://github.com/YOURNAME/kolmarn.git
cd kolmarn
pip install -e .

Requires: Python ≥ 3.9, PyTorch ≥ 2.0


Features

Component Status
KAN layers with spline expansions
Basis options: KAN spline and RBF
Smoothness regularization
Visualization of learned feature functions
Input normalization utilities In Progress
Trainable knot positions In Progress
Symbolic function export Planned
Real-world forecasting examples Planned

Example Usage

import torch
from kolmarn.models import KANSequential

# Learn sin(2πx)
x = torch.rand(200, 1)
y = torch.sin(2 * torch.pi * x)

model = KANSequential(
    in_features=1,
    layer_sizes=[32, 1],
    num_basis=16
)

optimizer = torch.optim.Adam(model.parameters(), lr=1e-2)

for _ in range(1000):
    pred = model(x)
    loss = ((pred - y) ** 2).mean()
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

# Visualize learned splines for input 0
from kolmarn.visualize import plot_feature_splines
plot_feature_splines(model, feature_index=0)

Interpretability

KolmArn exposes the learned nonlinear transformations applied to each input feature. These can be plotted directly to understand where and how the model responds to changes in the data.

Example output: learned univariate spline functions per hidden unit in a layer.

(Visual examples to be included with documentation.)


Performance Demonstration

Repeated regression experiments on sin(2πx) (100 independent trials, equal parameter counts):

Metric KAN (mean ± std) MLP (mean ± std)
RMSE 0.0167 ± 0.0079 0.0185 ± 0.0095
MAE 0.0133 ± 0.0079 0.0148 ± 0.0078
0.9993 ± 0.0012 0.9991 ± 0.0009

KolmArn matches or exceeds MLP accuracy while exposing its learned structure for direct interpretation.


Roadmap

Planned enhancements include:

  • Automatic input scaling
  • Trainable knot adaptation
  • Visualization of knot movement
  • Symbolic extraction of spline equations
  • Domain-specific examples (econometrics, risk models)

License

MIT — open for academic and commercial use.

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

kolmarn-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

kolmarn-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file kolmarn-0.1.0.tar.gz.

File metadata

  • Download URL: kolmarn-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kolmarn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c5a3fe3e80405e09df0369cf9df323e47152ff94b705aa26c69ad0c18cfd107d
MD5 3983b18cdf314e4be406971c85d4860f
BLAKE2b-256 36cc5e21eb8a658fcc6c2233e86095bef9b1c511312d159857b280d9aec50f45

See more details on using hashes here.

File details

Details for the file kolmarn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kolmarn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kolmarn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba69eef5b1c5ae05c3c5d4059ff8d245f3fc8481bd576f1550716c8a75efd6bf
MD5 e7524477c0dfe24ac42b378178db1ec5
BLAKE2b-256 99eb0adaf7926545500c645529a8489e12c7d73f56f39488db56e640cb20281d

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