算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
track-ml-experiments【设计与创意】Set up MLflow tracking server for experiment management, configure autologging for popular ML frameworks, compare runs with metrics and visualizations, and manage artifacts in remote storage backends for reproducible machine learning workflows. Use when starting a new ML project that requires experiment tracking, migrating from manual logs to automat…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
全配文與模板見 Extended Examples。
立 MLflow 追服而行全試之追,含計、參、件。
pip install mlflow)立 MLflow 追服與宜後儲。
# Option 1: Local file-based tracking (development)
mkdir -p mlruns
export MLFLOW_TRACKING_URI="file:./mlruns"
# Option 2: SQLite backend with local artifacts
mlflow server \
--backend-store-uri sqlite:///mlflow.db \
--default-artifact-root ./mlartifacts \
# ... (see EXAMPLES.md for complete implementation)
立配文為團享:
# mlflow_config.py
import os
MLFLOW_TRACKING_URI = os.getenv(
"MLFLOW_TRACKING_URI",
"http://mlflow-server.company.com:5000"
)
# ... (see EXAMPLES.md for complete implementation)
得:MLflow UI 於所定 host:port 可達,示空試列。服日確啟成而無誤。
敗則:以 netstat -tulpn | grep 5000 察口可用,驗資庫連串,確 S3 憑已設(aws configure),察防火牆為遠取。
啟框特之自記以自捕計、參、模。
# training_script.py
import mlflow
from mlflow_config import MLFLOW_TRACKING_URI, MLFLOW_EXPERIMENT_NAME
# Set tracking URI
mlflow.set_tracking_uri(MLFLOW_TRACKING_URI)
mlflow.set_experiment(MLFLOW_EXPERIMENT_NAME)
# ... (see EXAMPLES.md for complete implementation)
為 PyTorch:
import mlflow.pytorch
mlflow.pytorch.autolog(
log_every_n_epoch=1,
log_every_n_step=None,
log_models=True,
disable=False,
exclusive=False,
# ... (see EXAMPLES.md for complete implementation)
得:行現於 MLflow UI,諸超參、計(訓/驗損、準)、模件、入例皆已自記。
敗則:驗 MLflow 之版與 ML 框之兼容(mlflow.sklearn.autolog() 須 MLflow ≥1.20),察自記是否支君之模類,閉自記而用手記為退,以 mlflow.set_tracking_uri() 察連誤。
加自定計、參、件、標為全試文檔。
# comprehensive_tracking.py
import mlflow
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
def train_and_log_model(params, X_train, y_train, X_test, y_test):
"""
# ... (see EXAMPLES.md for complete implementation)
得:MLflow UI 顯豐之試資,含逐步計、視件、模簽、入例、為篩搜之全標。
敗則:察件儲之權(aws s3 ls s3://bucket/path),驗 matplotlib 後為圖記(plt.switch_backend('Agg')),確 log_dict 之資為 JSON 可序,察本機件儲之盤空。
用 MLflow 之比器以析多試。
# compare_runs.py
import mlflow
from mlflow.tracking import MlflowClient
client = MlflowClient()
def compare_experiments(experiment_name, metric_name="test_accuracy", top_n=5):
"""
# ... (see EXAMPLES.md for complete implementation)
命行之比:
# Compare runs using MLflow CLI
mlflow runs compare --experiment-name customer-churn \
--order-by "metrics.test_accuracy DESC" \
--max-results 10
# Export run data to CSV
mlflow experiments csv --experiment-name customer-churn \
--output experiments.csv
得:終端示序之行附要計,HTML 報已生附格之比表,CSV 文含諸行資為續析。
敗則:以 mlflow experiments list 驗試存,察計名精合(區大小),確行已成(察行態),驗出文之寫權。
立 S3/Azure/GCS 後為可擴件治。
# artifact_storage_config.py
import mlflow
import os
def configure_s3_backend():
"""
Configure S3 for artifact storage.
"""
# ... (see EXAMPLES.md for complete implementation)
Docker Compose 為 MLflow 與 PostgreSQL 與 S3:
# docker-compose.yml
version: '3.8'
services:
postgres:
image: postgres:14
environment:
POSTGRES_DB: mlflow
# ... (see EXAMPLES.md for complete implementation)
得:件成傳於遠儲,MLflow UI 示件鏈指於 S3/Azure/GCS URIs,自 UI 下件正行。
敗則:以 aws s3 ls 或 az storage blob list 驗雲憑,察桶/容權(須寫權),確 MLflow 裝附雲附(pip install mlflow[extras]),試與儲端之網連,察 CORS 設為瀏覽器取。
立自清、存、組之策。
# lifecycle_management.py
import mlflow
from mlflow.tracking import MlflowClient
from datetime import datetime, timedelta
client = MlflowClient()
def archive_old_experiments(days_old=90):
# ... (see EXAMPLES.md for complete implementation)
得:舊試移於除態,敗行除於活列,最佳行已標以易篩於 UI,儲空已收。
敗則:察試之權(須為主以除),驗行實於 FAILED 態,確排序所用之計於諸行皆存,察資庫連為批操,驗於遠儲件除之足權。
MLFLOW_TRACKING_URI 環變,察防火牆,確服在行exclusive=True 或閉衝之自記register-ml-model — 註所追之模於 MLflow 模冊version-ml-data — 以 DVC 版資為可復試setup-automl-pipeline — 合試追於自 ML 流deploy-ml-model-serving — 部最佳所追之模於產orchestrate-ml-pipeline — 合試追與流編排