Deepchecks测试

testland2026-10-25查看 1517复制 1820

在表格 / NLP / 视觉数据 + 模型上运行 Deepchecks 套件(数据完整性、训练-测试验证、模型评估)。将 `result.passed_conditions()` 传给 CI 以对回归进行门禁;根据 Deepchecks 生命周期姿态,相同的检查在研究、CI 和生产监控期间运行。在训练之前使用,以捕获表格、NLP 或视觉数据集中的训练-测试泄漏和数据完整性缺陷,并在生产样本上重新运行相同的套件以检测漂移。

Download (.md)

📘如何使用这个技能

  1. 1
    复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
  2. 2
    打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
  3. 3
    粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
  4. 4
    直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景

💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。

SKILL.md4694 chars
---
name: deepchecks-tests
description: "Run Deepchecks suites (data integrity, train-test validation, model evaluation) on tabular / NLP / vision data + models. Pass `result.passed_conditions()` to CI to gate on regressions; the same checks run during research, CI, and production monitoring per the Deepchecks lifecycle posture. Use before training to catch train-test leakage and data-integrity defects in a tabular, NLP, or vision dataset, and to re-run the same suite on production samples to detect drift."
metadata:
  keywords: "deepchecks, ml-testing, data-validation, train-test-split, model-evaluation"
  version: "1.3.5"
---

# deepchecks-tests

Deepchecks is *"a holistic open-source solution for all of your AI &
ML validation needs"* per the [Deepchecks welcome]. Validates **data
integrity, train-test splits, model evaluation, end-to-end model
development from research through production**.

## When to use

- Pre-training: validate data integrity + train-test leakage.
- Pre-deployment: model evaluation suite as merge gate.
- Production monitoring: same suite re-run on production samples
  to detect drift.

## Step 1 - Install

```bash
pip install deepchecks
```

Per the [Deepchecks welcome] page.

## Step 2 - Wrap data

For tabular models:

```python
from deepchecks.tabular import Dataset

train_ds = Dataset(
    train_df,
    label="target",
    cat_features=CATEGORICAL_COLUMNS,
)
test_ds = Dataset(
    test_df,
    label="target",
    cat_features=CATEGORICAL_COLUMNS,
)
```

`cat_features` matters for distribution checks. The Vision and NLP
APIs differ - see the [Deepchecks welcome] section linking
quickstarts for each data type.

## Step 3 - Run the data integrity suite

```python
from deepchecks.tabular.suites import data_integrity

integrity = data_integrity()
result = integrity.run(train_ds)
result.save_as_html("data_integrity.html")
```

Catches: duplicate rows, missing values, mixed types, conflicting
labels, single-value features, string mismatches.

## Step 4 - Run the train-test validation suite

```python
from deepchecks.tabular.suites import train_test_validation

validation = train_test_validation()
result = validation.run(train_ds, test_ds)
result.save_as_html("train_test_validation.html")
```

Catches: target drift, feature drift, train-test data leakage, label
imbalance, dataset size mismatch.

## Step 5 - Run the model evaluation suite

```python
from deepchecks.tabular.suites import model_evaluation

evaluation = model_evaluation()
result = evaluation.run(train_ds, test_ds, model)
result.save_as_html("model_evaluation.html")

if not result.passed_conditions():
    raise SystemExit("Deepchecks model evaluation failed")
```

Catches: performance regression vs baseline, weak segments, calibration
issues, prediction drift between train and test.

## Step 6 - Per-check thresholds

```python
from deepchecks.tabular.checks import FeatureDrift

check = FeatureDrift().add_condition_drift_score_less_than(
    max_allowed_categorical_score=0.2,
    max_allowed_numeric_score=0.1,
)
result = check.run(train_ds, test_ds)

if not result.passed_conditions():
    print(result.value)
    raise SystemExit("FeatureDrift failed threshold")
```

Each check has `add_condition_*` methods; chain them for per-check
gating.

## Step 7 - CI integration

```yaml
- name: Deepchecks suite
  run: |
    python ml/deepchecks_suite.py
- name: Upload Deepchecks reports
  uses: actions/upload-artifact@v4
  with:
    name: deepchecks-reports
    path: "*.html"
```

## Anti-patterns

| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Skip `cat_features` | All categorical checks misfire | Always specify (Step 2) |
| Skip `data_integrity` suite | Train on leaky / dup-heavy data | Run before `train_test_validation` (Step 3) |
| Block CI on every check | Hundreds of warning conditions; team disables | Define per-check thresholds (Step 6); gate Critical only |
| Re-run on the SAME test split each PR | Fixed split → fixed results; no drift detection | Use rolling/cross-validation splits |
| Reuse training data as "current" for production monitoring | Always passes drift; blind to real drift | Use real production samples |

## Limitations

- Deepchecks' "default conditions" are tuned for textbook ML; they
  may be too strict for real-world skewed data. Tune via
  `add_condition_*` methods (Step 6).
- Vision suite memory footprint: large image datasets need batched
  runs. See the [Deepchecks welcome] vision quickstart link.

## References

- [Deepchecks welcome] - overview, install, suite/check architecture,
  per-data-type quickstart links

[Deepchecks welcome]: https://docs.deepchecks.com/stable/getting-started/welcome.html
来源:skillsdirectory

评论0

登录后参与评论

还没有评论,来抢沙发吧