{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Phase 3 — Product Domain + Taxonomy + Product Grouping\n", "## Compliments Reference DB Pipeline\n", "\n", "**Version:** 1.1.0\n", "**Date:** 2026-07-30\n", "\n", "**Input:** Phase 2 output (`phase2_output.parquet`)\n", "\n", "**This phase does:**\n", "A. Food / Non-Food classification (product_domain)\n", "B. Taxonomy classification (metadata — temporary deterministic taxonomy)\n", "C. Identity-based deterministic product grouping\n", "D. Ambiguous-case detection\n", "E. Validation and regression tests\n", "\n", "**Note:** Taxonomy is a temporary rule-based classification layer.\n", "It is NOT GPC, NOT Agribalyse, NOT an official external taxonomy." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2026-07-30T17:08:38.184497Z", "iopub.status.busy": "2026-07-30T17:08:38.181586Z", "iopub.status.idle": "2026-07-30T17:08:39.157905Z", "shell.execute_reply": "2026-07-30T17:08:39.154706Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python: 3.13.7 (main, Mar 3 2026, 12:19:54) [GCC 15.2.0]\n", "pandas: 3.0.5\n", "numpy: 2.5.1\n", "Timestamp: 2026-07-30T17:08:39.147086+00:00\n" ] } ], "source": [ "import json, os, sys, re, uuid\n", "from datetime import datetime, timezone\n", "from pathlib import Path\n", "from collections import Counter\n", "\n", "import pandas as pd\n", "import numpy as np\n", "\n", "print(f\"Python: {sys.version}\")\n", "print(f\"pandas: {pd.__version__}\")\n", "print(f\"numpy: {np.__version__}\")\n", "print(f\"Timestamp: {datetime.now(timezone.utc).isoformat()}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Load Phase 2 Output" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2026-07-30T17:08:39.356596Z", "iopub.status.busy": "2026-07-30T17:08:39.355863Z", "iopub.status.idle": "2026-07-30T17:08:39.545028Z", "shell.execute_reply": "2026-07-30T17:08:39.542833Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Loaded: 4440 rows, 38 columns\n", "\n", "Columns: ['upc', 'external_id', 'brand', 'title', 'price', 'price_currency', 'size', 'size_amount', 'size_unit', 'size_qty', 'size_unit_norm', 'image_url', 'source', 'source_url', 'brand_clean', 'brand_raw', 'title_clean', 'title_raw', 'upc_raw', 'external_id_raw', 'is_organic', 'is_gluten_free', 'is_naturally_simple', 'is_sugar_free', 'is_unsalted', 'is_lactose_free', 'is_peanut_free', 'is_plant_based', 'is_reduced_sodium', 'fat_level', 'fat_percentage', 'flavour', 'formulation', 'brand_norm', 'product_line', 'variant_attributes', 'core_title', 'identity_hash']\n" ] }, { "data": { "text/html": [ "
| \n", " | upc | \n", "external_id | \n", "brand | \n", "title | \n", "price | \n", "price_currency | \n", "size | \n", "size_amount | \n", "size_unit | \n", "size_qty | \n", "... | \n", "is_reduced_sodium | \n", "fat_level | \n", "fat_percentage | \n", "flavour | \n", "formulation | \n", "brand_norm | \n", "product_line | \n", "variant_attributes | \n", "core_title | \n", "identity_hash | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "055742522167 | \n", "297608EA | \n", "Compliments | \n", "Compliments Cold And Sinus Plus 20 Count | \n", "9.99 | \n", "CAD | \n", "20 per pack | \n", "20.000 | \n", "count | \n", "1 | \n", "... | \n", "False | \n", "regular | \n", "NaN | \n", "[lime] | \n", "[] | \n", "Compliments | \n", "Core | \n", "{\"count\": 20} | \n", "Cold And Sinus Plus | \n", "0|0|0|0|0|0|0|0|0|fat_none|regular|Core|lime| | \n", "
| 1 | \n", "055742335200 | \n", "464324EA | \n", "Compliments | \n", "Compliments Twister T2 Light Bulbs 23W Soft Wh... | \n", "11.99 | \n", "CAD | \n", "2 per pack | \n", "2.000 | \n", "count | \n", "1 | \n", "... | \n", "False | \n", "reduced_fat | \n", "NaN | \n", "[lime] | \n", "[] | \n", "Compliments | \n", "Core | \n", "{\"count\": 2} | \n", "Twister T2 Light Bulbs 23W Soft White | \n", "0|0|0|0|0|0|0|0|0|fat_none|reduced_fat|Core|lime| | \n", "
| 2 | \n", "990002600400 | \n", "144288CS | \n", "Compliments | \n", "Compliments Zero Calorie Soft Drink 12 x 355ml | \n", "5.49 | \n", "CAD | \n", "12 x 29.583ml | \n", "29.583 | \n", "ml | \n", "12 | \n", "... | \n", "False | \n", "regular | \n", "NaN | \n", "[lime] | \n", "[] | \n", "Compliments | \n", "Core | \n", "{\"qty\": 12, \"amount\": 29.583, \"unit\": \"ml\"} | \n", "Zero Calorie Soft Drink | \n", "0|0|0|0|0|0|0|0|0|fat_none|regular|Core|lime| | \n", "
| 3 | \n", "055742569391 | \n", "312204EA | \n", "Compliments | \n", "Compliments Kalamata Whole Olives 375 ml | \n", "3.29 | \n", "CAD | \n", "375ml | \n", "375.000 | \n", "ml | \n", "1 | \n", "... | \n", "False | \n", "regular | \n", "NaN | \n", "[lime] | \n", "[whole] | \n", "Compliments | \n", "Core | \n", "{\"amount\": 375.0, \"unit\": \"ml\"} | \n", "Kalamata Whole Olives | \n", "0|0|0|0|0|0|0|0|0|fat_none|regular|Core|lime|w... | \n", "
| 4 | \n", "055742561111 | \n", "259928EA | \n", "Compliments | \n", "Compliments Sliced Almonds 250 g | \n", "7.99 | \n", "CAD | \n", "250g | \n", "250.000 | \n", "g | \n", "1 | \n", "... | \n", "False | \n", "regular | \n", "NaN | \n", "[almond, lime] | \n", "[sliced] | \n", "Compliments | \n", "Core | \n", "{\"amount\": 250.0, \"unit\": \"g\"} | \n", "Sliced Almonds | \n", "0|0|0|0|0|0|0|0|0|fat_none|regular|Core|almond... | \n", "
5 rows × 38 columns
\n", "