Metadata-Version: 2.4
Name: skgrad
Version: 0.1.0.dev0
Summary: Analytic input gradients for fitted scikit-learn models
Author: Ludger Hentschel
License-Expression: MIT
Project-URL: Homepage, https://github.com/LudgerHentschel/skgrad
Project-URL: Repository, https://github.com/LudgerHentschel/skgrad
Project-URL: Issues, https://github.com/LudgerHentschel/skgrad/issues
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.23
Requires-Dist: scikit-learn>=1.2
Provides-Extra: test
Requires-Dist: build>=1; extra == "test"
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: tomli>=2; python_version < "3.11" and extra == "test"
Requires-Dist: twine>=5; extra == "test"
Dynamic: license-file

# 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.

```python
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

```python
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.
