AWS sagemaker documentation change
Summary
Added SageMaker Python SDK v2 code example for MLflow metric logging and model registration
Security assessment
The change adds a legacy SDK implementation example for MLflow workflows. It demonstrates standard metric logging and model registration without any security configurations, vulnerability mitigations, or security feature explanations.
Diff
diff --git a/sagemaker/latest/dg/mlflow-track-experiments-log-metrics.md b/sagemaker/latest/dg/mlflow-track-experiments-log-metrics.md index 533bef013..43892447d 100644 --- a//sagemaker/latest/dg/mlflow-track-experiments-log-metrics.md +++ b//sagemaker/latest/dg/mlflow-track-experiments-log-metrics.md @@ -44,0 +45,3 @@ The following example takes you through a basic model training workflow using SK +SageMaker Python SDK v3 + + @@ -101,0 +105,26 @@ The following example takes you through a basic model training workflow using SK +SageMaker Python SDK v2 (Legacy) + + + + import mlflow.sklearn + from mlflow.models import infer_signature + from sklearn.datasets import make_regression + from sklearn.ensemble import RandomForestRegressor + + mlflow.set_tracking_uri(arn) + params = {"n_estimators": 3, "random_state": 42} + X, y = make_regression(n_features=4, n_informative=2, random_state=0, shuffle=False) + + # Log MLflow entities + with mlflow.start_run() as run: + rfr = RandomForestRegressor(**params).fit(X, y) + signature = infer_signature(X, rfr.predict(X)) + mlflow.log_params(params) + mlflow.sklearn.log_model(rfr, artifact_path="sklearn-model", signature=signature) + + model_uri = f"runs:/{run.info.run_id}/sklearn-model" + mv = mlflow.register_model(model_uri, "RandomForestRegressionModel") + + print(f"Name: {mv.name}") + print(f"Version: {mv.version}") +