Conversation
…tandard_errors` signatures to accept `flat_beta` as a keyword argument.
… unused `Optional` import
…mports. - Tightened _normalize_dual_indices and validation branches with casts for tuple/sparse/dense dual inputs so mypy can infer shapes and attributes. - Updated dense/sparse validation to use typed locals, preventing attribute errors.
…rs` with `epsilon`, `simulate_data` with `rng` and `dtype`, and clarify `y_dual` input formats.
- Add parse_choices and simulate_choices helpers, export them, and support choices input in fit plus a fit_choices convenience wrapper. - Introduce ModelResult summary with rich-rendered inference table and optimizer details (verbose metadata), plus a quickstart example using the choices-first path. - Add pandas-friendly parsing, optimizer summary table, README updates (interpretation guide, choices workflow), and tests for new helpers. - Remove old CSV example and add quickstart script; include rich dependency.
… summary output tests for inference and optimizer details.
There was a problem hiding this comment.
Pull request overview
This PR enhances the Multe package with API consistency improvements and a new "choices-first" workflow that simplifies usage. The changes modernize type hints to Python 3.10+ standards and add user-friendly features like formatted result summaries.
Key changes:
- Standardized
compute_standard_errorsargument order (X, y_single, y_dual, flat_beta) across all call sites - Introduced
parse_choices()andsimulate_choices()helpers for the new choices-first workflow - Added
fit_choices(),get_result(), andModelResultclass with rich-formatted summary output
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
multe/model.py |
Updated type hints to use Python 3.10+ union syntax; added ModelResult dataclass with rich-formatted summary; added fit_choices() and get_result() methods; refactored gradient() to support multiple dual input formats; standardized compute_standard_errors signature |
multe/simulate.py |
Added parse_choices() to convert choice lists to matrices; added simulate_choices() to generate data in choices-first format; updated type hints |
multe/__init__.py |
Exported new parse_choices and simulate_choices functions |
tests/test_model.py |
Added tests for new public gradient method, choices argument in fit, fit_choices wrapper, get_result, and summary methods; added scipy.sparse import |
tests/test_simulate.py |
Added comprehensive tests for parse_choices and simulate_choices helpers |
tests/test_difficult_integration.py |
Updated compute_standard_errors calls to use new argument order |
tests/test_benchmark.py |
New test file to verify benchmark example runs end-to-end |
examples/benchmark.py |
Updated compute_standard_errors call to use new argument order |
examples/quickstart.py |
New example demonstrating the choices-first workflow |
examples/csv_example.py |
Removed (replaced by simpler quickstart example) |
pyproject.toml |
Added rich>=13.0.0 dependency for formatted output |
README.md |
Updated documentation to showcase both matrix-first and choices-first workflows; expanded API reference |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
…in text fallback for `ModelResult.summary` making `rich` optional, and update `fit` method type hints to `npt.ArrayLike`.
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.
User workflow and documentation improvements:
parse_choicesandsimulate_choices, allowing users to fit models directly from a list of choices (integers or tuples) viafit_choicesandfit(..., choices=...). The README and quickstart example (examples/quickstart.py) have been updated to highlight this simpler entry point. [1] [2] [3]Model API and input flexibility:
MultichoiceLogit.fitmethod to accept either matrix inputs or a list of choices, and added support for various dual-choice input formats (dense, sparse, or index tuples). Type annotations and input validation were improved for robustness. (Ff623fc5L394R417, [1] [2] [3]examples/csv_example.py) to streamline the codebase and focus on recommended workflows.Model result reporting:
ModelResultdataclass with a rich summary method, providing a formatted table of coefficients, standard errors, z-scores, and p-values, as well as optimizer diagnostics. This improves interpretability and makes it easier for users to inspect model output.Minor fixes and maintenance:
compute_standard_errorsin the benchmark script for consistency with the updated API.