| name | mlops |
| description | MLflow, model versioning, experiment tracking, model registry, and production ML systems |
| sasmp_version | 1.3.0 |
| bonded_agent | 06-ml-ai-engineer |
| bond_type | PRIMARY_BOND |
| skill_version | 2.0.0 |
| last_updated | 2025-01 |
| complexity | advanced |
| estimated_mastery_hours | 150 |
| prerequisites | ["machine-learning","containerization","python-programming"] |
| unlocks | ["llms-generative-ai"] |
MLOps
Production machine learning systems with MLflow, model versioning, and deployment pipelines.
Quick Start
import mlflow
from mlflow.tracking import MlflowClient
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, f1_score
import joblib
mlflow.set_tracking_uri("http://mlflow-server:5000")
mlflow.set_experiment("customer-churn-prediction")
with mlflow.start_run(run_name="rf-baseline"):
params = {"n_estimators": 100, "max_depth": 10, "random_state": 42}
mlflow.log_params(params)
model = RandomForestClassifier(**params)
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
metrics = {
"accuracy": accuracy_score(y_test, y_pred),
"f1_score": f1_score(y_test, y_pred, average="weighted")
}
mlflow.log_metrics(metrics)
mlflow.sklearn.log_model(
model, "model",
registered_model_name="churn-classifier",
signature=mlflow.models.infer_signature(X_train, y_pred)
)
print(f"Run ID: {mlflow.active_run().info.run_id}")
Core Concepts
1. Model Registry & Versioning
from mlflow.tracking import MlflowClient
client = MlflowClient()
client.transition_model_version_stage(
name=,
version=,
stage=
)
client.transition_model_version_stage(
name=,
version=,
stage=
)
model_uri =
model = mlflow.sklearn.load_model(model_uri)
() -> :
results = {}
version versions:
run_id = client.get_model_version(model_name, (version)).run_id
run = client.get_run(run_id)
results[version] = run.data.metrics
results