feat(operator): reject Count Vectorizer on the Gaussian Naive Bayes operators - #7599
Open
kz930 wants to merge 1 commit into
Open
feat(operator): reject Count Vectorizer on the Gaussian Naive Bayes operators#7599kz930 wants to merge 1 commit into
kz930 wants to merge 1 commit into
Conversation
…perators Gaussian Naive Bayes and Training: Gaussian Naive Bayes offered a Count Vectorizer switch with no working setting. Turning it on ended the execution from inside scikit-learn: CountVectorizer emits a sparse matrix, and GaussianNB validates its input without accept_sparse because it estimates a mean and a variance per feature, which reads the zeros too. The refusal is deliberate on scikit-learn's side, since densifying a text matrix with a large vocabulary is what would exhaust memory. It is specific to this estimator, not to the switch. Fitting make_pipeline(CountVectorizer(), Estimator()) on the same documents, only GaussianNB raises; MultinomialNB, BernoulliNB and ComplementNB accept the sparse matrix, as do the rest of the estimators both groups use. The switch is declared once on SklearnModelOpDesc and both families splice it in the same way, so all of them inherit it whether or not their estimator can use it. An estimator that cannot take the sparse matrix now names what to reach for instead, and the shared getOutputSchemas turns that into a compile-time failure naming both. Hiding the switch would have been the closer match to how the family handles an impossible pairing already, but a hide keys on a sibling field's value and is evaluated in the frontend, so it cannot be made per estimator on a field the base declares once. It would also leave a workflow already saved with the switch on still failing at run time. The message names the estimator and the three Naive Bayes variants that do accept the matrix. Nothing fires while the switch is off, which is its default, so a freshly dropped operator is not reported invalid before it is configured. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Automated Reviewer SuggestionsBased on the
|
Contributor
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7599 +/- ##
=========================================
Coverage 88.63% 88.63%
Complexity 4346 4346
=========================================
Files 1177 1177
Lines 46896 46896
Branches 5230 5230
=========================================
Hits 41568 41568
Misses 3568 3568
Partials 1760 1760
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What changes were proposed in this PR?
Gaussian Naive BayesandTraining: Gaussian Naive Bayesoffered aCount Vectorizerswitch with no working setting. Turning it on ended the execution from inside scikit-learn:CountVectorizeremits a sparse matrix, andGaussianNBvalidates its input withoutaccept_sparsebecause it estimates a mean and a variance per feature, which reads the zeros too. The refusal is deliberate on scikit-learn's side, since densifying a text matrix with a large vocabulary is what would exhaust memory.It is specific to this estimator, not to the switch. The switch is declared once on
SklearnModelOpDescand both families splice it into the pipeline the same way, so every estimator in both groups inherits it whether or not its own can use it.An estimator that cannot take the sparse matrix now names what to reach for instead, and the shared
getOutputSchemasturns that into a compile-time failure naming both. Nothing fires while the switch is off, which is its default, so a freshly dropped operator is not reported invalid before it is configured.Hiding the switch would have been the closer match to how the family already handles an impossible pairing, since
Tfidf TransformerandText Attributeare hidden whenCount Vectorizeris off. It is not available here: a hide keys on a sibling field's value and is evaluated in the frontend, so it cannot be made per estimator on a field the base declares once. It would also leave a workflow already saved with the switch on still failing at run time, which the compile-time check catches.Any related issues, documentation, discussions?
Fixes #7597.
How was this PR tested?
make_pipeline(CountVectorizer(), Estimator())on the same documents,GaussianNBraises the TypeError in the issue whileMultinomialNB,BernoulliNBandComplementNBall fit, which is what the message points at.WorkflowOperator/testOnly *Sklearn*: 62 suites, 421 tests, none failed.scalafmtCheckAlland both scalafix checks clean.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5)