https://github.com/cmudig/divisi-toolkit

https://github.com/cmudig/divisi-toolkit

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    1 of 5 committers (20.0%) from academic institutions
  • Institutional organization owner
    Organization cmudig has institutional domain (dig.cmu.edu)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.1%) to scientific vocabulary
Last synced: 7 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: cmudig
  • License: mit
  • Language: JavaScript
  • Default Branch: main
  • Size: 5.51 MB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 2
  • Releases: 0
Created about 3 years ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.md

Divisi - Interactive Subgroup Discovery

Divisi is a tool to find interpretable patterns in large datasets that can be expressed as tabular features (for example, transactions, survey responses, electronic health records, or text documents). It runs faster than existing rule-based subgroup discovery algorithms and has an interactive interface to help you probe and curate subgroups of interest. Check out the paper (CHI 2025) to learn more.

Quickstart

Optionally create a virtual environment with Python >3.7. Install the package:

bash pip install divisi-toolkit

Install Jupyter Notebook or Jupyter Lab if not already installed. Then start a Jupyter server. The example_data/demo.ipynb notebook shows how to start the interactive widget or use the subgroup discovery algorithm programmatically.

Usage

To run Divisi, you first need to create a preprocessed, discretized version of your dataset. The easiest way is to take a Pandas dataframe and run the discretize_data command:

```python import divisi

discretedf = divisi.discretizedata( df, customcols={ # Specify custom discretization strategies here 'Age': divisi.binvalues(quantiles=5), # ... }, remove_cols=[ # Specify columns to remove from subgroup discovery 'Label' # ... ]) ```

If you have a text dataset, you can also use the discretize_token_sets method. (TODO provide example of text encoding)

Then, to use the Divisi interface in a notebook, simply create a DivisiWidget instance:

