Fix index misalignment in char_wb ngram padding - #8429
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesVectorizer API and character n-gram behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized fix adjusts character n-gram padding alignment and includes focused test changes; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
python/cuml/cuml/feature_extraction/_vectorizers.py (1)
216-224: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd an enabled
char_wbTfidf regression test.In
python/cuml/tests/test_text_feature_extraction.py, testTfidfVectorizer.fit_transform(analyzer="char_wb", ngram_range=(2, 6)). Compare the sparse output and feature names with scikit-learn usingget_feature_names_out().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@python/cuml/cuml/feature_extraction/_vectorizers.py` around lines 216 - 224, Add an enabled regression test in test_text_feature_extraction.py covering TfidfVectorizer with analyzer="char_wb" and ngram_range=(2, 6). Fit and transform the same input with cuML and scikit-learn, then compare sparse outputs and feature names using get_feature_names_out().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@python/cuml/cuml/feature_extraction/_vectorizers.py`:
- Around line 216-224: Add an enabled regression test in
test_text_feature_extraction.py covering TfidfVectorizer with analyzer="char_wb"
and ngram_range=(2, 6). Fit and transform the same input with cuML and
scikit-learn, then compare sparse outputs and feature names using
get_feature_names_out().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 80ca255e-7d3d-41f0-ab51-594df4f04c33
📒 Files selected for processing (1)
python/cuml/cuml/feature_extraction/_vectorizers.py
|
@divyegala Can you review this, please? |
divyegala
left a comment
There was a problem hiding this comment.
Thank you for the contribution! Could you please add a test?
|
Added |
|
/ok to test 36f9500 |
|
/merge |
Fixes #8416
Root cause
get_char_ngrams()pads each token withself.delimiteron both sides before generating character ngrams: