{ "nbformat": 4, "nbformat_minor": 5, "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12.0" } }, "cells": [ { "cell_type": "markdown", "id": "cell-01", "metadata": {}, "source": "# USDA Phytochemical & Ethnobotanical Database — Enriched v2.0\n\n**104,388 records · 24,771 compounds · 2,315 species · 4 enrichment layers**\n\n| Tier | Price | Includes |\n|------|-------|----------|\n| **Single Entity** | [€699](https://buy.stripe.com/00w6oGgFh58v6Toeqsebu02) | JSON + Parquet + SHA-256 Manifest |\n| **Team** | [€1.349](https://buy.stripe.com/dRm7sK9cP1Wj0v06Y0ebu03) | + `duckdb_queries.sql` (20 queries) + `compound_priority_score.py` + 4 Pre-computed Views |\n| **Enterprise** | [€1.699](https://buy.stripe.com/dRm28q0Gj1WjdhM6Y0ebu04) | + `snowflake_load.sql` + `chromadb_ingest.py` + `pinecone_ingest.py` + `embedding_guide.md` + Opportunity Matrix |\n\n**Full dataset:** [ethno-api.com](https://ethno-api.com) · **This notebook runs on the free 400-row sample.**\n" }, { "cell_type": "code", "id": "cell-02", "metadata": {}, "outputs": [], "execution_count": null, "source": [ "import pandas as pd\n", "import duckdb\n", "\n", "# Load the free 400-row sample\n", "# To use full dataset: replace path with 'ethno_dataset_2026_v2.json'\n", "SAMPLE = 'ethno_sample_400.json'\n", "\n", "df = pd.read_json(SAMPLE)\n", "print(f'Shape: {df.shape}')\n", "print(f'Columns: {list(df.columns)}')\n", "df.head(3)" ] }, { "cell_type": "code", "id": "cell-03", "metadata": {}, "outputs": [], "execution_count": null, "source": [ "# Dataset statistics\n", "print(f'Unique compounds: {df[\"chemical\"].nunique():,}')\n", "print(f'Unique species: {df[\"plant_species\"].nunique():,}')\n", "print(f'Application coverage: {df[\"application\"].notna().mean()*100:.1f}%')\n", "print(f'Dosage coverage: {df[\"dosage\"].notna().mean()*100:.1f}%')\n", "print(f'\\nTop compound by PubMed evidence:')\n", "print(df.groupby(\"chemical\")[\"pubmed_mentions_2026\"].max().sort_values(ascending=False).head(5).to_string())" ] }, { "cell_type": "code", "id": "cell-04", "metadata": {}, "outputs": [], "execution_count": null, "source": [ "# Q05: Composite evidence score (weighted: PubMed 30% | Trials 35% | ChEMBL 20% | Patents 15%)\n", "# Source: duckdb_queries.sql — available in Team + Enterprise tier\n", "result = duckdb.sql(f\"\"\"\n", " SELECT\n", " chemical,\n", " MAX(pubmed_mentions_2026) AS pubmed,\n", " MAX(clinical_trials_count_2026) AS trials,\n", " MAX(chembl_bioactivity_count) AS bioassays,\n", " MAX(patent_count_since_2020) AS patents,\n", " ROUND(\n", " (MAX(pubmed_mentions_2026) * 0.30) +\n", " (MAX(clinical_trials_count_2026) * 0.35) +\n", " (MAX(chembl_bioactivity_count) * 0.20) +\n", " (MAX(patent_count_since_2020) * 0.15),\n", " 2) AS composite_score\n", " FROM read_json_auto('{SAMPLE}')\n", " GROUP BY chemical\n", " ORDER BY composite_score DESC\n", " LIMIT 10\n", "\"\"\").df()\n", "print('Top 10 by composite evidence score:')\n", "result" ] }, { "cell_type": "code", "id": "cell-05", "metadata": {}, "outputs": [], "execution_count": null, "source": [ "# Q17: IP whitespace candidates — high research signal, low patent activity\n", "# Use case: freedom-to-operate screening\n", "# Source: duckdb_queries.sql (Team + Enterprise tier)\n", "whitespace = duckdb.sql(f\"\"\"\n", " SELECT\n", " chemical,\n", " MAX(pubmed_mentions_2026) AS pubmed,\n", " MAX(patent_count_since_2020) AS patents_since_2020,\n", " ROUND(MAX(pubmed_mentions_2026)::DOUBLE / NULLIF(MAX(patent_count_since_2020),0), 1)\n", " AS research_to_patent_ratio\n", " FROM read_json_auto('{SAMPLE}')\n", " GROUP BY chemical\n", " HAVING MAX(pubmed_mentions_2026) > 50 AND MAX(patent_count_since_2020) < 5\n", " ORDER BY research_to_patent_ratio DESC\n", " LIMIT 10\n", "\"\"\").df()\n", "print('IP Whitespace Candidates (high research, low patents):')\n", "whitespace" ] }, { "cell_type": "code", "id": "cell-06", "metadata": {}, "outputs": [], "execution_count": null, "source": [ "# Q06: Evidence tier classification (PLATINUM / GOLD / SILVER / BRONZE)\n", "# Source: duckdb_queries.sql (Team + Enterprise tier)\n", "tiers = duckdb.sql(f\"\"\"\n", " SELECT evidence_tier, COUNT(*) AS compound_count\n", " FROM (\n", " SELECT chemical,\n", " CASE\n", " WHEN MAX(pubmed_mentions_2026)>5000 AND MAX(clinical_trials_count_2026)>100 THEN 'PLATINUM'\n", " WHEN MAX(pubmed_mentions_2026)>1000 AND MAX(clinical_trials_count_2026)>20 THEN 'GOLD'\n", " WHEN MAX(pubmed_mentions_2026)>100 THEN 'SILVER'\n", " ELSE 'BRONZE'\n", " END AS evidence_tier\n", " FROM read_json_auto('{SAMPLE}')\n", " GROUP BY chemical\n", " ) sub\n", " GROUP BY evidence_tier\n", " ORDER BY evidence_tier\n", "\"\"\").df()\n", "print('Evidence tier distribution:')\n", "tiers" ] }, { "cell_type": "markdown", "id": "cell-07", "metadata": {}, "source": "## What's Included in Each Tier\n\n### Team License (€1.349) — adds to Single:\n| File | Description |\n|------|-------------|\n| `duckdb_queries.sql` | 20 production-ready queries across 5 categories (compound discovery, evidence scoring, species analysis, application intelligence, IP/pipeline) |\n| `compound_priority_score.py` | Combined evidence score calculator across all 4 layers |\n| `top500_by_pubmed.parquet` | Pre-computed Top 500 compounds by PubMed score |\n| `top500_by_trials.parquet` | Pre-computed Top 500 by ClinicalTrials count |\n| `top500_by_patent_density.parquet` | Pre-computed Top 500 by patent density |\n| `anti_inflammatory_panel.parquet` | All anti-inflammatory application records |\n\n### Enterprise License (€1.699) — adds to Team:\n| File | Description |\n|------|-------------|\n| `snowflake_load.sql` | Drop-in Snowflake import script (Stage + COPY INTO + Verify) |\n| `chromadb_ingest.py` | ChromaDB vector ingest with batch upload, --resume, verification |\n| `pinecone_ingest.py` | Pinecone ingest supporting OpenAI, sentence-transformers, Pinecone inference |\n| `embedding_guide.md` | ClinicalBERT, RAG pipeline templates, cost benchmarks |\n| `compound_opportunity_matrix.csv` | Ranked compound candidates: high bioactivity × low patent density |\n| `clinical_pipeline_gaps.csv` | High-PubMed, low-trial compounds: drug discovery pipeline gaps |\n| `ethno_rag_chunks.jsonl` | Pre-chunked JSONL for direct LLM embedding (ChromaDB / Pinecone) |\n\n---\n\n**→ Purchase the full dataset:**\n\n[**Single Entity €699 →**](https://buy.stripe.com/00w6oGgFh58v6Toeqsebu02)   [**Team €1.349 →**](https://buy.stripe.com/dRm7sK9cP1Wj0v06Y0ebu03)   [**Enterprise €1.699 →**](https://buy.stripe.com/dRm28q0Gj1WjdhM6Y0ebu04)\n" }, { "cell_type": "code", "id": "cell-08", "metadata": {}, "outputs": [], "execution_count": null, "source": [ "# Load via HuggingFace Datasets\n", "# from datasets import load_dataset\n", "# ds = load_dataset(\n", "# 'wirthal1990-tech/USDA-Phytochemical-Database-JSON',\n", "# split='sample',\n", "# trust_remote_code=False\n", "# )\n", "# df_hf = ds.to_pandas()\n", "# print(f'Records: {len(df_hf)} | Columns: {list(df_hf.columns)}')\n", "print('HuggingFace repo: https://huggingface.co/datasets/wirthal1990-tech/USDA-Phytochemical-Database-JSON')" ] }, { "cell_type": "markdown", "id": "cell-09", "metadata": {}, "source": "## Citation\n\n```bibtex\n@misc{ethno_api_v2_2026,\n title = {USDA Phytochemical \\& Ethnobotanical Database --- Enriched v2.0},\n author = {Wirth, Alexander},\n year = {2026},\n publisher = {Ethno-API},\n url = {https://ethno-api.com},\n note = {104,388 records, 24,771 unique chemicals, 2,315 plant species,\n 8-column schema with PubMed, ClinicalTrials, ChEMBL, and PatentsView enrichment}\n}\n```\n\n**Links:** [ethno-api.com](https://ethno-api.com) · [GitHub](https://github.com/wirthal1990-tech/USDA-Phytochemical-Database-JSON) · [HuggingFace](https://huggingface.co/datasets/wirthal1990-tech/USDA-Phytochemical-Database-JSON)\n\n\n---\n\n## Purchase Full Dataset\n\n| Tier | Price | |\n|------|-------|---|\n| Single Entity | €699 | [**Buy →**](https://buy.stripe.com/00w6oGgFh58v6Toeqsebu02) |\n| Team | €1.349 | [**Buy →**](https://buy.stripe.com/dRm7sK9cP1Wj0v06Y0ebu03) |\n| Enterprise | €1.699 | [**Buy →**](https://buy.stripe.com/dRm28q0Gj1WjdhM6Y0ebu04) |\n\n> Gemäß § 19 UStG keine Umsatzsteuer.\n" } ] }