Skip to content

Add VARIMAX Rotation Support to Database-Backed PCA in VerticaPy - #1375

Closed
rocketsharma wants to merge 1 commit into
vertica:masterfrom
rocketsharma:feature-pca-varimax-rotation-vertica
Closed

rocketsharma wants to merge 1 commit into
vertica:masterfrom
rocketsharma:feature-pca-varimax-rotation-vertica

Conversation

@rocketsharma

@rocketsharma rocketsharma commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

This PR adds VARIMAX rotation support to the database-backed PCA implementation in VerticaPy by reusing the existing rotation functionality from the in-memory PCA (MemModel).

Previously, PCA rotation was available only in MemModel PCA. With this enhancement, users can apply rotation directly to a PCA model trained in Vertica and execute rotated transformations within the database.

Changes

  • Added rotate(gamma=1.0, q=20, tol=1e-6) to database-backed PCA.
  • Reused the existing MemModel rotation logic without duplicating the mathematical implementation.
  • Added support for VARIMAX (gamma=1.0) and Quartimax (gamma=0.0).
  • Updated deploySQL() to generate SQL using rotated PCA components.
  • Enabled transform() to use rotated components.
  • Added support for rotated PCA transformations with scale=True and scale=False.
  • Preserved existing APPLY_PCA behavior for unrotated models.
  • Updated rotated PCA attributes, including explained variance and cos2_.
  • Added unit and integration tests.
  • Updated API documentation.

Example

from verticapy.machine_learning.vertica import PCA

model = PCA(name="pca_varimax", n_components=2)
model.fit("public.pca_data", ["x1", "x2", "x3"])

# Apply VARIMAX rotation
model.rotate(gamma=1.0)

# Generate SQL using rotated components
print(model.deploySQL())

# Execute rotated transformation in Vertica
result = model.transform("public.pca_data")

Validation Update – Vertica 26.4

Successfully validated PCA VARIMAX rotation against Vertica Analytic Database v26.4.0-20261030 on RHEL8.

Test results:

PCA VARIMAX integration tests: 14 passed

Full PCA, SVD and MCA regression suites: 101 passed, 16 skipped, 0 failed

Offline rotation tests: Passed

Verified functionality:

VARIMAX and Quartimax rotation match the existing MemModel implementation.

Rotated SQL results match Vertica's native APPLY_PCA output after rotation.

Both scale=True and scale=False work correctly.

transform(), deploySQL(), and supported SQL export operations behave as expected.

Model refitting and reloading correctly reset rotation state.

Existing PCA, SVD and MCA functionality remains unaffected in the tested suites.

Environment:

Vertica: 26.4.0-20261030

Python: 3.14.6

pytest: 9.2.0

OS: RHEL8

All executed tests passed. No test failures were observed.

Files Modified

  • verticapy/machine_learning/vertica/decomposition.py
  • verticapy/machine_learning/memmodel/decomposition.py
  • verticapy/tests/vModel/test_pca.py
  • docs/source/machine_learning_vertica_decomposition.rst

@rocketsharma rocketsharma self-assigned this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant