Skip to content
All work

ID3 mushroom classification

A from-scratch ID3 decision tree that predicts whether a mushroom is edible or poisonous from its attributes.

Type
School
Year
2020
Built with
Python · Decision trees · Information gain

A colleague and I implemented the ID3 algorithm from scratch, then trained it on mushroom attributes to classify each specimen as edible or poisonous.

Building a decision tree by hand — computing entropy and information gain at each split rather than calling a library — is the fastest way I know to understand why trees overfit, and why the split that looks most informative on training data is so often the one that betrays you.

The tree below was retrained with the same algorithm on the full UCI Mushroom dataset — 8,124 specimens, 22 attributes each. It asks about smell first, and for most mushrooms that’s the only question it needs. The odourless ones are where it has to work.

Mini game

Is it poisonous?

A real specimen from the dataset. Make your call, then see what the tree says.

Score
0 / 0
Streak
0
Best
0

Specimen

cap-shape
—
cap-surface
—
cap-color
—
bruises
—
odor
—
gill-attachment
—
gill-spacing
—
gill-size
—
gill-color
—
stalk-shape
—
stalk-root
—
stalk-surface-above-ring
—
stalk-surface-below-ring
—
stalk-color-above-ring
—
stalk-color-below-ring
—
veil-type
—
veil-color
—
ring-number
—
ring-type
—
spore-print-color
—
population
—
habitat
—
Keys: E · P · N
The whole tree · 8,124 training specimens, 0 misclassified
  • odor?8,124 specimens
    • nonespore-print-color?3,528 specimens
      • brownedible1,344 specimens
      • blackedible1,296 specimens
      • whitehabitat?624 specimens
        • grassesedible288 specimens
        • wasteedible192 specimens
        • leavescap-color?64 specimens
          • cinnamonedible24 specimens
          • brownedible24 specimens
          • whitepoisonous8 specimens
          • yellowpoisonous8 specimens
        • woodsgill-size?40 specimens
          • narrowpoisonous32 specimens
          • broadedible8 specimens
        • pathsedible40 specimens
      • greenpoisonous72 specimens
      • chocolateedible48 specimens
      • orangeedible48 specimens
      • yellowedible48 specimens
      • buffedible48 specimens
    • foulpoisonous2,160 specimens
    • fishypoisonous576 specimens
    • spicypoisonous576 specimens
    • almondedible400 specimens
    • aniseedible400 specimens
    • pungentpoisonous256 specimens
    • creosotepoisonous192 specimens
    • mustypoisonous36 specimens

A toy trained on 23 species of Agaricus and Lepiota from a 1981 field guide. It cannot tell you whether the mushroom in your hand is safe — please don't use it for real foraging.

Play it full screen →

Details and results are in the research report.

Let's connect

Have something hard that has to work?

Contract work, a full-time role, or a problem you want a second opinion on — I read every message and reply to the ones that aren't a template.

Email me

Usually replies within a day or two · St. Louis, Missouri

ESC

Home

Main landing page & highlights

Page

Work

All engineering projects & case studies

Page

Writing

Technical notes & engineering articles

Page

Games

Browser games, several against real models

Page

About

Background, career timeline & skills

Page

Contact

Email, inquiries & consultation

Page

Copy Email Address

davidgraymi@gmail.com

Action

Toggle Light / Dark Theme

Switch color theme

Action

Resume

Web page, with a PDF download

Read

Visit GitHub

github.com/davidgraymi

External

Visit LinkedIn

linkedin.com/in/david-gray-mi

External

Beat the bot

Tetris against the value network from my reinforcement-learning project. Same pieces, two minutes, most lines wins.

Game

Draw a digit

Draw 0–9 and watch a weighted KNN classifier find its nearest MNIST neighbours as you go.

Game

Is it poisonous?

A real mushroom from the UCI dataset. Make your call, then watch an ID3 decision tree make its own.

Game

Route the robots

Draw a warehouse, place robots and goals, and race a LaCAM multi-agent path-finding solver to the shortest plan.

Game

Daily Wordlet

One five-letter word a day, the same for everyone. Six guesses.

Game

Bot or human?

14 rounds. One line from a public-domain classic, one written by a language model. Spot the bot.

