The raw data
The source is the UCI Mushroom dataset, drawn from a 1981 Audubon Society field guide. Every column is categorical, a single letter in the raw file, decoded here for reading. The target is the class: edible or poisonous. Note the flagged stalk-root cells, marked missing in the source.
Cleaning
All categorical, so no scaling or outliers, but two judgment calls. veil-type has the same value for every mushroom, so it carries zero information and is dropped. stalk-root is missing for 2,480 rows; rather than throw away a third of the data, the missing value is kept as its own category. Then every trait is one-hot encoded, turning 21 columns into 116.
The tell: odor
Before any model, one feature carries most of the story. Grouped by odor, the classes separate almost perfectly: every foul, fishy, spicy, pungent, creosote, or musty mushroom is poisonous; almond and anise are edible. Only "no odor" mixes, and even then it leans edible.
Odor vs class
Spore print color
Gill size
Bruises
Two models, and why accuracy lies
A logistic regression baseline and a shallow decision tree, both trained on 70% of the data and scored on the 30% held out. Both clear 99.8% on every metric. That is exactly where a careful analyst gets suspicious, not satisfied.
The confusion matrix splits the mistakes. A false positive throws away a good mushroom. A false negative feeds someone poison. Here every error is the second kind.
ROC, and tuning the threshold to be safe
The ROC curve confirms the models rank poison above edible almost perfectly (AUC near 1.0). But the 0.50 cutoff is a choice, not a law. Since a missed poison is the costly error, drag the threshold down and watch the false negatives disappear, at some cost elsewhere.
ROC curve
Live model: run the decision tree
This is the real trained tree, running in your browser. Set the traits and it walks the same rules it learned, showing the exact decision path to its verdict. These eight traits are the ones the tree actually uses.
Analysis, models, and visuals by Carlos Abel Vivanco / AbleV Labs · Read the full notebook → · Back to the case study →