igl.models
scikit-learn-compatible estimators: classifier, regressor, autoencoder.
igl.models.classifier.IGLClassifier
Bases: _BaseIGLEstimator[CrossEntropyLoss], ClassifierMixin
scikit-learn-compatible classifier built on :class:igl.IGLModule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_dim
|
int
|
Latent dimension |
16
|
n_anchors
|
int | None
|
Anchor count. |
None
|
n_scales
|
int | None
|
Scale count. |
None
|
operator
|
OperatorNameLike | None
|
Kernel operator. |
None
|
normalize
|
NormalizeModeLike | None
|
Φ-normalization mode. |
None
|
encoder_hidden
|
int | tuple[int, ...] | None
|
Encoder |
None
|
encoder_depth
|
int | None
|
Encoder depth shorthand. |
None
|
config
|
IGLConfig | None
|
Optional :class: |
None
|
random_state
|
int | None
|
Optional integer seed for reproducible training. |
None
|
validation_fraction
|
float | None
|
If set, hold out this fraction of training data for early-stopping and dimension-curve evaluation. |
0.2
|
Attributes:
| Name | Type | Description |
|---|---|---|
classes_ |
Sorted unique training labels. |
|
n_features_in_ |
Ambient input dimension seen during fit. |
|
module_ |
The underlying :class: |
|
history_ |
:class: |
|
dimension_curve_ |
|
|
effective_dimension_ |
Detected elbow |
|
scaler_ |
:class: |
fit(x, y)
Fit the classifier on (x, y).
predict(x)
Predict class labels for x.
predict_proba(x)
Predict class probabilities for x.
igl.models.regressor.IGLRegressor
Bases: _BaseIGLEstimator[MSELoss], RegressorMixin
scikit-learn-compatible regressor.
Supports scalar and multi-output regression. Targets y may be a
1-D array ([n_samples]) for scalar regression, or 2-D
([n_samples, n_outputs]) for multi-output. The output dimension is
inferred from y in :meth:fit.
Args mirror :class:IGLClassifier except for validation_fraction.
Attributes:
| Name | Type | Description |
|---|---|---|
n_features_in_ |
Ambient input dimension seen during fit. |
|
n_outputs_ |
Number of output dimensions inferred from |
|
module_ |
The underlying :class: |
|
history_ |
:class: |
|
dimension_curve_ |
|
|
effective_dimension_ |
Discovered |
|
scaler_ |
:class: |
fit(x, y)
Fit the regressor on (x, y).
predict(x)
Predict targets for x. Returns 1-D if fit with scalar targets.
igl.models.autoencoder.IGLAutoencoder
Bases: _BaseIGLEstimator[MSELoss], TransformerMixin
Train an IGL model with y = x (reconstruction).
The :meth:fit method ignores its y argument and uses x as both
input and target.
Attributes:
| Name | Type | Description |
|---|---|---|
n_features_in_ |
Ambient input dimension. |
|
n_outputs_ |
Equal to |
|
module_ |
The underlying :class: |
|
history_, |
(dimension_curve_, effective_dimension_, scaler_)
|
same as
:class: |
fit(x, y=None)
Fit the autoencoder. y is ignored; the scaled x is the target.
Reconstruction is therefore measured in the StandardScaler-scaled
feature space. :meth:reconstruct inverse-transforms back to the
original feature space for users who need real-space outputs.
reconstruct(x)
Inverse-transform the reconstruction back to the original feature space.
transform(x)
Return the reconstructed input (in the scaled feature space).
igl.IGLDistiller
Bases: _BaseIGLEstimator[WhitenedMSELoss]
Distill states into a Matryoshka latent under a metric geometry.
The pipeline mirrors metric-weighted distillation: inputs are centered
per feature and scaled by a single scalar std; the reconstruction target
is the raw state, whitened inside the loss by metric's square root
so plain least squares optimizes the second-order expansion of the
geometry the metric encodes. :meth:reconstruct undoes the whitening,
returning states in the original space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_dim
|
int
|
Matryoshka latent width. |
16
|
metric
|
Tensor | None
|
Symmetric PSD metric |
None
|
clamp
|
float
|
Eigenvalue floor for the metric square root. |
1e-06
|
config
|
IGLConfig | None
|
Optional :class: |
None
|
device
|
str | device | None
|
Optional torch device for fitting. |
None
|
random_state
|
int | None
|
Seed scoping module construction and training. |
None
|
validation_fraction
|
float | None
|
Held-out fraction for early stopping. |
0.2
|
Attributes:
| Name | Type | Description |
|---|---|---|
module_ |
The fitted :class: |
|
history_ |
Training history (post-fit). |
|
dimension_curve_ |
Loss-versus-dimension curve in the whitened geometry (post-fit). |
|
effective_dimension_ |
Elbow of the dimension curve (post-fit). |
|
whitener_ |
The fitted :class: |
|
input_mean_ |
Per-feature input mean |
|
input_std_ |
Scalar input std (post-fit). |
fit(x, y=None)
Fit the distiller on states [N, C] (the states are the target).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
NDArray[floating]
|
States to distill. |
required |
y
|
None
|
Ignored; present for sklearn API compatibility. |
None
|
Returns:
| Type | Description |
|---|---|
IGLDistiller
|
|
project(x, *, k=None)
Map states to chart coordinates, optionally truncated to k.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
NDArray[floating]
|
States |
required |
k
|
int | None
|
Keep only the first |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[floating]
|
Coordinates |
reconstruct(x, *, k=None)
Reconstruct states through the bottleneck, back in the original space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
NDArray[floating]
|
States |
required |
k
|
int | None
|
Read the reconstruction from only the first |
None
|
Returns:
| Type | Description |
|---|---|
NDArray[floating]
|
Reconstructed states |