Representation Quality¶
reliably.repr.mig.mig(z, factors, *, n_bins=20, ci='bca', n_bootstrap=2000, level=0.95, seed=0)
¶
Mutual Information Gap (MIG) disentanglement metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
array - like
|
Latent codes, shape |
required |
factors
|
array - like
|
Ground-truth generative factors, shape |
required |
n_bins
|
int
|
Bins for MI estimation. |
20
|
ci
|
str | None
|
CI method. |
'bca'
|
n_bootstrap
|
int
|
Bootstrap resamples. |
2000
|
level
|
float
|
Nominal coverage. |
0.95
|
seed
|
int
|
RNG seed. |
0
|
Returns:
| Type | Description |
|---|---|
MetricResult
|
Named |
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> z = rng.normal(0, 1, (200, 4))
>>> f = rng.normal(0, 1, (200, 3))
>>> r = mig(z, f, ci=None)
>>> 0.0 <= r.value <= 1.0
True
Source code in src/reliably/repr/mig.py
reliably.repr.sap.sap(z, factors, *, ci='bca', n_bootstrap=2000, level=0.95, seed=0)
¶
Separated Attribute Predictability (SAP).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
array - like
|
Latent codes, shape |
required |
factors
|
array - like
|
Ground-truth factors, shape |
required |
ci
|
str | None
|
CI method. |
'bca'
|
n_bootstrap
|
int
|
Bootstrap resamples. |
2000
|
level
|
float
|
Nominal coverage. |
0.95
|
seed
|
int
|
RNG seed. |
0
|
Returns:
| Type | Description |
|---|---|
MetricResult
|
Named |
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> z = rng.normal(0, 1, (200, 4))
>>> f = rng.normal(0, 1, (200, 3))
>>> r = sap(z, f, ci=None)
>>> r.value >= 0.0
True
Source code in src/reliably/repr/sap.py
reliably.repr.dci.dci(z, factors, *, ci='bca', n_bootstrap=200, level=0.95, seed=0)
¶
DCI: Disentanglement, Completeness, Informativeness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
array - like
|
Latent codes, shape |
required |
factors
|
array - like
|
Ground-truth factors, shape |
required |
ci
|
str | None
|
CI method (bootstrap; note: DCI is slow, so default n_bootstrap=200). |
'bca'
|
n_bootstrap
|
int
|
Bootstrap resamples. |
200
|
level
|
float
|
Nominal coverage. |
0.95
|
seed
|
int
|
RNG seed. |
0
|
Returns:
| Type | Description |
|---|---|
MetricResult
|
Named |
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> z = rng.normal(0, 1, (100, 4))
>>> f = rng.normal(0, 1, (100, 3))
>>> r = dci(z, f, ci=None)
>>> 0.0 <= r.value <= 1.0
True
Source code in src/reliably/repr/dci.py
reliably.repr.factorvae.factorvae_metric(z, factors, *, n_votes=800, batch_size=64, ci='bca', n_bootstrap=200, level=0.95, seed=0)
¶
FactorVAE disentanglement metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
array - like
|
Latent codes, shape |
required |
factors
|
array - like
|
Ground-truth factors, shape |
required |
n_votes
|
int
|
Number of voting rounds. |
800
|
batch_size
|
int
|
Batch size per round. |
64
|
ci
|
str | None
|
CI method. |
'bca'
|
n_bootstrap
|
int
|
Bootstrap resamples. |
200
|
level
|
float
|
Nominal coverage. |
0.95
|
seed
|
int
|
RNG seed. |
0
|
Returns:
| Type | Description |
|---|---|
MetricResult
|
Named |
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> z = rng.normal(0, 1, (300, 4))
>>> f = rng.normal(0, 1, (300, 3))
>>> r = factorvae_metric(z, f, ci=None)
>>> 0.0 <= r.value <= 1.0
True
Source code in src/reliably/repr/factorvae.py
reliably.repr.irs.irs(z, factors, *, n_interventions=100, ci='bca', n_bootstrap=200, level=0.95, seed=0)
¶
Interventional Robustness Score (IRS).
Measures maximum change in the matched latent under interventions on nuisance factors while the target factor is held fixed (Suter et al., 2019). Higher score = more robust / better disentanglement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
array - like
|
Latent codes, shape |
required |
factors
|
array - like
|
Ground-truth factors, shape |
required |
n_interventions
|
int
|
Number of random interventions to sample. |
100
|
ci
|
str | None
|
CI method. |
'bca'
|
n_bootstrap
|
int
|
Bootstrap resamples. |
200
|
level
|
float
|
Nominal coverage. |
0.95
|
seed
|
int
|
RNG seed. |
0
|
Returns:
| Type | Description |
|---|---|
MetricResult
|
Named |
Examples:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> z = rng.normal(0, 1, (300, 4))
>>> f = rng.normal(0, 1, (300, 3))
>>> r = irs(z, f, ci=None)
>>> 0.0 <= r.value <= 1.0
True