Skip to content

v4a - #4

Merged
tmonk merged 7 commits into
masterfrom
v4a
Nov 25, 2025
Merged

v4a#4
tmonk merged 7 commits into
masterfrom
v4a

Conversation

@tmonk

@tmonk tmonk commented Nov 25, 2025

Copy link
Copy Markdown
Owner

User workflow and documentation improvements:

  • Added a choices-first workflow with new functions parse_choices and simulate_choices, allowing users to fit models directly from a list of choices (integers or tuples) via fit_choices and fit(..., choices=...). The README and quickstart example (examples/quickstart.py) have been updated to highlight this simpler entry point. [1] [2] [3]
  • Expanded and clarified documentation in the README, including new sections on data formats, input flexibility, and interpreting output tables. [1] [2]

Model API and input flexibility:

  • Updated the MultichoiceLogit.fit method 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]
  • Deprecated and removed the older CSV example script (examples/csv_example.py) to streamline the codebase and focus on recommended workflows.

Model result reporting:

  • Introduced a new ModelResult dataclass 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:

  • Fixed the argument order for compute_standard_errors in the benchmark script for consistency with the updated API.

…tandard_errors` signatures to accept `flat_beta` as a keyword argument.
…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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_errors argument order (X, y_single, y_dual, flat_beta) across all call sites
  • Introduced parse_choices() and simulate_choices() helpers for the new choices-first workflow
  • Added fit_choices(), get_result(), and ModelResult class 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`.
@tmonk
tmonk merged commit b21bb9f into master Nov 25, 2025
15 checks passed
@tmonk
tmonk deleted the v4a branch November 25, 2025 01:11
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.

2 participants