python w = divisi.DivisiWidget( discrete_df, # provide a path to store interface state so you can pick up where you left off state_path="divisi_state", # metrics to display for each subgroup (must be numpy arrays) metrics={ "Label": y, "Error": is_error }) w

By default, ranking functions will be created based on the metrics you provide. You can also provide ranking functions using the ranking_functions keyword argument to the DivisiWidget constructor. The following ranking functions are available in divisi.ranking:

  • OutcomeRate(y: ndarray, inverse: bool = false): Prioritizes subgroups with a higher rate of the given binary outcome y within the subgroup. If inverse is True, prioritizes subgroups with a lower rate.
  • OutcomeShare(y: ndarray): Prioritizes subgroups that capture more of the positive instances of the binary outcome y. Helps to measure coverage of the subgroup.
  • InteractionEffect(y: ndarray): Prioritizes subgroups for which all rule features contribute highly to the rate of the given binary outcome.
  • MeanDifference(y: ndarray): Prioritizes subgroups which have a mean of the given continuous metric y substantially different from the average.
  • Entropy(y: ndarray, inverse: bool = false): Prioritizes subgroups with a lower (or, if inverse is True, higher) entropy for the given integer-valued metric y inside the subgroup than outside.
  • SubgroupSize(ideal_fraction: number, spread: number): Scores subgroups by their size according to a Gaussian curve with a mean of ideal_fraction and a standard deviation of spread.
  • SimpleRule(): Prioritizes subgroups defined by rules with fewer features.

Programmatic Usage

To generate subgroups using pure Python without the interface, initialize an instance of SamplingSubgroupSearch with the discretized data object, ranking functions, and any search parameters, then run the sampler:

```python finder = divisi.sampling.SamplingSubgroupSearch( discretedf, { "High True Labels": divisi.ranking.OutcomeRate(y), "High Errors": divisi.ranking.OutcomeRate(iserror), "Simple Rule": divisi.ranking.SimpleRule() }, # additional sampling options minitemsfraction=0.05 # ... )

results, _ = finder.sample(50) ```

After running the sampler, you can re-rank the results based on the provided ranking functions without rerunning the search:

python for rule in results.rank({"High True Labels": 1.0, "Simple Rule": 0.25}): # rule.feature gets the predicate, rule.score_values contains the scores for each ranking function print(rule) # make a boolean mask over the dataframe corresponding to the rule mask = discrete_df.mask_for_rule(rule)

Citation

Please use the following citation if using Divisi in your projects:

bibtex @inproceedings{sivaraman2025divisi, title = {{Divisi: Interactive Search and Visualization for Scalable Exploratory Subgroup Analysis}}, author = {Sivaraman, Venkatesh and Li, Zexuan and Perer, Adam}, year = {2025}, publisher = {Association for Computing Machinery}, address = {New York, NY, USA}, doi = {10.1145/3706598.3713103}, booktitle = {Proceedings of the CHI Conference on Human Factors in Computing Systems}, numpages = {17}, location = {Yokohama, Japan}, series = {CHI '25} }

If you have a cool use case for Divisi, tell us about it!

Running in Development Mode

To develop the frontend, make sure you have an up-to-date version of NodeJS in your terminal, then run:

bash cd client npm install vite

The vite command starts a live hot-reload server for the frontend. Then, when you initialize the DivisiWidget, pass the dev=True keyword argument to use the live server. (Make sure that you don't have anything else running on port 5173 while you do this.)

Owner

  • Name: CMU Data Interaction Group
  • Login: cmudig
  • Kind: organization
  • Location: Pittsburgh, PA

People, Visualization, Analysis, Machine Learning

GitHub Events

Total
  • Delete event: 4
  • Push event: 2
  • Pull request event: 2
  • Create event: 1
Last Year
  • Delete event: 4
  • Push event: 2
  • Pull request event: 2
  • Create event: 1

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 44
  • Total Committers: 5
  • Avg Commits per committer: 8.8
  • Development Distribution Score (DDS): 0.205
Past Year
  • Commits: 28
  • Committers: 2
  • Avg Commits per committer: 14.0
  • Development Distribution Score (DDS): 0.143
Top Committers
Name Email Commits
Venkatesh Sivaraman v****8@g****m 35
ZX L z****l@Z****l 4
Rohit Chougule i****c@r****u 3
Rohit Chougule i****c@R****l 1
Rohit Chougule i****e@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 6
  • Average time to close issues: N/A
  • Average time to close pull requests: 9 days
  • Total issue authors: 0
  • Total pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.17
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 1 minute
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • iamrohitrc (4)
  • venkatesh-sivaraman (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 35 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
pypi.org: divisi-toolkit

Interactive widget and toolkit for slice discovery

  • Homepage: https://github.com/cmudig/divisi-toolkit
  • Documentation: https://divisi-toolkit.readthedocs.io/
  • License: MIT License Copyright (c) 2024 CMU Data Interaction Group Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 0.3.0
    published about 1 year ago
  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 35 Last month
Rankings
Dependent packages count: 10.7%
Average: 35.6%
Dependent repos count: 60.4%
Maintainers (1)
Last synced: 8 months ago

Dependencies

client/package-lock.json npm
  • 246 dependencies
client/package.json npm
  • @anywidget/vite ^0.1.1 development
  • @sveltejs/vite-plugin-svelte ^2.0.2 development
  • @tsconfig/svelte ^3.0.0 development
  • anywidget ^0.1.2 development
  • autoprefixer ^10.4.13 development
  • postcss ^8.4.21 development
  • svelte ^3.55.1 development
  • svelte-check ^2.10.3 development
  • tailwindcss ^3.2.7 development
  • tslib ^2.5.0 development
  • typescript ^4.9.3 development
  • vite ^4.5.2 development
  • @fortawesome/free-regular-svg-icons ^6.3.0
  • @fortawesome/free-solid-svg-icons ^6.3.0
  • @upsetjs/bundle ^1.11.0
  • d3 ^7.8.2
  • layercake ^7.2.2
  • svelte-fa ^3.0.3
  • svelte-select ^5.5.2
pyproject.toml pypi
  • anywidget *
  • importlib-metadata python_version<"3.8"
  • ipywidgets *
  • numpy *
  • scipy *