Autocarver

io.github.mdefrance由 GitHub 账号 mdefrance 发布v7.8.4更新于 Nov 4, 2026

Qualify dataset columns and process them against a target with AutoCarver, fully on your machine.

已验证STDIO仅桌面数据与分析AI 与机器学习

概览

AI 生成的概览

AutoCarver 的本地 MCP 服务器,让助手对数据集列进行特征鉴定,并针对目标变量将其切分为受监督、可读的分箱。

可以做什么
  • 鉴定数据文件中的列,推断特征类型并提出切分方案
  • 针对二分类、多分类、有序或连续目标切分数值、类别与有序特征
  • 返回切分后的分箱汇总表,含每箱目标率与频数
  • 全部通过工具调用在本机完成,无需手写代码
适用场景
适合希望由助手为信用评分、欺诈检测或风险建模准备特征,或在建模前把原始列变成可审计分箱、又不想自己编写分箱代码的场景。
运行要求
以 stdio 方式在本机运行;需安装带 MCP 扩展的软件包,并用 python -m AutoCarver.mcp(或通过 uv)启动。需要 Python 环境和支持 MCP 的客户端,如 VS Code Copilot、Claude Desktop 或 Cursor。未声明认证或环境变量。
安装前请注意
服务器本身在本机运行,不会把数据集发送给 AutoCarver,但助手分享的内容对你自己的 LLM 服务商可见。切分质量取决于 LLM,生产使用前应由人工确认特征定义。它会读取本地数据文件并生成切分结果,需人工复核。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Autocarver,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[AutoCarver Logo]

[PyPI] [Python] [License] [SPEC 0] [Docs] [Tests] [Coverage]

[AutoCarver in one loop: discretize, rank groupings, carve]

AutoCarver turns raw numeric, categorical, and ordinal columns into supervised, drift-robust, human-readable bins in a few lines of code. Stop losing model performance to suboptimal manual binning — and stop discovering overfit bins in production monitoring.

  • Searched, not eyeballed — a dynamic-programming search ranks the candidate groupings by Tschuprow's T (default) or Cramér's V, for your min_freq and max_n_mod.
  • Robust by construction — every candidate grouping is vetoed unless it holds on a held-out dev set (and optional CV folds), at fit time rather than in monitoring.
  • Define → carve → model — declare your Features, fit a carver, transform: the whole feature set is carved in one supervised pass, not one notebook per feature. One carver per target type — BinaryCarver, MulticlassCarver, OrdinalCarver, ContinuousCarver (regression) — all with the identical API.
  • AI-assisted — a local MCP server lets your LLM assistant qualify and carve columns through tool calls, fully on your machine.

On the Titanic quick start, Fare collapses from 72 pre-carving modalities to 2 bins while its association with survival rises: Tschuprow's T 0.18 raw → 0.29 carved.

Built for credit scoring, fraud detection, and risk modeling.

🆕 What's New

📊 Cross-validated robustness. fit now accepts a cv argument for extra held-out robustness views on top of (or instead of) a dev set: carver.fit(X, y, cv=5). Accepts an int, any scikit-learn splitter, or explicit index pairs, resolved via sklearn.model_selection.check_cv — folds veto over-fit combinations but never reorder them (ranks stay anchored to the full train set). See Cross-validation folds.

🤖 LLM & MCP integration. AutoCarver now ships a local Model Context Protocol server: point an MCP-aware assistant (VS Code Copilot, Claude Desktop, Cursor, …) at a data file and let it qualify the columns and carve them against your target through tool calls. The server runs fully on your machine — your dataset is never sent to AutoCarver or any external service (only your own LLM provider sees what the assistant shares). Carving quality depends on the LLM, so have a human confirm the feature definitions before production use. See the LLM & MCP guide.

bash
pip install "autocarver[mcp]"

Once configured, just ask your assistant:

Qualify the columns in titanic.csv and carve them against Survived.

The assistant infers feature types, proposes a carving, and returns the summary table — no code written by hand.

Client config

Add to .vscode/mcp.json (VS Code / GitHub Copilot) or claude_desktop_config.json (Claude Desktop, under mcpServers instead of servers):

json
{  "servers": {    "autocarver": {      "command": "python",      "args": ["-m", "AutoCarver.mcp"]    }  }}

If you use uv, point command at uv instead so it resolves the environment for you:

json
{  "servers": {    "autocarver": {      "command": "uv",      "args": ["run", "python", "-m", "AutoCarver.mcp"]    }  }}

Install

bash
pip install autocarver

Quick Start

[Open in Colab]

You already have a DataFrame and a target — that's the first box ticked before you start:

  • Load data
  • Split train / dev
  • Declare features by type
  • Fit the carver, validated on the dev set
  • Inspect the carved bins
  • Persist

The rest is the snippet below — binary classification on the Titanic dataset:

