Skip to main content
Glama

Disco

在表格数据中发现新颖、经统计验证的模式 —— 包括人类和智能体容易错过的特征交互、子组效应和条件关系。

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: Discovery Engine 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_outcome、not_serious、death 都是同一分类的一部分。如果目标是 profit,那么 revenue 和 cost 合在一起就构成了它。如果目标是调查指数,子项就是同义反复的。

包含示例的完整指南: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 是唯一一个找到所有模式的工具。


链接


Available Tools

14 tools
discovery_accountA
Read-only
Inspect

Check your Disco account status.

Returns current plan, available credits (subscription + purchased), and
payment method status. Use this to verify you have sufficient credits
before running a private analysis.

Args:
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: api_key. Returns: result

discovery_add_payment_methodA
Idempotent
Inspect

Attach a Stripe payment method to your Disco account.

The payment method must be tokenized via Stripe's API first — card details
never touch Disco's servers. Required before purchasing credits
or subscribing to a paid plan.

To tokenize a card, call Stripe's API directly:
POST https://api.stripe.com/v1/payment_methods
with the stripe_publishable_key from your account info.

Args:
    payment_method_id: Stripe payment method ID (pm_...) from Stripe's API.
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: payment_method_id (required), api_key. Returns: result

discovery_analyzeA
Destructive
Inspect

Run Disco on tabular data to find novel, statistically validated patterns.

This is NOT another data analyst — it's a discovery pipeline that systematically
searches for feature interactions, subgroup effects, and conditional relationships
nobody thought to look for, then validates each on hold-out data with FDR-corrected
p-values and checks novelty against academic literature.

This is a long-running operation. Returns a run_id immediately.
Use discovery_status to poll and discovery_get_results to fetch completed results.

Use this when you need to go beyond answering questions about data and start
finding things nobody thought to ask. Do NOT use this for summary statistics,
visualization, or SQL queries.

Public runs are free but results are published. Private runs cost credits.
Call discovery_estimate first to check cost. Private report URLs require
sign-in — tell the user to sign in at the dashboard with the same email
address used to create the account (email code, no password needed).

Call discovery_upload first to upload your file, then pass the returned file_ref here.

Args:
    target_column: The column to analyze — what drives it, beyond what's obvious.
    file_ref: The file reference returned by discovery_upload.
    analysis_depth: Search depth (1=fast, higher=deeper). Default 1.
    visibility: "public" (free) or "private" (costs credits). Default "public".
    title: Optional title for the analysis.
    description: Optional description of the dataset.
    excluded_columns: Optional JSON array of column names to exclude from analysis.
    column_descriptions: Optional JSON object mapping column names to descriptions. Significantly improves pattern explanations — always provide if column names are non-obvious (e.g. {"col_7": "patient age", "feat_a": "blood pressure"}).
    author: Optional author name for the report.
    source_url: Optional source URL for the dataset.
    use_llms: Slower and more expensive, but you get smarter pre-processing, summary page, literature context and pattern novelty assessment. Only applies to private runs — public runs always use LLMs. Default false.
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: target_column (required), file_ref, analysis_depth, visibility, +8 more. Returns: result

discovery_estimateA
Read-only
Inspect

Estimate cost, time, and credit requirements before running an analysis.

Returns credit cost, estimated duration in seconds, whether you have
sufficient credits, and whether a free public alternative exists. Always call
this before discovery_analyze for private runs.

Args:
    file_size_mb: Size of the dataset in megabytes.
    num_columns: Number of columns in the dataset.
    num_rows: Number of rows (optional, improves time estimate).
    analysis_depth: Search depth (1=fast, higher=deeper). Default 1.
    visibility: "public" (free, results published) or "private" (costs credits).
    use_llms: Slower and more expensive, but you get smarter pre-processing, summary page, literature context and pattern novelty assessment. Only applies to private runs — public runs always use LLMs. Default false.
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: file_size_mb (required), num_columns (required), num_rows, analysis_depth, +3 more. Returns: result

discovery_get_resultsA
Read-only
Inspect

Fetch the full results of a completed Disco run.

Returns discovered patterns (with conditions, p-values, novelty scores,
citations), feature importance scores, a summary with key insights, column
statistics, and suggestions for what to explore next.

The response includes a `dashboard_urls` object with direct links to each
page of the interactive report — use these to direct the user to the most
relevant view:
- **summary**: AI-generated overview with key insights, novel findings, and plain-language explanation of the most important findings
- **patterns**: Full list of discovered patterns with conditions, effect sizes, p-values, novelty scores, citations, and interactive visualisations
- **features**: Feature importances, feature statistics and distribution plots, and correlation matrix
- **territory**: Interactive 3D map showing how patterns select different regions of the data

Only call this after discovery_status returns "completed".

Args:
    run_id: The run ID returned by discovery_analyze.
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: run_id (required), api_key. Returns: result

discovery_list_plansA
Read-only
Inspect

List available Disco plans with pricing.

No authentication required. Returns all available subscription tiers with credit allowances and pricing. Use this to help users choose a plan.

Inputs: no named parameters. Returns: result

discovery_loginA
Idempotent
Inspect

Get a new API key for an existing Disco account.

Sends a 6-digit verification code to the email address. Call
discovery_login_verify with the code to receive a new API key.
Use this when you need an API key for an account that already exists
(e.g. the key was lost or this is a new agent session).

Returns 404 if no account exists with this email — use discovery_signup instead.

