Conversation
This was referenced Mar 5, 2026
ballPointPenguin
approved these changes
Mar 8, 2026
Member
ballPointPenguin
left a comment
There was a problem hiding this comment.
NOTE: pca.py’s module docstring still describes the deleted handwritten PCA implementation, even though this PR replaces it with sklearn.
NOTE: the new benchmark helper’s usage examples assume ../.venv/bin/python, which doesn’t match the repo’s documented/canonical delphi-env workflow in delphi/Makefile
-> we should pick either delphi-env/bin/python OR .venv/bin/python and use that everywhere
otherwise: looks good, tests pass. Nice cleanup 🧽
Note: we will update the golden records in a later commit.
I took care to keep the "sparsity-aware" scaling, computed in a vectorized way.
It's not needed anymore: the PCA is done by Sklearn, and the edge cases are already handled by wrapped_pca caller, i.e. pca_project_dataframe. Less code, less complexity, less maintenance.
Re-recorded golden snapshots using the new sklearn SVD-based PCA. These snapshots now serve as the baseline for regression tests.
Tests that only verify sorting/moderation now use recompute=False to skip unnecessary PCA computation. Manager tests that need PCA but use minimal data have targeted filterwarnings with explanations. Changes: - Add recompute=False to sorting tests (no PCA needed for ID ordering) - Add recompute=False to test_moderation (only checks filtering) - Add @pytest.mark.filterwarnings to TestConversationManager tests that use minimal data through the manager interface 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix division by zero when participant has no votes (pca.py) Mirrors Clojure's (max n-votes 1) approach - Fix return type annotation for _log_projection_metrics (comparer.py) - Add explanatory comment for intentional except pass (comparer.py) - Remove unused variable in test (test_regression.py) - Add unit test for no-votes edge case (test_pca_unit.py) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use pca.mean_ instead of manual centering (sklearn handles centering internally) - Replace np.random.seed(42) with random_state=42 on PCA constructor - Update docstring to reflect sklearn PCA + column-mean imputation - Fix _pca_sign_flips type annotation to Dict[str, Dict[int, int]] - Scope outlier_fraction to PCA-related paths only (non-PCA data stays strict) - Add try/except around symlink creation for cross-platform robustness - Remove unused normalize_vector/proj_vec test helpers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- pca.py: describe sklearn wrapper instead of deleted power iteration impl - bench_pca.py: use tool-agnostic `python` instead of hardcoded venv path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Thanks @ballPointPenguin !
As to what should be a "canonical" venv place, in a way that would be "least surprising" to most python developers likely to work on delphi, or even might be tool-agnostic, this deserves a discussion of its own, and eventually its own PR. |
Delphi Coverage Report
|
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.
Summary
The main deliverable of the #2311 split. Replaces ~900 lines of hand-rolled power iteration PCA with ~50 lines using sklearn's SVD-based PCA.
Net deletion: ~1000+ lines of hand-rolled linear algebra replaced by battle-tested sklearn.
Reviewer note
The golden record JSON diffs (~15k lines) can be skipped — they are the expected output changes from switching to sklearn PCA. The projection metrics from #2415 validate equivalence. Focus review on `pca.py`.
Test plan
🤖 Generated with Claude Code