Repository navigation
Conversation
set_params() on preprocessing_config replaces _preprocessor with an unfitted one for the next fit(), but save() and fit(rebuild=False) read _preprocessor, so the saved artifact could not predict and continuation raised NotFittedError. Use the data module's fitted preprocessor in both places. Fixes #561
This branch has not been deployed
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.
Fixes #561
Problem
set_params(preprocessing_config=...)/set_params(preprocessing_config__...=...)prepare the nextfit(). They replaceestimator._preprocessorwith a new, unfitted preprocessor. The fitted preprocessor that the in-memory model keeps using lives onestimator._data_module. Two code paths readestimator._preprocessorinstead:build_save_bundle()saved the unfitted preprocessor, so the artifact'spredict()raisedNotFittedErrorafterload();_prepare_continuation()built the continuation data with it, sofit(rebuild=False)raised the same error.Fix
deeptab/core/serialization.py(build_save_bundle): the artifact and its metadata take the data module's fitted preprocessor, falling back toestimator._preprocessorwhen there is none.preprocessor_kwargsandpreprocessing_configare still saved as set, so a refit afterload()uses the new settings. As a consequence,artifact_metadata["preprocessing"]holds the pendingkwargsnext to the fitted preprocessor'sspecandfingerprintwhen settings changed afterfit().deeptab/models/_mixins/fit.py(_prepare_continuation): continuation reuses the previous data module's fitted preprocessor, as the docs describe ("Continuation also reuses fitted preprocessing").Tests
tests/integration/test_preprocessing_changes_after_fit.py(new), forMLPRegressorandMLPLSS:test_save_after_set_params_keeps_the_fitted_preprocessor: the reloaded artifact reproduces the in-memory predictions.test_continuation_after_set_params_uses_the_fitted_preprocessorBoth tests change
cat_cutoffafterfit(): onmain,n_binsset throughset_params()doesn't reach the new preprocessor (#489), whilecat_cutoffdoes. All four cases fail onmainand pass with this change.Docs
No change needed.
Checks
just test: 3240 passed, 46 skipped, 28 xfailed; coverage 91.28%just docs: build succeeded (warnings treated as errors)just check: all hooks passed (ruff, prettier, pyright)