fix: map randomForest 'classification' type to 'class' in gg_variable class attr#90
Merged
Merged
Conversation
… class attr
randomForest stores family as object$type ("classification"), but the
plot.gg_variable dispatcher and the rfsrc path both use "class". Add an
explicit mapping so the class vector is consistent across engines and callers
never need to special-case "classification".
Adds one test verifying "class" is present and "classification" is absent.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
=======================================
Coverage 86.39% 86.39%
=======================================
Files 38 38
Lines 3021 3022 +1
=======================================
+ Hits 2610 2611 +1
Misses 411 411
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request standardizes the S3 class attribute applied by gg_variable.randomForest() so that randomForest classification models use "class" (matching the rfsrc path and plot.gg_variable’s family detection) instead of "classification".
Changes:
- Map
object$type == "classification"to"class"when building thegg_variableclass vector for randomForest models. - Add a unit test asserting
"class"is present and"classification"is absent fromclass(gg_variable(rf_iris)).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
R/gg_variable.R |
Maps randomForest "classification" type to "class" in the returned object’s S3 class vector for consistent downstream dispatch. |
tests/testthat/test_gg_variable.R |
Adds a regression test ensuring the class mapping is applied for randomForest classification models. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
gg_variable.randomForest()appendedobject$type("classification") to the class vector of the result, butplot.gg_variable's dispatcher and the rfsrc path both use"class"to identify classification forests"class"default), but fragile — anyinherits(gg_dta, "class")check would silently fail"classification"→"class"at the point of assignment with an explanatory comment; all otherobject$typevalues pass through unchangedTest plan
"class" %in% class(gg_variable(rf_iris))isTRUE"classification" %in% class(gg_variable(rf_iris))isFALSEtest_gg_variable.Rsuite passes (42 tests)Notes
Depends on nothing; safe to merge before or after PR #87/#88. The real-world impact is minimal today (dispatcher falls through to the same default) but the explicit mapping removes a latent surprise.
🤖 Generated with Claude Code