Skip to main content
Glama

Disco

在表格数据中发现新颖、经统计验证的模式 —— 包括相关性分析和 LLM 容易忽略的特征交互、子组效应和条件关系。

PyPI License: MIT

Leap Laboratories 制作。


它实际上做了什么

大多数数据分析始于一个问题。而 Disco 始于数据。

它在没有任何偏见或假设的情况下,找出能显著改变目标列的特征条件组合 —— 例如“年龄在 45-65 岁之间、HDL 低且 CRP 高的患者,其再入院率是其他人的 3 倍” —— 而无需您预先假设这种交互作用。

每个模式都具备以下特点:

  • 在留出集(hold-out set)上进行验证 —— 增加了泛化的可能性

  • FDR 校正 —— 包含 p 值,并针对多重测试进行了调整

  • 对照学术文献进行核查 —— 帮助您理解所发现的内容,并识别其是否具有创新性。

输出结构化:包含所发现的每个模式的条件、效应量、p 值、引用和新颖性分类。

适用场景: “哪些变量对于 X 最重要”、“我们是否遗漏了某些模式?”、“我不知道从这些数据的哪里开始分析”、“我需要了解 A 和 B 如何影响 C”。

不适用场景: 汇总统计、可视化、过滤、SQL 查询 —— 请使用 pandas 处理这些任务。


Related MCP server: Data Analysis MCP Server

快速入门

pip install discovery-engine-api

获取 API 密钥:

# Step 1: request verification code (no password, no card)
curl -X POST https://disco.leap-labs.com/api/signup \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'

# Step 2: submit code from email → get key
curl -X POST https://disco.leap-labs.com/api/signup/verify \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "code": "123456"}'
# → {"key": "disco_...", "credits": 10, "tier": "free_tier"}

或者在 disco.leap-labs.com/developers 创建密钥。

运行您的首次分析:

from discovery import Engine

engine = Engine(api_key="disco_...")
result = await engine.discover(
    file="data.csv",
    target_column="outcome",
)

for pattern in result.patterns:
    if pattern.p_value < 0.05 and pattern.novelty_type == "novel":
        print(f"{pattern.description} (p={pattern.p_value:.4f})")

print(f"Explore: {result.report_url}")

运行需要几分钟。discover() 会自动轮询并记录进度 —— 包括队列位置、预计等待时间、当前流水线步骤和预计完成时间。有关后台运行的信息,请参阅 异步运行

Python SDK 完整参考 · 示例笔记本


您将获得什么

result.patterns 中的每个 Pattern 看起来像这样(来自作物产量数据集的真实输出):

Pattern(
    description="When humidity is between 72–89% AND wind speed is below 12 km/h, "
                "crop yield increases by 34% above the dataset average",
    conditions=[
        {"type": "continuous", "feature": "humidity_pct",
         "min_value": 72.0, "max_value": 89.0},
        {"type": "continuous", "feature": "wind_speed_kmh",
         "min_value": 0.0, "max_value": 12.0},
    ],
    p_value=0.003,              # FDR-corrected
    novelty_type="novel",
    novelty_explanation="Published studies examine humidity and wind speed as independent "
                        "predictors, but this interaction effect — where low wind amplifies "
                        "the benefit of high humidity within a specific range — has not been "
                        "reported in the literature.",
    citations=[
        {"title": "Effects of relative humidity on cereal crop productivity",
         "authors": ["Zhang, L.", "Wang, H."], "year": "2021",
         "journal": "Journal of Agricultural Science"},
    ],
    target_change_direction="max",
    abs_target_change=0.34,     # 34% increase
    support_count=847,          # rows matching this pattern
    support_percentage=16.9,
)

需要注意的关键点:

  • 模式是条件的组合 —— 是湿度 AND 风速共同作用,而不仅仅是“湿度越高越好”

  • 具体的阈值 —— 72-89%,而不是模糊的相关性

  • 新颖 vs 验证性 —— 每个模式都经过分类;验证性模式证实了已知科学,而新颖模式正是您所追求的

  • 引用 —— 展示了已知的内容,以便您了解什么是真正的新发现

  • report_url 链接到一个交互式网页报告,其中可视化了所有模式

result.summary 提供了一个由 LLM 生成的叙述性概述:

result.summary.overview
# "Disco identified 14 statistically significant patterns. 5 are novel.
#  The strongest driver is a previously unreported interaction between humidity
#  and wind speed at specific thresholds."

result.summary.key_insights
# ["Humidity × low wind speed at 72–89% humidity produces a 34% yield increase — novel.",
#  "Soil nitrogen above 45 mg/kg shows diminishing returns when phosphorus is below 12 mg/kg.",
#  ...]

工作原理

Disco 是一个流水线,而不是对数据进行提示词工程。它:

  1. 在您的部分数据上训练机器学习模型

  2. 使用可解释性技术提取学习到的模式

  3. 使用 FDR 校正(Benjamini-Hochberg)在留出数据上验证每个模式

  4. 通过语义搜索对照学术文献检查存活的模式

您无法通过编写 pandas 代码或要求 LLM 查看 CSV 来复制此过程。它能发现假设驱动分析所忽略的结构,因为它不是从假设开始的。


准备数据

