Skip to content

Comments

DRAFT: add other_value and top_k transform for cohorts#174

Open
gbowlin wants to merge 5 commits intoepic-open-source:mainfrom
gbowlin:add_cohort_other_transform
Open

DRAFT: add other_value and top_k transform for cohorts#174
gbowlin wants to merge 5 commits intoepic-open-source:mainfrom
gbowlin:add_cohort_other_transform

Conversation

@gbowlin
Copy link
Contributor

@gbowlin gbowlin commented Aug 1, 2025

Overview

An implementation of a cohort transformation that allows creation of an "Other" placeholder value for cohort columns that might have many options, but where we expect a long tail of small counts that can be meaningfully grouped together as "Other", or ignored by marking as np.nan or None.

Description of changes

Adds a cohort transform to allow renaming small count columns to an other_value group.

  cohorts:
    - source: many_values_column 
      display_name: All Different Values
    - source: many_values_column 
      display_name: Top 5 or Other
      top_k: 5
      other_value: "Other"

Author Checklist

  • Linting passes; run early with pre-commit hook.
  • Tests added for new code and issue being fixed.
  • Added type annotations and full numpy-style docstrings for new methods.
  • Draft your news fragment in new changelog/ISSUE.TYPE.rst files; see changelog/README.md.

@@ -191,6 +191,12 @@ class Cohort(BaseModel):
splits: Optional[list[Any]] = []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like splits is already used for categorical values -> where it does a change to np.nan for unknown columns, which might raise an error (should test)

@gbowlin gbowlin changed the title add other_value and top_k transform for cohorts DRAFT: add other_value and top_k transform for cohorts Aug 1, 2025
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