Skip to content

ISLP 0.7: ModelSpec from modelmatrix - #72

Merged
jonathan-taylor merged 2 commits into
mainfrom
islp-0.7-modelmatrix
Oct 27, 2026
Merged

jonathan-taylor merged 2 commits into
mainfrom
islp-0.7-modelmatrix

Conversation

@jonathan-taylor

@jonathan-taylor jonathan-taylor commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

ModelSpec has moved to its own package, modelmatrix (0.3.0 on PyPI). ISLP now depends on modelmatrix>=0.3 instead of carrying its own copy.

Imports keep working.

  • from ISLP.models import ModelSpec (and poly, ns, bs, pca, derived_feature, contrast, ordinal, ...) gives modelmatrix's objects.
  • ISLP.models also exports modelmatrix's wildcard (R's .), Contrast, Ordinal and its responses Surv, Binomial, Multinomial and Outcome.
  • ISLP.models.model_spec, ISLP.models.columns and ISLP.transforms are aliased to modelmatrix's modules in sys.modules, so from ISLP.transforms import Poly and similar still work, private names included.

Breaking, as 0.6.0 announced: intercept defaults to False. statsmodels' models, and sklearn_sm / sklearn_selected with them, need intercept=True. The 0.6.0 FutureWarning about the move is gone.

Bug fix in strategy.py. Stepwise selection counted terms with model_spec.terms and mapped them to terms_ by position. With a wildcard, which is one term standing for many, the two lists don't line up, and selection failed. It now counts terms_ and maps given terms (lower_terms, upper_terms, initial_terms) to their fitted versions through features_. A column the wildcard stands for can therefore be a lower term. The unused imports of the column helpers, and the unused _build_submodel, are removed.

Tests:

  • The ModelSpec tests moved to modelmatrix.
  • tests/models/test_modelmatrix.py checks the re-exports, the old import paths and the new default. It also checks stepwise selection with a wildcard: forward, a lower term among the wildcard's columns, and fixed-step backward. Those three tests fail on the old strategy.py.
  • The two stepwise tests that were in the old ModelSpec tests moved here: a strict xfail for derived terms, and the 1-SD rule.
  • Locally: 58 passed, 2 xfailed (without the network test).

Docs:

  • The ModelSpec and transforms pages now live in modelmatrix's docs. ISLP's sidebar keeps the entries, as links there: spec, ANOVA, comparison, responses, poly, splines and PCA. models/selection stays an ISLP page. The moved notebooks are removed.
  • intersphinx maps modelmatrix's API, so a reference like :py:class:modelmatrix.ModelSpec`` links to its API page.
  • The API list drops ISLP.models.model_spec, ISLP.models.columns and ISLP.transforms, which are now modelmatrix's modules.
  • Checked with a local Sphinx build (notebooks not executed), using the objects.inv of a local modelmatrix docs build. The reference resolves, no page links to a removed one, and there are fewer warnings than before.
  • The links and the inventory need modelmatrix's site to be deployed (one manual run of its Build docs workflow). Until then, an ISLP docs build gets an intersphinx warning, and the links return 404.

Not in this PR:

  • The labs (ISLP_labs) need intercept=True wherever they rely on the old default, plus the Ch07 ordinal('education') fix. That's a separate PR there.

🤖 Generated with Claude Code

jonathan-taylor and others added 2 commits October 26, 2026 16:33
ISLP now depends on modelmatrix>=0.3, to which ModelSpec moved.

- ISLP.models re-exports modelmatrix's ModelSpec and features, and its
  wildcard, Contrast, Ordinal and responses (Surv, Binomial,
  Multinomial, Outcome).
- ISLP.models.model_spec, ISLP.models.columns and ISLP.transforms are
  modelmatrix's modules (aliased in sys.modules), so imports from them
  keep working.
- intercept defaults to False, as 0.6.0 announced; the FutureWarning
  is gone.
- strategy.py counts terms with terms_ and maps given terms to their
  fitted versions through features_, so a wildcard (one term standing
  for many) no longer misaligns them. Unused imports of the column
  helpers, and the unused _build_submodel, are removed.
- The tests of ModelSpec moved to modelmatrix; the stepwise tests stay,
  with new ones for a wildcard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- models.rst and transforms.rst keep their entries, now links to
  modelmatrix's pages (spec, anova, comparison, responses, poly,
  splines, pca); models/selection stays an ISLP page.
- The moved notebooks (and their jupytext sources) are removed.
- intersphinx maps modelmatrix's API, so :py:class:`modelmatrix.ModelSpec`
  links there.
- The API list drops ISLP.models.model_spec, ISLP.models.columns and
  ISLP.transforms, now modelmatrix's modules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonathan-taylor
jonathan-taylor merged commit 21c55b6 into main Oct 27, 2026
1 check passed
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.

1 participant