Subgroup Discovery with pysubgroup
A practical guide to finding, understanding, and validating interesting subgroups.
Subgroup discovery looks for interpretable descriptions of parts of a dataset whose target behavior is unusual. A description might combine two conditions; its rows might have an unusually high rate of an outcome, a different numeric distribution, or an exceptional relationship between variables.
This book connects the ideas of subgroup discovery to executable analyses
with pysubgroup: formulating a question, defining candidate descriptions,
choosing a quality function, searching, and interpreting and validating the
results.
Who this guide is for¶
The intended reader knows basic Python and pandas. The guide introduces subgroup discovery from the beginning and develops the relevant concepts alongside the code.
Contents¶
- Subgroup Discovery with pysubgroup
- I. Getting started
- II. Defining the search
- III. Beyond binary targets
- IV. Understanding and validating results
- V. End-to-end workflows
- VI. Advanced use and extension
- Reference
Choose a reading path¶
New to subgroup discovery? Start with the idea and a complete first search, then work through Part II. You will learn to choose descriptions, quality functions, constraints, and search algorithms before moving to more complex targets.
Have a specific target? Go to numeric outcomes, multiple targets and WKL, Exceptional Model Mining, or classifier auditing.
Already have results? Learn to read and visualize them, choose a diverse set, compare with simpler descriptions, and validate fixed candidates.
Want a complete analysis? Follow the Adult exploration or the validated model audit.
Extending or tuning the package? Read about performance, custom quality functions, custom targets and models, and specialized tasks.
For quick lookup, use the method-selection tables, API reference, glossary, and troubleshooting guide.
Running the examples¶
Each executable chapter starts with its own imports and data setup. Run its cells
in order in a fresh Python kernel. Examples require pysubgroup[plot]. The first
search and the longer Adult workflow download Adult from OpenML on first use
and share a book-local data cache. Most other chapters use offline scikit-learn
datasets or synthetic data. Randomized examples use explicit seeds.
The book uses small tasks suitable for a laptop. Plots and tables are computed from the examples, rather than pasted from an unrelated run. Most chapters end with an experiment to help connect the code with the underlying question.