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. supports is the single capability check; users do not need to distinguish internal model families.

For downstream composition, skgrad.gradient_properties(model) reports computational metadata such as whether the input Jacobian is constant. This allows consumers to optimize integration without duplicating skgrad's estimator registry or exposing separate family-specific support predicates.

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, and other consumers can combine them with analytic chain-rule transformations.

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.1.tar.gz (10.3 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.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: skgrad-0.1.1.tar.gz
  • Upload date:
  • Size: 10.3 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.1.tar.gz
Algorithm Hash digest
SHA256 da840971bf92493bcb9c8bbe836410b25ef30f7b5d93f7956db6df98e6c182db
MD5 ebfd567ed50deedcd88f174863f11b16
BLAKE2b-256 f9ca61352c59805f0ac69e43b3668cf48634f6f87f79ffdc16d4e528cf875199

See more details on using hashes here.

Provenance

The following attestation bundles were made for skgrad-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: skgrad-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5649c36c5900ba1dab2082a7eb663bec1d56b26f5cddde164ff115a3b382e97
MD5 512e4cddab00e8d112ead3dbbd50f1d1
BLAKE2b-256 68636484e1835656e6a51304d1d854fb6317b29e1e66ea5e023bce92e5f81d02

See more details on using hashes here.

Provenance

The following attestation bundles were made for skgrad-0.1.1-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

This release

0.1.1 This release

2 files

0.1.0

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