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.
Ground truth and recovered factor returns
Sampled weekly so the chart stays readable; each polyline carries a distinct dash pattern, and the data-table mirror lists every sampled value. Focus a line to hear its mean and range.
Per-stock reconstruction quality
Horizontal bars sorted by VAE reconstruction R². A vertical tick on each bar marks the PCA baseline so the delta is legible at a glance; the quality bucket (high, moderate, low, negligible) is repeated in the table mirror.
KL contribution per latent dimension
Latents that sit near zero have collapsed onto the prior and carry no information about the data. This is the clearest illustration of posterior collapse as β rises.
Canonical correlations with the ground-truth factor space
Values close to one mean the VAE latent space and the ground-truth factor space span the same subspace up to rotation. The PCA baseline is plotted alongside for reference.
Training curves
ELBO loss, reconstruction, and KL plotted across the optimisation run. Each line has a unique dash pattern and a focusable aria-label summarising its trajectory.
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
- Kingma and Welling 2013, Auto-Encoding Variational Bayes, the original VAE formulation.
- Higgins et al. 2017, β-VAE: Learning Basic Visual Concepts with a Constrained Variational Framework, the KL-weighted objective used here.
- Lucas et al. 2019, Don't Blame the ELBO, the closed-form analysis of the linear Gaussian β-VAE that pins the ELBO optimum to PPCA with eigenvalue thresholding.
- Chen et al. 2018, Isolating Sources of Disentanglement, the source of the Mutual Information Gap metric used as a disentanglement score.
- Accessibility scaffolding follows the W3C ARIA Authoring Practices Guide tabs pattern and WCAG 2.2 AA targets.
- Fonts: Inter (Rasmus Andersson) and JetBrains Mono (JetBrains), both under the SIL Open Font License.