Add --LR_model and --demo options to gene_vec_model.py#4
Add --LR_model and --demo options to gene_vec_model.py#4chronicgiardia wants to merge 2 commits into
Conversation
Refactor gene_vec_model.py to expose the embedding pipeline via main() and add helpers for the new CLI arguments: - --LR_model: train (or load) a logistic regression model over gene-pair embedding features and persist it as gene_pair_lr.pkl in the directory. - --demo: export a copy of the learned embeddings into the demo directory. Add a unittest suite covering argument parsing, feature construction, LR model save/load, and demo export. Document both arguments in the README. Co-Authored-By: Oz <oz-agent@warp.dev>
There was a problem hiding this comment.
Pull request overview
This PR extends the src/gene_vec_model.py training script with two optional CLI flags to (1) train/load a downstream logistic regression model on learned gene embeddings and (2) export trained embeddings into a demo directory, and adds unit tests and README documentation for these behaviors.
Changes:
- Added
--LR_model <dir>and helper logic to train or load a persisted gene-pair logistic regression model. - Added
--demo <dir>and helper logic to export the embeddings CSV into the demo directory (preferringdemo/data/when present). - Refactored the script to a
main()entrypoint guarded byif __name__ == '__main__'and introducedunittestcoverage for the new helpers/CLI parsing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/gene_vec_model.py | Adds new CLI args, extracts helper functions, and wraps training flow into a main() entrypoint; optionally trains/loads LR and exports embeddings. |
| src/test_gene_vec_model.py | Adds unittest coverage for argument parsing, feature construction, LR save/load behavior, and demo export (skips LR tests if sklearn missing). |
| README.md | Documents the new --LR_model and --demo options and their outputs/behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from sklearn.linear_model import LogisticRegression | ||
|
|
Mirrors the argument-parsing style used by graphify's args-demo command: explicit per-flag cursor loop supporting both --flag value and --flag=value forms, manual --help/-h output, and error+exit(1) on unrecognized arguments. Returns a SimpleNamespace so main() usage (args.datatype, args.LR_model, etc.) is unchanged. All 11 existing tests in test_gene_vec_model.py pass unmodified. Co-Authored-By: Oz <oz-agent@warp.dev>
|
Updated: replaced the argparse-based parser in |
Summary
Adds two optional CLI arguments to
src/gene_vec_model.pyand documents them:--LR_model <dir>: after training gene embeddings, trains (or loads, if already present) a logistic regression model that predicts whether a pair of genes is associated, using the element-wise product of the two genes' embeddings as features. Persisted asgene_pair_lr.pklin the directory. Requires scikit-learn.--demo <dir>: exports a copy of the learned embeddings into the demo directory (into itsdata/subdirectory when present) so the demo scripts can consume freshly trained embeddings.To make this testable, the training pipeline was refactored into a
main()guarded byif __name__ == '__main__', and the new logic was extracted into small helpers (build_pair_features,train_or_load_lr_model,export_embeddings_for_demo). CLI behavior is unchanged.Tests
Adds
src/test_gene_vec_model.py(stdlibunittest, no pytest required) covering argument parsing, feature construction, LR model save/load (including load-without-retrain), and demo export. Run with:All 11 tests pass.
Conversation: https://app.warp.dev/conversation/2180fe28-77cf-4cc1-9147-26b5fd7a2e6a