Skip to content

Feature builders

Bases: BaseEstimator, TransformerMixin

FeatureUnion-style composition of named transformers.

Each child is fit on the same (X, y) and outputs are concatenated column-wise.

Parameters:

Name Type Description Default
transformers list[tuple[str, TransformerMixin]] | None

List of (name, transformer) pairs. Each transformer must implement fit/transform (sklearn TransformerMixin convention).

None

Bases: BaseEstimator, TransformerMixin

Return X unchanged (the x component of phi_{z^N}(x)).

Bases: BaseEstimator, TransformerMixin

Estimate log-density log q(x | training data).

Parameters:

Name Type Description Default
method DensityMethod

"mahalanobis" — diagonal Gaussian MLE (Lee et al. 2018; Sanderink, 2026 default). "knn"-log(d_k + eps) where d_k is the k-th NN distance. "kde" — sklearn KernelDensity with Gaussian kernel. "flow" — normalizing flow (requires pip install "deup[torch]").

'mahalanobis'
k int

Neighbors for method="knn".

5
bandwidth float

Bandwidth for method="kde".

1.0
var_floor float

Minimum variance per dimension for mahalanobis (dead-ReLU dimensions).

1e-06
eps float

Stabilizer for knn log-density.

1e-08

Bases: BaseEstimator, TransformerMixin

Estimate log predictive variance log V(x).

Parameters:

Name Type Description Default
method VarianceMethod

"ensemble" — bootstrap variance of a cloned base estimator's predictions. "gp" — GP variance (requires pip install "deup[torch]"; not yet implemented — raises at fit).

'ensemble'
estimator Any

Base model for method="ensemble" (cloned per bootstrap replicate).

None
n_estimators int

Number of bootstrap replicas.

10
random_state int | None

Seed for bootstrap subsampling.

None
eps float

Added inside log(var + eps) for numerical stability.

1e-08

Bases: BaseEstimator, TransformerMixin

k-th nearest-neighbor distance from x to the training manifold.

Parameters:

Name Type Description Default
k int

Which neighbor distance to return (1 = nearest). Useful as a covariate-shift proxy complementary to DensityFeature.

5

Bases: BaseEstimator, TransformerMixin

Binary indicator: 1 if x was in the training set, else 0.

Parameters:

Name Type Description Default
atol float

Tolerance for floating-point duplicate detection (exact match when both 0).

0.0
rtol float

Tolerance for floating-point duplicate detection (exact match when both 0).

0.0

Bases: BaseEstimator, TransformerMixin

Local average of training residual magnitudes |y - f(x)|.

At fit(X, y) the base estimator is cloned and fit, and absolute residuals are stored. At transform(X) (inference, no y), returns the mean residual magnitude among k nearest training neighbors — a local error prior.

Parameters:

Name Type Description Default
estimator Any

Base model f (any sklearn fit/predict object). Cloned at fit.

required
k int

Neighbors for smoothing.

5