Game

Reaction test

Wait for the panel to light up amber, then hit it as fast as you can.

Game

Lost signal

The 404 page's dodge game. Packets rain down; steer the receiver out of the way.

Game

neural-cost

A framework-neutral Python library that tells you how fast a neural network should run, not just how fast it does — FLOPs, tensor traffic and a roofline model across PyTorch, JAX and TensorFlow.

Personal

Sign Language Interpretation System

Control any smart device with American Sign Language — hand tracking, a gesture classifier and grammar correction, wired together over a client-server link.

Capstone

Patient Care Portal Triage

An NLP pipeline that routes patient portal messages to the right team and surfaces relevant evidence-based research while they wait for a human.

Research

Threat modeling a zero-trust deployment pipeline

A continuous deployment pipeline for configuration-as-code and infrastructure-as-code into Kubernetes, designed from its threat model outward so the release process does the security review.

Professional

Moving three toolchain apps to Kubernetes on Azure

Three toolchain applications moved to Kubernetes on Azure, deployed one way with Helm and infrastructure-as-code, and secured with an Istio service mesh.

Professional

A processor built from the ground up

Kernel, task scheduler and communication protocol written from nothing, in C and Ada, now in production and distributed globally.

Professional

A system library that runs anywhere

One portable C++ library targeting any RTOS or bare-metal system, packaged with Docker, Bazel and GitLab CI — cutting porting work by 4×.

Professional

LaCam for Multi-Agent Path Finding

A from-scratch LaCam solver for CS440 — agents searching a space of joint configurations, each expanded by a constraint tree that rules out collisions and swaps.

School

Bindersnap

GitHub for everyone who doesn't use GitHub — document management, review lifecycle, team collaboration, search and an in-browser editor.

Personal

Wordlet

A word guessing game built in Flutter and compiled to the web — playable right here, no install, no account.

Personal

Reinforcement Learning applied to Tetris

An agent that learns to play Tetris — a genuinely fun excuse to get hands-on with reward shaping.

School

Handwritten digit recognition with weighted KNN

A KNN classifier for handwritten digits, plus a k-value optimizer that collapses repeated distance calculations into a single pass.

School

ID3 mushroom classification

A from-scratch ID3 decision tree that predicts whether a mushroom is edible or poisonous from its attributes.

School

Healthcare length-of-stay estimator

A data mining project predicting how long a patient will stay, from admission-time features.

School

This website

A static site built with Astro, hosted free on GitHub Pages, designed so writing a post costs one markdown file and nothing else.

Personal

An Unexpected Email, REPRO-SIGN, and 11 Citations on Google Scholar

Years after our college capstone, an out-of-the-blue email from European AI researchers wanting to reproduce our sign language paper sent me to Google Scholar, where we've been cited 11 times.

Post

Connecting the Dots: How a Sign Language Capstone Got Me Hooked on AI

Looking back at my senior capstone project at Missouri State — building a real-time American Sign Language smart home controller with MediaPipe, custom CNNs, and networking — and how it sparked my path in machine learning.

Post

GPU vs. CPU: Roofline Benchmarks on Apple Silicon MPS with neural-cost v0.2.0

The neural-cost v0.2.0 GPU benchmark moves from CPU roofline analysis to Apple Silicon's MPS GPU backend — measuring PyTorch and JAX across five architectures, four batch sizes, and both eager and compiled execution modes.

Post

PyTorch vs. JAX vs. TensorFlow: A Roofline Benchmark Across 5 Architectures

An empirical investigation comparing PyTorch 2.14, JAX 0.11, and TensorFlow across five model architectures and four batch sizes, measuring compiler speedups, kernel overheads, and hardware limits on Apple Silicon.

Post

neural-cost: Roofline Analysis Across PyTorch, JAX, and TensorFlow

A framework-neutral Python library that estimates a neural network's FLOPs and tensor traffic, measures its runtime, and uses a roofline model to tell you exactly where performance is being left on the table.

Post

I rebuilt this site so that publishing costs one file

The old site was a single 41,000-character index.html. Every change was archaeology. Here is what I replaced it with and why the constraint was maintenance, not design.

Post
↑ ↓ to navigate↵ to select
esc to close

Terminal