Disentanglement · β-VAE · Quant Research

Unsupervised Stock Factors, in Your Browser

Alpha Factor VAE trains a linear-Gaussian β-variational autoencoder on a 50-stock synthetic universe driven by four known factors, then lets you dial the KL weight and watch the latent space negotiate the classic disentanglement-reconstruction trade-off. A Python driver fits the model in closed form (Lucas et al. 2019), writes every diagnostic to data/factors.json, and this page reads the payload and re-renders six coordinated panels against it. Every number traces to one source of truth.

Fit summary

KL weight β
—
Mean reconstruction R²
—
Top canonical correlation
—
Mutual Information Gap
—
Active latents
—
Source
—

The summary follows the active β selector. Switch β in the Explore section to re-render every figure against a different KL weight.

Explore the fit

Six panels, one data payload. Tab between them with the arrow keys. Each panel carries both a chart and a tabular mirror so the exploration is identical for sighted and screen-reader users.

Factor loadings, ground truth versus VAE recovery

Each row is one stock; each column is one factor or latent. Colour intensity encodes magnitude and the hue encodes sign, but the full signed value is repeated in the table mirror so the panel does not rely on colour alone.

Method in one paragraph

We synthesise 252 trading days of returns for 50 stocks from a four-factor linear Gaussian model with per-factor volatilities between 9 and 18 percent annualised, signed lognormal loadings, and heteroskedastic idiosyncratic noise. We then fit a linear Gaussian β-variational autoencoder in closed form using the result from Lucas et al. 2019: the ELBO-optimal solution is the top principal components of the data with eigenvalues thresholded at β times the estimated idiosyncratic variance. Components that fall below the threshold collapse onto the standard-normal prior and the corresponding latent dimension carries no information. We sweep β over 0.5, 2, 8, and 32 and report reconstruction R squared, canonical correlations with the ground-truth factor space, the KL contribution per latent dimension, and the Mutual Information Gap disentanglement score. A PyTorch variant at scripts/train_one.py reproduces the same fit with stochastic gradient descent and writes the same JSON schema, so the dashboard does not know which backend it is reading.

Credits and references