Skip to main content

skgrad

skgrad computes analytic input gradients for fitted scikit-learn models. It provides one consistent interface for affine estimators and multilayer perceptrons without numerical finite differences or automatic-differentiation frameworks.

import skgrad

values, jacobian = skgrad.value_and_jacobian(model, X)

values always has shape (samples, outputs) and jacobian has shape (samples, outputs, features). Regression values are predictions. Classification values are decision scores or logits, never probabilities.

Supported models

  • LinearRegression, Ridge, Lasso, and ElasticNet
  • LogisticRegression and RidgeClassifier
  • MLPRegressor with identity output
  • MLPClassifier, using pre-probability logits

Hidden MLP activations may be identity, logistic, tanh, or ReLU. ReLU uses a zero derivative at its nondifferentiable origin, matching scikit-learn's backpropagation convention.

API

skgrad.supports(model)
skgrad.model_output(model, X)
skgrad.input_jacobian(model, X)
skgrad.input_gradient(model, X, target=None)
skgrad.value_and_jacobian(model, X)

input_gradient is the scalar-output convenience API. A target is required when the model has multiple outputs.

Tree models, parameter gradients, numerical differentiation, Integrated Gradients, and baseline handling are deliberately outside the package scope.

The value_and_jacobian primitive is designed for downstream composition. For example, UnifiedIG integrates its Jacobians to explain model outputs, while MPAIG combines them with analytic loss derivatives to explain realized predictive performance.

Download files

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

Source Distribution

skgrad-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

skgrad-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: skgrad-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for skgrad-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b3525f9f497b4feb19af83c13d0d96264822ee740823c18ca9d5d31c357b925
MD5 ba9f7fc5d17c9c318feb3f0ed7445697
BLAKE2b-256 854e5260862e6c3e3b9182f7438589bfea706902ab62b7d2a76d4885f235f436

See more details on using hashes here.

Provenance

The following attestation bundles were made for skgrad-0.1.0.tar.gz:

Publisher: release.yml on LudgerHentschel/skgrad

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: skgrad-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for skgrad-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a724d2a9965872fbc3736e2e047dfb7b5234c16a5b2d322fa85339e3041094af
MD5 b93a02e5d32b9609b82fec9a8bfa8646
BLAKE2b-256 bbb22733a58fbb61fb20c555db6e7c14d7812e00a724ab557b8b2f5bdb483bef

See more details on using hashes here.

Provenance

The following attestation bundles were made for skgrad-0.1.0-py3-none-any.whl:

Publisher: release.yml on LudgerHentschel/skgrad

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.6

2 files

0.1.5

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page