An interactive 3D visualization system that maps foods into an 8-dimensional categorical space using octahedral geometry. This project implements a novel approach to food categorization based on structural, textural, and preparation properties.
Instead of traditional flat taxonomies, this system positions foods in a 3D octahedral space where:
- 8 maximally distinct food categories define the vertices and face centers
- Category scores (0-1) determine a food's position in the space
- Hybridization is visualized through entropy and positioning
- Relationships between foods become geometrically apparent
- Soup 🍲 - Liquid-dominated, spoonable
- Sandwich 🥪 - Structural integrity from bread/wrapper
- Salad 🥗 - Unbound assembly of raw/cold ingredients
- Roast 🍖 - Whole-piece dry heat cooking
- Stew 🍛 - Chunks in thick liquid, forkable
- Cutlet 🍗 - Solid, fried/breaded protein slice
- Tart 🥧 - Open-faced pastry with structured topping
- Dumpling 🥟 - Filled dough pouch, hand-held
# Clone the repository
git clone <repository-url>
cd food
# Install dependencies
pip install -r requirements.txt
# Run the Streamlit app
streamlit run streamlit_app.py- Explore the 3D Chart: Start with the sample data to see foods positioned in octahedral space
- Add New Foods: Use sliders to define category scores for any food item
- Analyze Patterns: View distribution charts and entropy analysis
- Compare Foods: Use radar charts to compare foods across all categories
- Octahedral mesh with category rays pointing to pure forms
- Food positioning based on weighted category scores
- Color coding by dominant category
- Size variation representing hybridization (entropy)
- Hover details showing complete category breakdowns
- Slider-based scoring for all 8 categories (0.0 - 1.0)
- Preset loading for category prototypes
- Real-time validation and metrics display
- Batch operations for data management
- Category distribution charts showing food spread
- Entropy analysis revealing hybridization patterns
- Food comparison using radar charts
- Summary statistics across the entire dataset
Each food item is represented as:
FoodEntry(
name="Chicken Pot Pie",
description="Chicken stew in a pastry shell",
cuisine="American",
vector=CategoryVector(
tart=0.7, # Primary: pastry shell
stew=0.6, # Secondary: chunky filling
roast=0.3, # Tertiary: baked crust
soup=0.2 # Quaternary: gravy-like
)
)- Primary (≥0.75): Dominant characteristics
- Secondary (0.25-0.74): Notable features
- Tertiary (<0.25): Minor attributes
- Total Score: Sum of all category values
- Entropy: Measure of hybridization (0-3 bits)
- Primary Category: Highest-scoring category
The octahedral coordinates create meaningful spatial relationships:
# Vertex positions (pure categories)
SOUP = (0, 0, 1) # Top vertex
SANDWICH = (1, 0, 0) # Right vertex
SALAD = (0, 1, 0) # Front vertex
ROAST = (-1, 0, 0) # Left vertex (opposite sandwich)
# Face positions (hybrid categories)
STEW = (0.5, 0.5, 0) # Between soup/salad
CUTLET = (0, -0.5, -0.5) # Opposite salad
TART = (0.5, -0.5, 0) # Between sandwich/roast
DUMPLING = (0, 0, -1) # Bottom vertex (opposite soup)| Food | Primary | Secondary | Tertiary |
|---|---|---|---|
| Lasagna | Tart (0.8) | Stew (0.6) | Roast (0.5) |
| Burrito | Sandwich (0.8) | Dumpling (0.6) | Stew (0.3) |
| Ramen | Soup (0.8) | Dumpling (0.3) | Salad (0.2) |
| Spring Roll | Dumpling (0.8) | Salad (0.6) | Sandwich (0.2) |
- 8 vertices/faces accommodate 8 distinct categories
- Opposite positioning represents antithetical concepts (soup ↔ dumpling)
- Face interpolation naturally represents hybrid forms
- 3D embedding preserves geometric relationships
- Menu organization for restaurants
- Recipe recommendation systems
- Culinary education and taxonomy
- Food science research into structural properties
- Cultural cuisine analysis and comparison
app/
├── models.py # Pydantic data models
├── geometry.py # Octahedral mesh generation
├── visualization.py # Plotly 3D charts
├── sample_data.py # Example foods dataset
└── __init__.py
streamlit_app.py # Main web interface
requirements.txt # Python dependencies
README.md # This file
- Streamlit: Web interface and interactivity
- Plotly: 3D visualization and charts
- Pydantic: Data validation and modeling
- NumPy: Geometric calculations
- Pandas: Data manipulation
This is an experimental framework for food categorization. Contributions welcome for:
- Category refinement: Should "tart" include quiches?
- Geometric validation: Testing octahedral mapping accuracy
- Dataset expansion: More diverse food examples
- UI improvements: Better input workflows
- Analysis features: New visualization types
- Machine learning: Auto-scoring from ingredient lists
- Cultural mapping: Regional cuisine clustering analysis
- Temporal analysis: How recipes evolve in the space
- Multi-language: International food name support
- API integration: Restaurant menu analysis
- Export tools: Data sharing and collaboration features
Open source - feel free to experiment, extend, and adapt!
"All food exists somewhere in the octahedron. The question is: where?"