brute-force-plotter icon indicating copy to clipboard operation
brute-force-plotter copied to clipboard

Add target variable highlighting for visualizations

Open Copilot opened this issue 4 months ago • 1 comments

Target Variable Support Implementation ✅

This PR adds support for specifying a target variable that will be highlighted in visualizations, making it easier to understand relationships between features and the target variable in machine learning tasks.

What's New:

Target Variable Highlighting - Specify a column to highlight throughout all plots

  • CLI: --target COLUMN option
  • Library: target='column_name' parameter
  • Works with both categorical and numeric targets

What Gets Highlighted:

  • 📊 Scatter Plots (Numeric vs Numeric): Points colored by target variable
  • 📈 Distribution Plots (Single Numeric): Histograms and violin plots grouped by target
  • 📊 Bar Plots (Single Categorical): Bars grouped/colored by target

Recent Improvements (addressing code review feedback):

  • [x] Fixed missing sharex=True parameter in single variable plots for consistency
  • [x] Extracted target validation logic to shared utility function validate_target_variable()
  • [x] Removed code duplication between CLI and library interfaces
  • [x] CLI now validates target exists in data types
  • [x] Library validates target exists in both data types and actual data
  • [x] All 148 tests passing

Changes Made:

  • [x] Add target parameter to CLI (--target option)
  • [x] Add target parameter to library interface
  • [x] Add global config for target variable storage
  • [x] Update scatter plots to use target for coloring
  • [x] Update numeric distribution plots to group by target
  • [x] Update categorical plots to use target as hue
  • [x] Add comprehensive tests (5 new tests, all passing)
  • [x] Update documentation with examples and visual comparison
  • [x] Run full test suite (148 tests, all passing)
  • [x] Format and lint all code
  • [x] Security scan (0 vulnerabilities)
  • [x] Address code review feedback

Usage Examples:

CLI:

python -m src data.csv dtypes.json output --target Survived

Library:

import brute_force_plotter as bfp
bfp.plot(data, dtypes, output_path='./plots', target='Survived')

Backward Compatibility:

✅ Fully backward compatible - the target parameter is optional ✅ All existing tests pass without modification ✅ Default behavior unchanged when target is not specified

Test Results:

  • Total Tests: 148 (5 new tests added)
  • Pass Rate: 100%
  • Coverage: ~96%
  • All linting checks pass
  • Security scan: 0 vulnerabilities
Original prompt

This section details on the original issue you should resolve

<issue_title>target variable support</issue_title> <issue_description>having support for a target variable.

</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes eyadsibai/brute-force-plotter#28

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Oct 27 '25 11:10 Copilot