Skip to content

[WIP][MLLIB] Rewrite CountVectorizer fitting with DataFrame APIs - #57755

Draft
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:count-vectorizer-dataframe-fit-dev3
Draft

[WIP][MLLIB] Rewrite CountVectorizer fitting with DataFrame APIs#57755
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:count-vectorizer-dataframe-fit-dev3

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This draft rewrites CountVectorizer.fit to use DataFrame operations instead of converting the input to an RDD. It calculates term frequency with explode and aggregation, and calculates document frequency with explode(array_distinct(...)) only when DF filtering is requested. It also uses a native ordered limit for vocabulary selection.

Why are the changes needed?

The current implementation leaves the DataFrame execution path for manual per-document maps and reduceByKey. Keeping the computation in DataFrame operations lets Spark plan the aggregations natively and avoids document-frequency work when neither DF parameter is set.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added regression coverage that distinguishes document frequency from repeated term frequency. build/sbt mllib/Test/compile completed successfully. The test suite was not run. Static checks: git diff --check, ASCII scan, and changed-line length scan.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Codex (GPT-5)

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.

1 participant