Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

experiment-tracking-and-reproducibility

БесплатноБез исполняемых скриптовНе проверен

Use when a change trains a model, reports a metric, or touches seeds, data or model versions, the lockfile, MLflow or DVC — what every run must log, seeding…

makifbaysalот makifbaysal★ 123 звезды на GitHub

Об этом скилле

Experiment Tracking and Reproducibility

Overview

A metric nobody can reproduce is an anecdote. Reproducing a run needs five things: the code (git SHA), the data (a version or hash), the parameters, the environment (lockfile) and the seed. Log all five with every run, and make the training entrypoint a deterministic function of them.

Core principle: if two runs with the same five inputs can produce different models, the difference must be explainable (GPU non-determinism, thread scheduling) and bounded — never "randomness" from an unseeded call.

1. What every run logs

Item How
Code git SHA and a dirty flag
Data DVC hash from dvc.lock, a snapshot date plus query, or a content hash of the training frame
Parameters the full resolved config, including defaults
Environment hash of the lockfile (uv.lock, poetry.lock), Python version, key library versions
Seed the one seed the run derived everything from
Metrics mean and spread across folds, the baseline's score, the test score once (rule test-set-discipline)
Artifact the fitted pipeline in a safe format (rule safe-model-serialization), with an input example
def data_fingerprint(df: pd.DataFrame) -> str:
    return hashlib.sha256(pd.util.hash_pandas_object(df, index=True).to_numpy().tobytes()).hexdigest()[:16]

def code_and_env() -> dict[str, str]:
    sha = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True).stdout.strip()
    dirty = bool(subprocess.run(["git", "status", "--porcelain"], capture_output=True, text=True, check=True).stdout)
    lock = hashlib.sha256(Path("uv.lock").read_bytes()).hexdigest()[:16]
    return {"git_sha": sha, "git_dirty": str(dirty), "lock_sha": lock, "python": platform.python_version()}

2. MLflow 3

with mlflow.start_run(run_name=f"churn-{cfg.seed}"):
    mlflow.log_params(cfg.model_dump())
    mlflow.set_tags({**code_and_env(), "data_fingerprint": data_fingerprint(train_df), "seed": str(cfg.seed)})
    mlflow.log_input(mlflow.data.from_pandas(train_df, name="train", targets="churned"), context="training")

    cv = cross_validate(pipe, X_train, y_train, cv=splitter, scoring="average_precision")
    mlflow.log_metrics({
        "cv_ap_mean": cv["test_score"].mean(),
        "cv_ap_std": cv["test_score"].std(),
        "baseline_ap": y_train.mean(),
    })

    pipe.fit(X_train, y_train)
    info = mlflow.sklearn.log_model(
        sk_model=pipe,
        name="model",
        input_example=X_train.head(5),
        skops_trusted_types=REVIEWED_SKLEARN_TYPES,
    )
  • MLflow 3 logs models as first-class LoggedModels: log_model(..., name=...) replaces the 2.x artifact_path= argument, and info.model_uri points at the logged model.
  • Use registry aliases (champion, challenger) and load models:/churn@champion; registry stages are deprecated.
  • Follow the repository's pinned MLflow and its existing logging helpers; W&B or another tracker in the repo stays the tracker (rule stack-choice).
  • Recent MLflow 3 releases save scikit-learn models with skops (outside Databricks) and refuse types that are not on a trusted list: REVIEWED_SKLEARN_TYPES names only the types you checked (a HistGradientBoosting* model needs its TreePredictor), never everything get_untrusted_types() reports. Older pins and Databricks use cloudpickle — load those only from the repository's own tracking server or registry (rule safe-model-serialization).

3. Tests never touch the shared tracking server

@pytest.fixture(autouse=True)
def local_mlflow(tmp_path, monkeypatch):
    monkeypatch.setenv("MLFLOW_TRACKING_URI", f"sqlite:///{tmp_path / 'mlflow.db'}")

A test asserts what the run logged (params, the metric keys, the data fingerprint tag) by reading it back from this local store. Your own end-to-end exercise of the pipeline logs to /tmp/tt-<task key>/ the same way.

4. Seeds

# ❌ global, legacy, invisible
np.random.seed(42)
idx = np.random.permutation(n)

# ✅ one generator, passed down; integer seeds for estimators and splitters
rng = np.random.default_rng(cfg.seed)
idx = rng.permutation(n)
splitter = StratifiedKFold(n_splits=5, shuffle=True, random_state=cfg.seed)
model = HistGradientBoostingClassifier(random_state=cfg.seed)
  • Python's random.seed(cfg.seed) too if any dependency uses it.
  • LightGBM: seed=, plus deterministic=True and a fixed num_threads when bit-identical results matter. XGBoost: random_state=.
  • PyTorch has its own list (deep-learning-pytorch).
  • A determinism test (two fits, same seed, identical predictions) belongs in the suite (ml-testing-strategy). Across different machines, compare with a tolerance — floating-point sums depend on thread scheduling.

5. Environment

  • The lockfile is the environment; uv sync --locked (or the repo's equivalent) builds it. Never pip install something ad hoc to get a run to work.
  • Pin CPU whe
Полный SKILL.md на GitHub

Установить experiment-tracking-and-reproducibility в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл experiment-tracking-and-reproducibility?

Use when a change trains a model, reports a metric, or touches seeds, data or model versions, the lockfile, MLflow or DVC — what every run must log, seeding, environment pinning, data versioning and keeping tests off the shared tracking server

Как установить скилл experiment-tracking-and-reproducibility?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл experiment-tracking-and-reproducibility запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить experiment-tracking-and-reproducibility с