fix: scitype-correct export_code examples, is_pipeline, dataset, loaded models (#534) - #547
Open
Shashankss1205 wants to merge 1 commit into
Open
fix: scitype-correct export_code examples, is_pipeline, dataset, loaded models (#534)#547Shashankss1205 wants to merge 1 commit into
Shashankss1205 wants to merge 1 commit into
Conversation
…ed models (#534) - BUG-03: the fit example was forecaster-shaped for every scitype, so running the generated code for a transformer/splitter/classifier raised AttributeError. Branch the example on object_type: transformers get fit_transform, splitters iterate split(), classifiers/regressors get fit(X, y)/predict(X), forecasters keep fit(y)/predict(fh). All four generated examples now execute. - BUG-04: is_pipeline used "[" in spec, false-positiving on any list argument. Derive it from the instance instead (spec "*" operator or hasattr steps). - NB-15: the dataset argument was ignored and unknown names silently fell back to airline. Honour it, and reject an unknown dataset with a clear error. - NB-17: loaded models carry no craft spec and failed with "No craft spec found". Emit a runnable load_model(path) snippet from the handle metadata. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 #534.
Four
export_codedefects (the string-escaping one, BUG-02, was already fixed in #518):BUG-03 — fit example was forecaster-shaped for every scitype
export_code(handle, include_fit_example=true)always emittedfit(y)/predict(fh), so running the generated code raisedAttributeErrorfor transformers (nopredict), splitters (nofit), and classifiers. The example now branches onobject_type:fit_transform(y)split(y)fit(X, y)/predict(X)fit(y)/predict(fh)All four generated examples are executed in the tests.
BUG-04 — is_pipeline false-positived on any list argument
is_pipeline = ... or "[" in specflagged e.g.SlidingWindowSplitter(fh=[1,2,3])as a pipeline. Now derived from the instance: a craft*in the spec orhasattr(instance, "steps").NB-15 — dataset argument ignored; unknown names silently used airline
The
datasetparam is now honoured, and an unknown dataset is rejected with a clear error (rather than silently falling back toload_airline).NB-17 — loaded models couldn't be exported
load_modelhandles carry no craft spec, so export failed with "No craft spec found". They now emit a runnableload_model("<path>")snippet built from the handle metadata.Testing
tests/test_export_code_scitype.py(11 tests): is_pipeline true/false cases; exec of the generated example for forecaster/transformer/splitter/classifier; unknown-dataset rejected and known-dataset (lynx) used; loaded-model handle emits aload_modelsnippet.🤖 Generated with Claude Code