360 Secure SkillHub
360 安全技能中心

MLOps Observability

面向机器学习工程的可观测性参考技能:说明如何复制并集成 MLflow 追踪脚本,记录参数、指标、模型、数据集与 Git commit;给出 Evidently 数据漂移检测与 SHAP 可解释性示例代码,提供随机种子固定、监控检查清单,并列出本地与生产环境的告警选项。

guohongbin-git
guohongbin-git
热度 25.89
最近更新 2026-05-11 17:26:14
分类:开发依赖:代码执行 / 读写文件 / 第三方 API应用场景:DevOps / 数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add mlops-observability-cn
Metadata
name
mlops-observability-cn
version
1.0.0
description
Full stack observability - reproducibility, lineage, monitoring, alerting
license
MIT

MLOps Observability 👁️

Glass box system - reproducible, traceable, monitored.

Features

1. MLflow Tracking 📊

Complete tracking setup:

cp references/mlflow-tracking.py ../your-project/src/tracking.py

Tracks:

  • Config (params)
  • Metrics (accuracy, loss)
  • Models (sklearn/pytorch)
  • Datasets (lineage)
  • Git commit (reproducibility)

2. Drift Detection 📉

Using Evidently:

from evidently import Report
from evidently.metrics import DataDriftTable

report = Report(metrics=[DataDriftTable()])
report.run(reference_data=train, current_data=prod)

3. Explainability (SHAP) 🔍

import shap

explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X)
shap.summary_plot(shap_values, X)

Quick Start

# Copy tracking code
cp references/mlflow-tracking.py ./src/

# Add to training script:
# from tracking import setup_tracking, log_training_run

Reproducibility

# Set all seeds
import random, numpy as np, torch
random.seed(42)
np.random.seed(42)
torch.manual_seed(42)

# Track git commit
import git
commit = git.Repo().head.commit.hexsha
mlflow.log_param("git_commit", commit)

Monitoring Checklist

  • Random seeds fixed
  • MLflow tracking enabled
  • System metrics logged
  • Drift detection setup
  • SHAP explanations saved
  • Alerts configured

Alerting

  • Local: plyer notifications
  • Production: PagerDuty (critical) / Slack (warnings)

Author

Converted from MLOps Coding Course

Changelog

v1.0.0 (2026-02-18)

  • Initial OpenClaw conversion
  • Added MLflow tracking code