Args:
    email: Email address of the existing account.

Inputs: email (required). Returns: result

discovery_login_verifyA
Idempotent
Inspect

Complete login and receive a new API key.

Call this after discovery_login returns {"status": "verification_required"}.
The user receives a 6-digit code by email — pass it here along with the
same email address. Returns a new API key on success.

Args:
    email: Email address used in the discovery_login call.
    code: 6-digit verification code from the email.

Inputs: email (required), code (required). Returns: result

discovery_purchase_creditsA
Destructive
Inspect

Purchase Disco credit packs using a stored payment method.

Credits cost $0.10 each, sold in packs of 100 ($10/pack). Credits are used
for private analyses (public analyses are free). Requires a payment method
on file — use discovery_add_payment_method first.

Args:
    packs: Number of 100-credit packs to purchase. Default 1.
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: packs, api_key. Returns: result

discovery_signupA
Idempotent
Inspect

Create a Disco account and get an API key.

Provide an email address to start the signup flow. If email verification
is required, returns {"status": "verification_required"} — the user will
receive a 6-digit code by email, then call discovery_signup_verify to
complete signup and receive the API key. The free tier (10 credits/month,
unlimited public runs) is active immediately. No authentication required.

Returns 409 if the email is already registered.

Args:
    email: Email address for the new account.
    name: Display name (optional — defaults to email local part).

Inputs: email (required), name. Returns: result

discovery_signup_verifyA
Idempotent
Inspect

Complete Disco signup using an email verification code.

Call this after discovery_signup returns {"status": "verification_required"}.
The user receives a 6-digit code by email — pass it here along with the
same email address used in discovery_signup. Returns an API key on success.

Args:
    email: Email address used in the discovery_signup call.
    code: 6-digit verification code from the email.

Inputs: email (required), code (required). Returns: result

discovery_statusA
Read-only
Inspect

Check the status of a Disco run.

Returns current status and progress details:
- status: "pending" | "processing" | "completed" | "failed"
- job_status: underlying job queue status
- queue_position: position in queue when pending (1 = next up)
- current_step: active pipeline step (preprocessing, training, interpreting, reporting)
- estimated_seconds: estimated total processing time in seconds
- estimated_wait_seconds: estimated queue wait time in seconds (pending only)

Poll this after calling discovery_analyze — runs typically take 3–15 minutes.
Use discovery_get_results to fetch full results once status is "completed".

Args:
    run_id: The run ID returned by discovery_analyze.
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: run_id (required), api_key. Returns: result

discovery_subscribeA
DestructiveIdempotent
Inspect

Subscribe to or change your Disco plan.

Available plans:
- "free_tier": Explorer — free, 10 credits/month
- "tier_1": Researcher — $49/month, 50 credits/month
- "tier_2": Team — $199/month, 200 credits/month

Paid plans require a payment method on file. Credits roll over on paid plans.

Args:
    plan: Plan tier ID ("free_tier", "tier_1", or "tier_2").
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: plan (required), api_key. Returns: result

discovery_uploadAInspect

Upload a dataset file and return a file reference for use with discovery_analyze.

Call this before discovery_analyze. Pass the returned result directly to
discovery_analyze as the file_ref argument.

Provide exactly one of: file_url, file_path, or file_content.

Args:
    file_url: A publicly accessible http/https URL. The server downloads it directly.
              Best option for remote datasets.
    file_path: Absolute path to a local file. Only works when running the MCP server
               locally (not the hosted version). Streams the file directly — no size limit.
    file_content: File contents, base64-encoded. For small files when a URL or path
                  isn't available. Limited by the model's context window.
    file_name: Filename with extension (e.g. "data.csv"), for format detection.
               Only used with file_content. Default: "data.csv".
    api_key: Disco API key (disco_...). Optional if DISCOVERY_API_KEY env var is set.

Inputs: file_content, file_name, file_path, file_url, +1 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 14 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap. Account management (discovery_account, discovery_add_payment_method), authentication (discovery_login, discovery_login_verify, discovery_signup, discovery_signup_verify), analysis workflow (discovery_upload, discovery_estimate, discovery_analyze, discovery_status, discovery_get_results), and billing (discovery_list_plans, discovery_purchase_credits, discovery_subscribe) are all cleanly separated. An agent can easily distinguish between tools like discovery_analyze (run analysis) and discovery_estimate (check cost/time) despite both relating to analysis preparation.

    Naming Consistency5/5

    All 14 tools follow a perfect 'discovery_verb_noun' pattern with consistent snake_case throughout. The naming convention is highly predictable: discovery_account, discovery_analyze, discovery_estimate, discovery_get_results, discovery_list_plans, etc. This consistency makes the tool set immediately understandable and navigable.

    Tool Count5/5

    14 tools is ideal for this server's comprehensive scope covering authentication, data upload, analysis execution, results retrieval, and billing management. Each tool serves a specific, necessary function in the end-to-end workflow. The count is neither too thin (missing critical operations) nor bloated (no redundant tools), perfectly matching the domain of a sophisticated data analysis platform.

    Completeness5/5

    The tool surface provides complete coverage for the Disco platform's domain. It includes full authentication flow (signup/login with verification), account management, billing operations (plans, payments, credits), data upload, analysis estimation, execution, status monitoring, and results retrieval. There are no dead ends or gaps—every logical step in the workflow has a corresponding tool, creating a coherent end-to-end experience.

    Maintenance

    ActivitySlowing
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers