Add combined multi-tab sample explorer (RoasterDB / FloraDB / SuppDB)
Browse files- README.md +14 -6
- app.py +216 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -1,13 +1,21 @@
|
|
| 1 |
---
|
| 2 |
title: Dataset Sample Explorers
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Dataset Sample Explorers
|
| 3 |
+
emoji: ποΈ
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.9.0
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: cc-by-nc-4.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# ποΈ Dataset Sample Explorers
|
| 14 |
+
|
| 15 |
+
One interactive explorer for the **free samples** of three curated commercial datasets:
|
| 16 |
+
|
| 17 |
+
* **β [RoasterDB](https://specialty-coffee-roasterdb.pages.dev)** β specialty coffee mapped to the SCA Flavor Wheel ([sample dataset](https://huggingface.co/datasets/Ichlibitiche/roasterdb-specialty-coffee-sample))
|
| 18 |
+
* **πΏ [FloraDB](https://houseplants-botanical-floradb.pages.dev)** β quantitative houseplant care + ASPCA pet toxicity ([sample dataset](https://huggingface.co/datasets/Ichlibitiche/floradb-houseplants-care-sample))
|
| 19 |
+
* **π [SuppDB](https://supplements-nootropics-suppdb.pages.dev)** β NIH DSLD supplement labels with mg-normalized doses + PubChem chemistry ([sample dataset](https://huggingface.co/datasets/Ichlibitiche/suppdb-supplements-sample))
|
| 20 |
+
|
| 21 |
+
Every record carries a source URL for re-verification. Full datas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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# ββ Load the three free samples from their public Hugging Face datasets ββ
|
| 5 |
+
ROASTER_URL = "hf://datasets/Ichlibitiche/roasterdb-specialty-coffee-sample/roasterdb_sample.csv"
|
| 6 |
+
FLORA_URL = "hf://datasets/Ichlibitiche/floradb-houseplants-care-sample/floradb_sample.csv"
|
| 7 |
+
SUPP_URL = "hf://datasets/Ichlibitiche/suppdb-supplements-sample/suppdb_sample.csv"
|
| 8 |
+
|
| 9 |
+
r_df = pd.read_csv(ROASTER_URL)
|
| 10 |
+
f_df = pd.read_csv(FLORA_URL)
|
| 11 |
+
s_df = pd.read_csv(SUPP_URL)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def choices(df, col):
|
| 15 |
+
vals = df[col].dropna().astype(str)
|
| 16 |
+
return ["All"] + sorted(v for v in vals.unique() if v.strip() and v != "Unknown")
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# ββ RoasterDB ββ
|
| 20 |
+
R_COLS = {
|
| 21 |
+
"source_roaster": "Roaster",
|
| 22 |
+
"title": "Coffee",
|
| 23 |
+
"origin_country": "Origin",
|
| 24 |
+
"process_method": "Process",
|
| 25 |
+
"roast_level": "Roast",
|
| 26 |
+
"weight_grams": "Weight (g)",
|
| 27 |
+
"price_value": "Price (USD)",
|
| 28 |
+
"tasting_notes_sca_nodes": "SCA Flavor Notes",
|
| 29 |
+
"source_url": "Source URL",
|
| 30 |
+
}
|
| 31 |
+
R_PRICE_MAX = float(r_df["price_value"].max())
|
| 32 |
+
|
| 33 |
+
def r_explore(roaster, country, process, roast, flavor, max_price):
|
| 34 |
+
d = r_df
|
| 35 |
+
if roaster != "All":
|
| 36 |
+
d = d[d["source_roaster"] == roaster]
|
| 37 |
+
if country != "All":
|
| 38 |
+
d = d[d["origin_country"] == country]
|
| 39 |
+
if process != "All":
|
| 40 |
+
d = d[d["process_method"] == process]
|
| 41 |
+
if roast != "All":
|
| 42 |
+
d = d[d["roast_level"] == roast]
|
| 43 |
+
if flavor and flavor.strip():
|
| 44 |
+
d = d[d["tasting_notes_sca_nodes"].fillna("").str.contains(flavor.strip(), case=False, regex=False)]
|
| 45 |
+
if max_price < R_PRICE_MAX:
|
| 46 |
+
d = d[d["price_value"].fillna(R_PRICE_MAX + 1) <= max_price]
|
| 47 |
+
summary = (
|
| 48 |
+
f"**{len(d)} coffees** from **{d['source_roaster'].nunique()} roasters** match β "
|
| 49 |
+
f"out of {len(r_df)} in the free sample. The full RoasterDB has **8,000+ products from 280+ roasters**."
|
| 50 |
+
)
|
| 51 |
+
return summary, d[list(R_COLS)].rename(columns=R_COLS).sort_values("Price (USD)")
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
# ββ FloraDB ββ
|
| 55 |
+
F_COLS = {
|
| 56 |
+
"common_name": "Common Name",
|
| 57 |
+
"scientific_name": "Scientific Name",
|
| 58 |
+
"family": "Family",
|
| 59 |
+
"light_requirement_level": "Light",
|
| 60 |
+
"min_lux": "Min Lux",
|
| 61 |
+
"max_lux": "Max Lux",
|
| 62 |
+
"watering_frequency_days": "Water Every (days)",
|
| 63 |
+
"min_temp_celsius": "Min Β°C",
|
| 64 |
+
"max_temp_celsius": "Max Β°C",
|
| 65 |
+
"is_toxic_to_dogs": "Toxic: Dogs",
|
| 66 |
+
"is_toxic_to_cats": "Toxic: Cats",
|
| 67 |
+
"toxicity_status": "Toxicity Source",
|
| 68 |
+
"care_confidence": "Care Confidence",
|
| 69 |
+
"gbif_source_url": "GBIF Source",
|
| 70 |
+
}
|
| 71 |
+
F_PET_FILTERS = [
|
| 72 |
+
"All",
|
| 73 |
+
"Verified safe for dogs",
|
| 74 |
+
"Verified safe for cats",
|
| 75 |
+
"Toxic to dogs or cats",
|
| 76 |
+
"Toxicity unknown",
|
| 77 |
+
]
|
| 78 |
+
|
| 79 |
+
def f_explore(name_query, family, light, confidence, pet_filter):
|
| 80 |
+
d = f_df
|
| 81 |
+
if name_query and name_query.strip():
|
| 82 |
+
q = name_query.strip()
|
| 83 |
+
hit = (
|
| 84 |
+
d["common_name"].fillna("").str.contains(q, case=False, regex=False)
|
| 85 |
+
| d["scientific_name"].fillna("").str.contains(q, case=False, regex=False)
|
| 86 |
+
)
|
| 87 |
+
d = d[hit]
|
| 88 |
+
if family != "All":
|
| 89 |
+
d = d[d["family"] == family]
|
| 90 |
+
if light != "All":
|
| 91 |
+
d = d[d["light_requirement_level"] == light]
|
| 92 |
+
if confidence != "All":
|
| 93 |
+
d = d[d["care_confidence"] == confidence]
|
| 94 |
+
# Safety filters are conservative: "safe" requires a determined status, never unknown
|
| 95 |
+
if pet_filter == "Verified safe for dogs":
|
| 96 |
+
d = d[(d["is_toxic_to_dogs"] == 0) & (d["toxicity_status"] != "unknown")]
|
| 97 |
+
elif pet_filter == "Verified safe for cats":
|
| 98 |
+
d = d[(d["is_toxic_to_cats"] == 0) & (d["toxicity_status"] != "unknown")]
|
| 99 |
+
elif pet_filter == "Toxic to dogs or cats":
|
| 100 |
+
d = d[(d["is_toxic_to_dogs"] == 1) | (d["is_toxic_to_cats"] == 1)]
|
| 101 |
+
elif pet_filter == "Toxicity unknown":
|
| 102 |
+
d = d[d["toxicity_status"] == "unknown"]
|
| 103 |
+
summary = (
|
| 104 |
+
f"**{len(d)} plants** across **{d['family'].nunique()} families** match β "
|
| 105 |
+
f"out of {len(f_df)} in the free sample. "
|
| 106 |
+
f"The full FloraDB has **270 care plants + 891 ASPCA toxicity records + a 20,000+ species GBIF index**."
|
| 107 |
+
)
|
| 108 |
+
return summary, d[list(F_COLS)].rename(columns=F_COLS)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
# ββ SuppDB ββ
|
| 112 |
+
S_COLS = {
|
| 113 |
+
"brand": "Brand",
|
| 114 |
+
"product_name": "Product",
|
| 115 |
+
"form_type": "Form",
|
| 116 |
+
"ingredient": "Ingredient",
|
| 117 |
+
"ingredient_form": "Ingredient Form",
|
| 118 |
+
"ingredient_category": "Category",
|
| 119 |
+
"amount_per_serving_mg": "Dose (mg/serving)",
|
| 120 |
+
"is_proprietary_blend": "Hidden in Blend",
|
| 121 |
+
"recommended_daily_mg": "NIH RDA (mg)",
|
| 122 |
+
"upper_safety_limit_mg": "Upper Limit (mg)",
|
| 123 |
+
"molecular_formula": "Formula",
|
| 124 |
+
"source_url": "NIH DSLD Label",
|
| 125 |
+
}
|
| 126 |
+
S_BLEND_FILTERS = [
|
| 127 |
+
"All",
|
| 128 |
+
"Disclosed doses only",
|
| 129 |
+
"Proprietary-blend (hidden dose) only",
|
| 130 |
+
]
|
| 131 |
+
|
| 132 |
+
def s_explore(ingredient_query, brand, category, form, blend_filter):
|
| 133 |
+
d = s_df
|
| 134 |
+
if ingredient_query and ingredient_query.strip():
|
| 135 |
+
q = ingredient_query.strip()
|
| 136 |
+
hit = (
|
| 137 |
+
d["ingredient"].fillna("").str.contains(q, case=False, regex=False)
|
| 138 |
+
| d["product_name"].fillna("").str.contains(q, case=False, regex=False)
|
| 139 |
+
)
|
| 140 |
+
d = d[hit]
|
| 141 |
+
if brand != "All":
|
| 142 |
+
d = d[d["brand"] == brand]
|
| 143 |
+
if category != "All":
|
| 144 |
+
d = d[d["ingredient_category"] == category]
|
| 145 |
+
if form != "All":
|
| 146 |
+
d = d[d["form_type"] == form]
|
| 147 |
+
if blend_filter == "Disclosed doses only":
|
| 148 |
+
d = d[d["is_proprietary_blend"] == 0]
|
| 149 |
+
elif blend_filter == "Proprietary-blend (hidden dose) only":
|
| 150 |
+
d = d[d["is_proprietary_blend"] == 1]
|
| 151 |
+
summary = (
|
| 152 |
+
f"**{len(d)} ingredient records** across **{d['product_id'].nunique()} products** "
|
| 153 |
+
f"from **{d['brand'].nunique()} brands** match β out of {len(s_df)} records in the free sample. "
|
| 154 |
+
f"The full SuppDB has **115,000+ ingredient records across 17,000+ products**."
|
| 155 |
+
)
|
| 156 |
+
return summary, d[list(S_COLS)].rename(columns=S_COLS)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
# ββ UI ββ
|
| 160 |
+
with gr.Blocks(title="Dataset Sample Explorers") as demo:
|
| 161 |
+
gr.Markdown("# ποΈ Dataset Sample Explorers")
|
| 162 |
+
gr.Markdown("""Interactive explorers for the **free samples** of three curated commercial datasets. Every record carries a source URL so any fact can be re-verified. Full datasets are available at each official portal.""")
|
| 163 |
+
|
| 164 |
+
with gr.Tab("β RoasterDB β Specialty Coffee"):
|
| 165 |
+
gr.Markdown(f"""**{len(r_df)} verified coffees from {r_df['source_roaster'].nunique()} artisan roasters**, tasting notes normalized to the **SCA Flavor Wheel**. Full dataset: **8,000+ products, 280+ roasters** β [roasterdb.net](https://specialty-coffee-roasterdb.pages.dev) Β· [π€ sample dataset](https://huggingface.co/datasets/Ichlibitiche/roasterdb-specialty-coffee-sample) Β· [π Kaggle](https://www.kaggle.com/datasets/ahtiticheamine/roasterdb-specialty-coffee-sample) Β· [π Apify scraper](https://apify.com/dataengineered/specialty-coffee-roaster-scraper)""")
|
| 166 |
+
with gr.Row():
|
| 167 |
+
r_roaster = gr.Dropdown(choices=choices(r_df, "source_roaster"), value="All", label="Roaster")
|
| 168 |
+
r_country = gr.Dropdown(choices=choices(r_df, "origin_country"), value="All", label="Origin Country")
|
| 169 |
+
r_process = gr.Dropdown(choices=choices(r_df, "process_method"), value="All", label="Process Method")
|
| 170 |
+
r_roast = gr.Dropdown(choices=choices(r_df, "roast_level"), value="All", label="Roast Level")
|
| 171 |
+
with gr.Row():
|
| 172 |
+
r_flavor = gr.Textbox(label="SCA Flavor Search", placeholder="e.g. Berry, Chocolate, Floral, Peach...")
|
| 173 |
+
r_price = gr.Slider(minimum=0, maximum=R_PRICE_MAX, value=R_PRICE_MAX, step=1, label="Max Price (USD)")
|
| 174 |
+
r_btn = gr.Button("Explore Coffees", variant="primary")
|
| 175 |
+
r_text = gr.Markdown()
|
| 176 |
+
r_table = gr.Dataframe(label="Matching Coffees", wrap=True)
|
| 177 |
+
r_inputs = [r_roaster, r_country, r_process, r_roast, r_flavor, r_price]
|
| 178 |
+
r_btn.click(fn=r_explore, inputs=r_inputs, outputs=[r_text, r_table])
|
| 179 |
+
demo.load(fn=r_explore, inputs=r_inputs, outputs=[r_text, r_table])
|
| 180 |
+
|
| 181 |
+
with gr.Tab("πΏ FloraDB β Houseplants & Pet Toxicity"):
|
| 182 |
+
gr.Markdown(f"""**{len(f_df)} houseplants from {f_df['family'].nunique()} botanical families** β care as **quantitative metrics** (Lux, watering days, Β°C) with **ASPCA pet toxicity** on GBIF-verified names. Full dataset: **270 care plants + 891 toxicity records + 20,000+ species index** β [floradb](https://houseplants-botanical-floradb.pages.dev) Β· [π€ sample dataset](https://huggingface.co/datasets/Ichlibitiche/floradb-houseplants-care-sample) Β· [π Kaggle](https://www.kaggle.com/datasets/ahtiticheamine/floradb-houseplants-care-sample) Β· [π Apify lookup](https://apify.com/dataengineered/houseplant-care-toxicity-lookup)""")
|
| 183 |
+
with gr.Row():
|
| 184 |
+
f_name = gr.Textbox(label="Plant Search", placeholder="e.g. Monstera, Pothos, Ficus...")
|
| 185 |
+
f_family = gr.Dropdown(choices=choices(f_df, "family"), value="All", label="Botanical Family")
|
| 186 |
+
f_light = gr.Dropdown(choices=choices(f_df, "light_requirement_level"), value="All", label="Light Requirement")
|
| 187 |
+
with gr.Row():
|
| 188 |
+
f_conf = gr.Dropdown(choices=choices(f_df, "care_confidence"), value="All", label="Care Confidence")
|
| 189 |
+
f_pet = gr.Dropdown(choices=F_PET_FILTERS, value="All", label="Pet Safety (ASPCA-based, conservative)")
|
| 190 |
+
f_btn = gr.Button("Explore Plants", variant="primary")
|
| 191 |
+
f_text = gr.Markdown()
|
| 192 |
+
f_table = gr.Dataframe(label="Matching Plants", wrap=True)
|
| 193 |
+
f_inputs = [f_name, f_family, f_light, f_conf, f_pet]
|
| 194 |
+
f_btn.click(fn=f_explore, inputs=f_inputs, outputs=[f_text, f_table])
|
| 195 |
+
demo.load(fn=f_explore, inputs=f_inputs, outputs=[f_text, f_table])
|
| 196 |
+
|
| 197 |
+
with gr.Tab("π SuppDB β Supplements & Nootropics"):
|
| 198 |
+
gr.Markdown(f"""**{len(s_df)} active-ingredient records from {s_df['product_id'].nunique()} real supplement products ({s_df['brand'].nunique()} brands)** β NIH DSLD labels with **mg-normalized doses**, **proprietary-blend transparency**, and **PubChem chemistry**. Full dataset: **17,000+ products, 115,000+ ingredient records** β [suppdb.net](https://supplements-nootropics-suppdb.pages.dev) Β· [π€ sample dataset](https://huggingface.co/datasets/Ichlibitiche/suppdb-supplements-sample) Β· [π Kaggle](https://www.kaggle.com/datasets/ahtiticheamine/suppdb-supplements-sample)""")
|
| 199 |
+
with gr.Row():
|
| 200 |
+
s_query = gr.Textbox(label="Ingredient / Product Search", placeholder="e.g. Magnesium, Ashwagandha, Vitamin D...")
|
| 201 |
+
s_brand = gr.Dropdown(choices=choices(s_df, "brand"), value="All", label="Brand")
|
| 202 |
+
with gr.Row():
|
| 203 |
+
s_category = gr.Dropdown(choices=choices(s_df, "ingredient_category"), value="All", label="Ingredient Category")
|
| 204 |
+
s_form = gr.Dropdown(choices=choices(s_df, "form_type"), value="All", label="Product Form")
|
| 205 |
+
s_blend = gr.Dropdown(choices=S_BLEND_FILTERS, value="All", label="Proprietary-Blend Transparency")
|
| 206 |
+
s_btn = gr.Button("Explore Supplements", variant="primary")
|
| 207 |
+
s_text = gr.Markdown()
|
| 208 |
+
s_table = gr.Dataframe(label="Matching Ingredient Records", wrap=True)
|
| 209 |
+
s_inputs = [s_query, s_brand, s_category, s_form, s_blend]
|
| 210 |
+
s_btn.click(fn=s_explore, inputs=s_inputs, outputs=[s_text, s_table])
|
| 211 |
+
demo.load(fn=s_explore, inputs=s_inputs, outputs=[s_text, s_table])
|
| 212 |
+
|
| 213 |
+
gr.Markdown("""---
|
| 214 |
+
*Sample data CC BY-NC 4.0 (per-dataset attribution on each tab). FloraDB toxicity data is informational, not veterinary advice; SuppDB is factual label data, not medical advice. Full datasets commercially licensed at each portal. Sister project: [π¬ INCIDB Skincare Dupe Finder](https://huggingface.co/spaces/Ichlibitiche/incidb-skincare-dupe-finder).*""")
|
| 215 |
+
|
| 216 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas
|
| 2 |
+
huggingface_hub
|