feat(workflow-operator): vectorize every named text column, not just one - #7668
feat(workflow-operator): vectorize every named text column, not just one#7668kz930 wants to merge 1 commit into
Conversation
Text Attribute named one column, so a dataset whose text is spread over several could not be used as it stands. A title beside a body, or a description beside a comment, is ordinary, and the only way through was a Concat upstream, which merges the columns into one string and gives up which column each word came from. Naming several columns was not an alternative. CountVectorizer takes a flat sequence of documents, so a two-column frame reaches it as two documents rather than as the rows, and it learns a vocabulary of the column names. The field takes a list, and the generated pipeline opens with a ColumnTransformer that gives each named column its own CountVectorizer and concatenates the results, so a word keeps the column it came from through the feature's prefix. The steps are named by position rather than after the column, keeping a column whose name carries a double underscore away from the separator get_feature_names_out puts between step and feature. The transformer names the columns it reads, so the frame no longer has to be narrowed before the pipeline, and that line goes. Tfidf Transformer stays one switch over the whole matrix, which leaves the shape of the pipeline as it was. Turning Count Vectorizer on still discards the numeric columns, as before: carrying them along needs a way to say which columns are features, which these two families do not have. A workflow written before this holds a bare string in the field, which reads as a list of one, so nothing has to be migrated. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7668 +/- ##
============================================
+ Coverage 89.65% 89.77% +0.11%
- Complexity 4397 4414 +17
============================================
Files 1177 1177
Lines 46996 47018 +22
Branches 5268 5270 +2
============================================
+ Hits 42136 42212 +76
+ Misses 3094 3035 -59
- Partials 1766 1771 +5
*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:
|
✅ No material benchmark regressions detected🟢 4 better · 🔴 0 worse · ⚪ 11 noise (<±5%) · 0 without baseline
Baseline detailsLatest main
Raw CSVconfig_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,458.68,200,128000,436,0.266,21966.28,27068.89,27068.89
1,100,10,64,20,2116.06,2000,1280000,945,0.577,105327.67,127900.51,127900.51
2,1000,10,64,20,18140.91,20000,12800000,1102,0.673,903853.08,993171.22,993171.22 |
|
@aglinxinyuan @carloea2 May you take a look at it? |
aglinxinyuan
left a comment
There was a problem hiding this comment.
Can you test with a real workflow?
What changes were proposed in this PR?
Text Attributenamed one column, so a dataset whose text is spread over several could not be used as it stands. A title beside a body, or a description beside a comment, is ordinary, and the only way through was a Concat upstream, which merges the columns into one string and gives up which column each word came from.Naming several columns was not an alternative either.
CountVectorizertakes a flat sequence of documents, so a two-column frame reaches it as two documents rather than as the rows, and it learns a vocabulary of the column names:The field now takes a list, and the generated pipeline opens with a
ColumnTransformerthat gives each named column its ownCountVectorizerand concatenates the results, so a word keeps the column it came from through the feature's prefix:The steps are named by position rather than after the column, which keeps a column whose name carries a double underscore away from the separator
get_feature_names_outputs between step and feature. The transformer names the columns it reads, so the frame no longer has to be narrowed before the pipeline and that line goes.Tfidf Transformerstays one switch over the whole matrix, leaving the shape of the pipeline as it was. TurningCount Vectorizeron still discards the numeric columns, as before: carrying them along needs a way to say which columns are features, which these two families do not have, and that is a separate change.The operator's output is unchanged, one row of
model_nameandmodel. A workflow written before this holds a bare string in the field, whichACCEPT_SINGLE_VALUE_AS_ARRAYreads as a list of one, so nothing has to be migrated.The field is declared on
SklearnModelOpDesc, so this reaches all fifty-one operators of the Sklearn and Sklearn Training groups.Any related issues, documentation, discussions?
Closes #7667
This touches the same line of the two codegen templates as #7645, which rewrites it while this deletes it. Whichever merges second needs that line resolved by hand: the
elsebranch #7645 introduces is kept, and theifbranch this removes stays removed.How was this PR tested?
SklearnClassifierOpDescCodegenSpecandSklearnTrainingOpDescCodegenSpecpinned the generated pipeline and were updated to the new one, each gaining a case for several columns getting a vectorizer apiece. The fifty-one per-operator specs that pinned the field's default were updated to the empty list.WorkflowOperator/testpasses: 2287 tests.The emitted line was also run as it stands, with the base64 decoding stubbed, against a frame of two text columns and a numeric one: it fits, and the feature names carry the
text0__andtext1__prefixes.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5)