Enable categorical variables as predictors in IV analysis#247
Merged
Conversation
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Feature: Enable categorical variables as predictors in IV analysis
Enable categorical variables as predictors in IV analysis
Aug 4, 2025
Extended `create_IV()` and `map_IV()` to include character and factor variables as predictors, not just numeric.
Documented support for categorical predictors in create_IV(), enhanced display control in create_dt(), and improved test coverage. Also noted detection of text missing values in validation_report().
Member
|
wpa |
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.
The
create_IVfunction previously failed when categorical variables (e.g., Gender, Department, Region) were supplied as predictors because it only supported numeric variables. This limitation prevented analysts from including valuable categorical factors in their Information Value analysis.This PR also updates the package to
v1.10.0, and is submitted into CRAN.Changes Made
This PR extends the IV analysis pipeline to fully support categorical variables:
Core Implementation
calculate_IVfunction to detect and handle categorical variables usingis.character() || is.factor()map_IVfunction to include categorical variables in automatic predictor selectionBefore and After
Before:
After:
Example Output
For a categorical variable like
FunctionType, the function now produces meaningful results:Business Impact
This enhancement enables analysts to:
Testing
Added comprehensive test cases covering:
predictors=NULLFixes #230.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
cran.r-project.org/usr/lib/R/bin/exec/R --vanilla -e ~n~install.packages(c('dplyr',~+~'tidyr',~+~'tidyselect',~+~'purrr',~+~'ggplot2',~+~'glue'),~+~repos='REDACTED',~+~dependencies=TRUE)~n~(dns block)esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.