Repository navigation
Add VARIMAX Rotation Support to Database-Backed PCA in VerticaPy - #1376
Open
rocketsharma wants to merge 1 commit into
Open
rocketsharma wants to merge 1 commit into
rocketsharma wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.