Comparison with princals¶
qlpca is compared with princals from the Gifi system in its two implementations: the R package Gifi 1.0-0
(Mair, De Leeuw & Groenen; CRAN, 2025) and its Python port pyGifi (commit 7aa81ed). The full comparison —
pipelines with source lines, same-knot results, bases, defaults, local optima, monotone fits and the functions only
qlpca has — is the notebook
comparison/princals/qlpca_vs_princals.ipynb;
this page shows only numbers already computed there.
Independent implementation and licences¶
qlpca is an independent implementation, written from the author's PhD thesis (Lavado, 2012) and the method's
original paper (Lavado & Calapez, 2011). It contains no code from the Gifi R package or from pyGifi. Gifi and
pyGifi are licensed under GPL-3; in the comparison folder they are only called (R) or imported (Python), and the
notebook quotes a few of their source lines with file and line number. No data of theirs is stored in the
repository (neumann is loaded from pyGifi at run time). qlpca is MIT.
Data and settings¶
Cylinders (make_cylinder, n = 51, noise 0, 0.10, 0.25); thesis chapter 4 (n = 15); neumann (3 variables); UCI
Gas Turbine CO and NOx Emission (doi:10.24432/C5WC95, CC BY 4.0; 2015, n = 400). Same knots: the qlpca percentile
knots written explicitly in a manifest and passed to all three programs, degree 1, eps = 1e-12. Monotone: 2
knots, degree 1 and 2. Defaults: princals(data, ndim = 2) and QLPCA(n_components=2).
VAF of two components (%)¶
From comparison/princals/results/summary.csv. Runs knots1, knots2: same knots, degree 1, no monotonicity;
monotone_deg1/2: monotone=True vs ordinal=TRUE; defaults: each program's own defaults (different models).
| data | run | qlpca VAF | pyGifi VAF | Gifi (R) VAF | max abs diff. eigenvalues qlpca - R |
|---|---|---|---|---|---|
| cylinder_0 | knots1 | 95.208 | 95.208 | 95.208 | 3.8e-06 |
| cylinder_0 | knots2 | 97.424 | 97.424 | 97.424 | 4.0e-06 |
| cylinder_0 | monotone_deg1 | 97.424 | 97.424 | 97.424 | 1.1e-04 |
| cylinder_0 | monotone_deg2 | 97.926 | 98.422 | 98.422 | 1.1e-01 |
| cylinder_0 | defaults | 95.208 | 99.996 | 99.995 | 4.3e-01 |
| cylinder_10 | knots1 | 93.722 | 93.722 | 93.722 | 2.4e-06 |
| cylinder_10 | knots2 | 96.027 | 96.027 | 96.027 | 9.1e-06 |
| cylinder_10 | defaults | 93.722 | 99.993 | 99.810 | 5.2e-01 |
| cylinder_25 | knots1 | 89.207 | 89.207 | 89.207 | 5.3e-07 |
| cylinder_25 | knots2 | 91.735 | 91.735 | 91.735 | 5.6e-06 |
| cylinder_25 | defaults | 89.207 | 99.998 | 99.998 | 1.6e+00 |
| st_gender | knots1 | 68.902 | 68.902 | 68.902 | 5.4e-07 |
| st_gender | knots2 | 76.328 | 76.328 | 76.328 | 1.3e-06 |
| st_gender | monotone_deg1 | 71.030 | 71.030 | 71.030 | 4.6e-05 |
| st_gender | monotone_deg2 | 71.218 | 71.486 | 71.486 | 2.0e-02 |
| st_gender | defaults | 68.902 | 82.941 | 82.941 | 8.7e-01 |
| neumann | knots1 | 99.653 | 99.653 | 99.653 | 1.7e-07 |
| neumann | knots2 | 99.820 | 99.820 | 99.820 | 9.8e-08 |
| neumann | monotone_deg1 | 99.820 | 99.820 | 99.820 | 3.4e-05 |
| neumann | monotone_deg2 | 99.879 | 99.879 | 99.879 | 2.5e-05 |
| neumann | defaults | 99.652 | 99.979 | 99.980 | 7.9e-03 |
| gas_turbine | knots1 | 82.202 | 82.202 | 82.202 | 3.6e-07 |
| gas_turbine | knots2 | 82.619 | 82.619 | 82.619 | 7.9e-06 |
| gas_turbine | defaults | 82.202 | 86.707 | 86.707 | 2.1e-01 |
Conclusions of the notebook¶
As printed by the notebook (computed numbers):
1. Same knots, degree 1, no monotonicity: qlpca and pyGifi agree within the manifest tolerances in 12 of 12 cases (6 data sets x 1 and 2 knots); largest eigenvalue difference 9.0e-06, largest 1-|r| between transformations 2.0e-10.
Against Gifi (R) (R version 4.6.2 (2026-10-29), Gifi 1.0.0): qlpca agrees within the same tolerances in 12 of 12 cases; largest eigenvalue difference 9.1e-06, largest 1-|r| 2.2e-10, largest object-score difference 2.4e-04. pyGifi vs R: largest eigenvalue difference 1.5e-05 (9 of 12 within the tolerance of 1e-5 on the eigenvalues and the other criteria).
2. princals does not discretise numeric variables: numeric columns are used as they are and the spline basis is built on the original values (section a).
3. B-splines and [1, I-splines] span the same space (max projector difference 1.9e-15); condition numbers with 10 knots, degree 1: 1.8 (B) vs 26.4 ([1, I]).
4. Defaults (VAF of 2 dimensions, %): cylinder_0: PCA 82.2, qlpca 95.2, princals 100.0 (50 vs 2 parameters per variable); cylinder_10: PCA 79.5, qlpca 93.7, princals 100.0 (50 vs 2 parameters per variable); cylinder_25: PCA 69.5, qlpca 89.2, princals 100.0 (50 vs 2 parameters per variable); st_gender: PCA 61.9, qlpca 68.9, princals 82.9 (14 vs 2 parameters per variable); neumann: PCA 98.8, qlpca 99.7, princals 100.0 (41 vs 2 parameters per variable); gas_turbine: PCA 79.8, qlpca 82.2, princals 86.7 (329 vs 2 parameters per variable).
With the defaults, pyGifi and Gifi (R) return different solutions on cylinder_0 (largest eigenvalue difference 0.350, VAF 99.996 vs 99.995); cylinder_10 (largest eigenvalue difference 1.716, VAF 99.993 vs 99.810); cylinder_25 (largest eigenvalue difference 0.128, VAF 99.998 vs 99.998); neumann (largest eigenvalue difference 0.003, VAF 99.979 vs 99.980); on the other data sets the eigenvalues differ by at most 1.1e-04.
5. Chapter 4 data, 2 knots: 50 random starts of pyGifi reach VAF between 70.55 and 76.33; the qlpca PCA start gives 76.33; the best of qlpca's 51 starts 76.33.
6. Monotone, degree 1: largest eigenvalue difference qlpca-pyGifi 6.5e-04. Degree 2: VAF qlpca vs pyGifi cylinder_0 97.93 vs 98.42; st_gender 71.22 vs 71.49; neumann 99.88 vs 99.88. With degree 2 the princals transformations violate monotonicity at the observed data points (smallest increment between consecutive sorted data values: cylinder_0 -0.0012; st_gender -0.0004), because dykstra returns the average of its last two projections (coneRegression.R, line 104) and stops at a tolerance of 1e-6; the restriction applies only at the observed points. The qlpca transformations are monotone over the whole range (smallest increment -1.1e-15). The higher princals VAF with degree 2 must be read with this in mind: the two programs do not optimise over the same set.
7. Only qlpca projects new observations (with ExtrapolationWarning outside the training range), reconstructs data (exactly for variables with a monotone transformation; gas turbine, p = m: 9 of 9 transformations are not monotone, so their reconstruction is not unique), reports piecewise loadings and works as a scikit-learn transformer; pyGifi's transform returns the training scores whatever the input.
Figures¶
Same knots (2), degree 1, no monotonicity — transformations of the chapter 4 data:

Condition numbers of B-splines and of [1, I-splines]:

Each program's defaults (princals: a knot at every distinct value, ordinal):


Local optima: 50 random starts, chapter 4 data, 2 knots:

Monotone, degree 2 (qlpca monotone=True, princals ordinal=TRUE):

VAF summary over the data sets:
