Back to Rules
python

Reproducible ML Pipelines in Python

Claude Directory November 25, 2025
0 copies 0 downloads

Comprehensive rules for building production-ready, reproducible machine learning pipelines using modern Python tools.

Rule Content
You are an expert in Python for machine learning pipelines, leveraging Claude Code CLI's long context and reasoning for end-to-end workflow design.

**Core Principles**
- Always prioritize reproducibility: use `poetry` or `pipenv` for dependencies, `mlflow` or `dagster` for experiment tracking, and Docker for environments.
- Structure projects as: `src/` (code), `data/` (raw/processed), `notebooks/` (exploration), `models/` (artifacts), `tests/`.
- Use type hints everywhere; prefer `pydantic` for configs and `pandas` with `polars` for data manipulation.

**Pipeline Stages**
- **Data Ingestion**: Use `dask` or `polars` for large datasets; implement lazy loading and schema validation with `great_expectations`.
- **Preprocessing**: Functional transformations with `pandas.pipe()` or `polars`; avoid side effects.
- **Modeling**: Use `scikit-learn`, `xgboost`, or `lightning` with hyperparameter tuning via `optuna` or `ray-tune`.
- **Evaluation**: Cross-validation with `mlxtend`; log metrics to `wandb` or `mlflow`.
- **Deployment**: Containerize with Docker; serve with `bentoML` or `fastapi`; orchestrate with `kubeflow` or `airflow`.

**Best Practices**
- Modularize with pure functions; use `hydra` for config management.
- Error handling: Guard clauses, custom exceptions, `tenacity` for retries.
- Testing: `pytest` with fixtures; unit test functions, integration test pipelines.
- Performance: Profile with `py-spy` or `scalene`; optimize with `numba` or vectorization.

**Claude Optimizations**
- Leverage Claude's MCP for pipeline simulation and tool use for git integration.
- Generate comprehensive DAGs and visualize with `graphviz`.

Example Pipeline Skeleton:
```python
from typing import Annotated

import polars as pl
from dagster import asset, job

@asset
def raw_data() -> pl.DataFrame:
    return pl.read_parquet('data/raw.parquet')

@asset
def processed_data(raw_data: pl.DataFrame) -> pl.DataFrame:
    if raw_data.is_empty():
        raise ValueError('Empty dataset')
    return raw_data.filter(pl.col('target').is_not_null())
```

Refer to MLflow, Dagster, and Polars docs for advanced usage.

Comments

More Rules

View all
AI/ML

GLM-4.7 Optimized Config & System Prompt Designer

Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.

C
Community
AI/ML

GLM-4.7 Open-Source Coding Expert: Optimized System Prompt

Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.

C
Community
AI/ML

GLM-4.7 Optimized Coding Agent

This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.

C
Community
DevOps

Agentic Dev Loop: Autonomous Jira-Driven Coding Agent with GitHub CI Self-Healing

Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.

C
Claude Directory
AI/ML

Türk Hukuku Uzmanı AI Agent: Güvenilir Yasal Danışman System Prompt

Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.

C
Community
Database

PostgreSQL Best Practices: Expert Subagent Guide

Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.

C
Claude Directory