Skip to content

refactor(models): define pretrain and optimize_hparams once - #634

Open
jorisstrakeljahn wants to merge 3 commits into
OpenTabular:mainfrom
jorisstrakeljahn:refactor/share-pretrain-and-search
Open

jorisstrakeljahn wants to merge 3 commits into
OpenTabular:mainfrom
jorisstrakeljahn:refactor/share-pretrain-and-search

Conversation

@jorisstrakeljahn

Copy link
Copy Markdown
Contributor

pretrain and optimize_hparams existed twice, almost word for word, in the classifier base and the regressor base. The only intended difference was one True or False flag. This PR moves both into a small mixin that the two bases share, so the copies cannot drift apart.

They had already started to drift a little. The classifier checked for a missing data module and raised NotFittedError. The regressor had no such check, only a type ignore, and would fail with an AttributeError. Both now raise NotFittedError. A built model always has a data module, so I think this only shows if someone clears it by hand.

There are three commits:

  1. A test that pins which regression flag (True or False) a classifier and a regressor pass to the pretraining. It passes on main and after each commit.
  2. pretrain moves into the shared mixin.
  3. optimize_hparams moves into the shared mixin.

The public methods and their signatures are unchanged. I compared main and this branch with a script: all public method signatures of the estimators are identical, and seeded runs of pretrain and of a short search give identical weights and predictions.

I left the regression argument of the search mixin alone, although nothing reads it. Removing it needs a change in lss_base.py, which several open PRs touch.

just test: 3376 passed
just check: passes

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
deeptab/models/_mixins/point.py 68.00% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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