Skip to content

Unify missing values display - #749

Open
meubleancien wants to merge 1 commit into
MAIF:developfrom
meubleancien:unify_missing_values_display
Open

Unify missing values display#749
meubleancien wants to merge 1 commit into
MAIF:developfrom
meubleancien:unify_missing_values_display

Conversation

@meubleancien

Copy link
Copy Markdown
Contributor

Title: feat: unify display of missing values across plots and webapp

Description

Enhancement: #721

Null/missing values from training datasets were displayed inconsistently across the web application: raw nan in some hover texts, None or in table tooltips, blank cells in the dataset table, and invisible points in the contribution plot for non-numeric features. Since some models (e.g. CatBoost) natively support missing values, null entries are legitimate feature values and deserve a consistent, unambiguous representation.

This PR unifies the display of null feature values as missing everywhere, extending the convention introduced in #700 for the violin plot. A shared helper format_missing_value / MISSING_VALUE_DISPLAY is added in shapash/utils/utils.py.

Changes by component

Component: Contribution plot (scatter, object/category features)
Before: null points not rendered, hover shows raw nan
After: rendered as a missing modality with x marker, hover shows missing
────────────────────────────────────────
Component: Contribution plot (violin)
Before: axis label says missing but point hover shows nan
After: point hover shows missing
────────────────────────────────────────
Component: Local plot
Before: y-axis label and hover show nan (incl. grouped features)
After: missing
────────────────────────────────────────
Component: Compare plot
Before: hover shows nan
After: missing
────────────────────────────────────────
Component: Cluster plot (classification & regression)
Before: point hover shows nan; all-null cluster raises IndexError on mode()[0]; all-null numeric
cluster crashes on NaN mean/std formatting
After: hover shows missing; all-null clusters handled; null can be reported as top modality, e.g.
feature top: missing (53.3%)
────────────────────────────────────────
Component: Dataset table
Before: cells blank, tooltips show nan/None
After: cells and tooltips show missing via shared get_datatable_data_and_tooltips helper
────────────────────────────────────────
Component: Identity card
Before: empty label for null values
After: missing

Tests

  • New unit tests for format_missing_value (NaN, None, pd.NA, pd.NaT, non-null passthrough, custom display string)
  • New scatter test for object-dtype features with nulls, extended violin test asserting hover customdata, new local plot null-display test
  • New tests for the DataTable data/tooltip helper

Two adjacent bugs surfaced during this work and are left out of scope (happy to open follow-up issues): the dtype check if type is float in smart_app.py makes the table rounding block dead code, and the webapp filters drop nulls entirely so missing values can't be filtered on.

PS:

  • this is more of ideas for Zakaria than a ready to merge PR
  • I used Claude Fable 5

Null feature values were rendered inconsistently (raw "nan", "None",
blank cells) depending on the component. They are now displayed as
"missing" everywhere, via a shared format_missing_value helper:

- contribution plot: extend NaN handling to object/category columns
  (missing modality + "x" marker) and fix violin point hover customdata
- local plot: bar labels and hover text, incl. grouped features
- compare plot: hover text
- cluster plot: point hover text in classification and regression
  branches; also guard all-null clusters (mode()[0] IndexError, NaN
  mean/std formatting) and allow null as top modality
- webapp dataset table: cells and tooltips through a shared
  get_datatable_data_and_tooltips helper; identity card label

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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