python
from pathlib import Path
import pandas as pdfrom sklearn.model_selection import train_test_split
from AutoCarver import BinaryCarver, Features
# 1. Load dataurl = "https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv"data = pd.read_csv(url)target = "Survived"
# 2. Train / dev split, stratified on the targettrain, dev = train_test_split(data, test_size=0.33, random_state=42, stratify=data[target])
# 3. Declare features by typefeatures = Features(    categoricals=["Sex"],    numericals=["Age", "Fare", "Siblings/Spouses Aboard", "Parents/Children Aboard"],    ordinals={"Pclass": ["1", "2", "3"]},)
# 4. Fit the carver (dev set drives the robustness checks)carver = BinaryCarver(features=features)train_processed = carver.fit_transform(train, train[target], X_dev=dev, y_dev=dev[target])dev_processed = carver.transform(dev)
# 5. Inspect the carved buckets, target rate, and associationcarver.summary
# 6. Persist for later usecarver.save(Path("titanic_carver.json"))
# 7. Load the carver back incarver = BinaryCarver.load(Path("titanic_carver.json"))dev_processed = carver.transform(dev)

min_freq and max_n_mod are the only two knobs that matter to start with — the defaults (0.02 / 5) reflect common scoring practice, and every behavioral toggle lives in one ProcessingConfig object. Scan, adjust, move on.

For multiclass classification use MulticlassCarver (one binning per feature, against the full K-class target) — or OneVsRestCarver for a separate binning per class; for ordinal targets use OrdinalCarver; for regression use ContinuousCarver — the API is identical. To pre-select features by target association and inter-feature redundancy, pipe the carved output through ClassificationSelector or RegressionSelector with features=carver.features (the carver carves its own copy, so your original features stay raw).

What you get

Two questions worth answering before your next model review: can you defend every bin boundary of your current model to a stakeholder — and can you show each one holds on data it has never seen? AutoCarver makes both a one-liner:

  • The best grouping, not the first acceptable one — candidate groupings are ranked by Tschuprow's T (default) or Cramér's V, and the highest-ranked one that holds on the dev set is kept, so you don't stop at the first grouping that looks fine.

  • Stop silent overfitting before production — bins that only exist in your training sample degrade quietly under drift. Every candidate combination is validated on a dev set (and optional CV folds): any whose target rates flip or whose buckets fall below min_freq is rejected at fit time, not discovered in monitoring.

  • First-class ordinal features — OrdinalDiscretizer enforces your declared modality order, so under-represented levels are merged with their nearest neighbour instead of being collapsed by frequency.

  • You are the final auditor — carver.features.summary and carver.features.history expose the bin definitions, per-bin target rate / frequency, and the full carving trace; disagree with a boundary and you can override it, and transform applies your fix like any carved bin:

    python
    feature = carver.features("Siblings/Spouses Aboard")  # any carved feature; labels are [0, 1, 2]feature.group([1], 2)  # merge two bins you consider equivalent
  • Interpretable buckets — human-readable boundaries you can audit, document, and ship to a scorecard.

  • Dimensionality reduction — groups under-represented modalities and caps bins per feature (max_n_mod), which is especially useful before one-hot encoding.

  • Feature pre-selection — ClassificationSelector / RegressionSelector rank features by target association and filter on inter-feature correlation.

[Raw feature vs AutoCarver buckets: frequency and target rate before/after supervised binning]

Titanic Age, one BinaryCarver.fit call: 84 raw values collapse to 3 buckets with a monotonic survival rate.

How does it compare?

Manual binningAutoCarveroptbinningsklearn KBinsDiscretizer
Algorithmeyeballing distributions, notebook by notebookdynamic-programming search over ordered groupingsCART pre-binning, then CP solver (CP-SAT default; MIP optional)quantile / uniform / k-means — unsupervised
Grouping kept for given min_freq / max_n_mod / metricnone — first acceptable grouping winsbest viable grouping among the top-ranked candidatesbest merge of its CART pre-bins found within a solver time limitn/a — no target objective
Target typesany, at ~1 feature/hourbinary, multiclass, ordinal, continuousbinary, multiclass, continuousn/a
All feature types in one fit (numeric, categorical, ordinal, NaN)each feature is its own projectyes — declared ordinal order enforced, NaN as its own modalityyes via BinningProcess; no first-class ordinal type (user_splits workaround)numeric only; NaN raises
Held-out dev-set robustness checkrarely — too tedious to script per featureyes — dev set + optional k-fold CV, built into fitno (script CV yourself)no
Per-bin stats + carving history after fitscattered notebook cellscarver.summary, carver.historybinning_tableno

All three libraries are sklearn-Pipeline compatible; AutoCarver adds JSON round-trip persistence (carver.save("...json")). AutoCarver (ClassificationSelector, RegressionSelector) and optbinning (BinningProcess(selection_criteria=...)) both offer feature pre-selection. The full feature matrix, side-by-side runnable snippets, and a "when to pick which" guide live on the comparison page.

Documentation

Full reference, tutorials, and end-to-end notebook examples on ReadTheDocs.

来源:README.md,提交 6f003ab

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:该软件包类型无法在沙箱中运行。

版本历史

5
  1. v7.8.4最新Nov 4, 2026
  2. v7.8.3Oct 29, 2026
  3. v7.8.2Oct 25, 2026
  4. v7.8.1Sep 30, 2026
  5. v7.8.0Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分