Skip to content

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

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

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

Conversation

@rocketsharma

@rocketsharma rocketsharma commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

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

Previously, PCA rotation was available only in the in-memory PCA implementation. This enhancement enables users to apply rotation directly to a PCA model trained in Vertica and execute rotated transformations inside the database.

Changes

Added rotate(gamma=1.0, q=20, tol=1e-6) to database-backed PCA.

Reused the existing MemModel PCA rotation algorithm 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 execute rotated PCA transformations in Vertica.

Supported both scale=True and scale=False.

Updated rotated PCA attributes, including principal_components_, cos2_, and explained_variance_.

Preserved existing APPLY_PCA behavior for unrotated models.

Added unit and integration tests and updated API documentation.

Validation

Environment:

Vertica: 26.4.0-20261030

OS: RHEL8

Python: 3.14.6

pytest: 9.2.0

Test results:

PCA VARIMAX live integration tests: 14 passed

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

Offline rotation and MemModel tests: 58 passed

Functional validation:

Successfully trained PCA and applied VARIMAX rotation in Vertica 26.4.

Verified that rotated components match the existing MemModel implementation.

Confirmed that generated SQL executes successfully inside Vertica.

Validated rotated SQL against native APPLY_PCA transformations for both scaling modes.

Compared rotated SQL results with NumPy calculations; the standalone demonstration showed a maximum numerical difference of 5.33e-15.

Verified transform(), repeated rotation, component selection, and model refit/reload behavior.

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