在运行之前,请排除那些会产生无意义结果的列。Disco 会发现统计学上真实的模式 —— 但如果输入包含与目标定义相关的列,则模式将是同义反复的。

排除:

  1. 标识符 —— 行 ID、UUID、患者 ID、样本代码

  2. 数据泄露 —— 重命名或重新格式化的目标(例如,当目标是 diagnosis_code 时,包含 diagnosis_text

  3. 同义反复列 —— 与目标具有相同结构的替代编码。如果目标是 serious,那么 serious_outcomenot_seriousdeath 都是同一分类的一部分。如果目标是 profit,那么 revenuecost 共同构成了它。如果目标是调查指数,则子项是同义反复的。

带有示例的完整指南:SKILL.md


参数

await engine.discover(
    file="data.csv",           # path, Path, or pd.DataFrame
    target_column="outcome",   # column to predict/explain
    analysis_depth=2,          # 2=default, higher=deeper analysis, lower = faster and cheaper
    visibility="public",       # "public" (always free, data and report is published) or "private" (costs credits)
    column_descriptions={      # improves pattern explanations and literature context
        "bmi": "Body mass index",
        "hdl": "HDL cholesterol in mg/dL",
    },
    excluded_columns=["id", "timestamp"],  # see "Preparing your data" above
    use_llms=False,                        # Defaults to False. If True, runs are slower and more expensive, but you get smarter pre-processing, summary page, literature context and novelty assessment. Public runs always use LLMs.
    title="My dataset",
    description="...", # improves pattern explanations and literature context
)

公开运行是免费的,但结果会被发布。对于私有数据,请设置 visibility="private" —— 这需要消耗积分。


异步运行

运行需要几分钟。对于智能体工作流或并行执行其他工作的脚本:

# Submit without waiting
run = await engine.run_async(file="data.csv", target_column="outcome", wait=False)
print(f"Submitted {run.run_id}, continuing...")

# ... do other things ...

result = await engine.wait_for_completion(run.run_id, timeout=1800)

对于同步脚本和 Jupyter 笔记本:

result = engine.run(file="data.csv", target_column="outcome", wait=True)
# or: pip install discovery-engine-api[jupyter] for notebook compatibility

MCP 服务器

Disco 可作为 MCP 服务器使用 —— 无需本地安装。

{
  "mcpServers": {
    "discovery-engine": {
      "url": "https://disco.leap-labs.com/mcp",
      "env": { "DISCOVERY_API_KEY": "disco_..." }
    }
  }
}

工具:discovery_list_plans, discovery_estimate, discovery_upload, discovery_analyze, discovery_status, discovery_get_results, discovery_account, discovery_signup, discovery_signup_verify, discovery_login, discovery_login_verify, discovery_add_payment_method, discovery_subscribe, discovery_purchase_credits

完整智能体技能文件


定价

费用

公开运行

免费 —— 结果和数据会被发布

私有运行

积分取决于文件大小和配置 —— 请使用 engine.estimate()

免费层级

每月 10 积分,无需信用卡

研究人员

每月 $49 —— 50 积分

团队

每月 $199 —— 200 积分

积分

每个积分 $0.10

运行前进行估算:

estimate = await engine.estimate(file_size_mb=10.5, num_columns=25, analysis_depth=2, visibility="private")
# estimate["cost"]["credits"] → 55
# estimate["account"]["sufficient"] → True/False

账户管理完全是程序化的 —— 通过 SDK 或 REST API 绑定支付方式、订阅计划和购买积分。请参阅 Python SDK 参考SKILL.md


预期数据格式

Disco 需要一个 扁平表 —— 列为特征,行为样本。

| patient_id | age | bmi  | smoker | outcome |
|------------|-----|------|--------|---------|
| 001        | 52  | 28.3 | yes    | 1       |
| 002        | 34  | 22.1 | no     | 0       |
| ...        | ... | ...  | ...    | ...     |
  • 每个观测值一行 —— 患者、样本、交易、测量值等。

  • 每个特征一列 —— 数值、分类、日期时间或自由文本均可

  • 一个目标列 —— 您想要了解的结果。必须至少有 2 个不同的值。

  • 缺失值是可以的 —— Disco 会自动处理它们。无需提前删除行或进行插补。

  • 无需透视 —— 如果您的数据已经是扁平表,则可以直接使用

支持的格式: CSV、TSV、Excel (.xlsx)、JSON、Parquet、ARFF、Feather。最大 5 GB。

不支持: 图像、原始文本文档、嵌套/分层 JSON、多工作表 Excel(请使用第一个工作表或导出为 CSV)


与其他工具的比较

目标

工具

汇总统计、数据质量

ydata-profiling, sweetviz

预测模型

AutoML (auto-sklearn, TPOT, H2O)

快速相关性

pandas, seaborn

回答关于数据的特定问题

ChatGPT, Claude

发现您不知道要寻找的内容

Disco

Disco 并不是 EDA 或 AutoML 的替代品 —— 它能发现这些工具所忽略的模式。我们在一个具有已知地面实况模式的数据集上 测试了 18 种数据分析工具。大多数工具自信地报告了错误的结果。Disco 是唯一一个找到所有模式的工具。


链接


Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leap-laboratories/discovery-engine'

If you have feedback or need assistance with the MCP directory API, please join our Discord server