MLflow 소개
Weston Bassler
Senior MLOps Engineer

모델 버전
모델 스테이지

모델 로드
# MLflow flavor
mlflow.FLAVOR.load_model()
모델 서빙
# MLflow 커맨드라인 서빙
mlflow models serve
규칙
models:/
모델 버전
models:/model_name/version
모델 스테이지
models:/model_name/stage
# Import flavor import mlflow.FLAVOR# Load version mlflow.FLAVOR.load_model("models:/model_name/version")# Load stage mlflow.FLAVOR.load_model("models:/model_name/stage")
# Import flavor import mlflow.sklearn# Staging의 Unicorn 모델 로드 model = mlflow.sklearn.load_model("models:/Unicorn/Staging")# 모델 출력 model
LogisticRegression()
# 추론
model.predict(data)
# Production 스테이지의 Unicorn 모델 서빙
mlflow models serve -m "models:/Unicorn/Production"
2023/03/26 15:07:00 INFO mlflow.models.flavor_backend_registry:
Selected backend for flavor 'python_function'
2023/03/26 15:07:00 INFO mlflow.pyfunc.backend: === Running command 'exec gunicorn
--timeout=60 -b 127.0.0.1:5000 -w 1 ${GUNICORN_CMD_ARGS} --
mlflow.pyfunc.scoring_server.wsgi:app'
[2023-03-26 15:07:00 -0400] [86409] [INFO] Starting gunicorn 20.1.0
[2023-03-26 15:07:00 -0400] [86409] [INFO] Listening at: http://127.0.0.1:5000
[2023-03-26 15:07:00 -0400] [86409] [INFO] Using worker: sync
[2023-03-26 15:07:00 -0400] [86410] [INFO] Booting worker with pid: 86410
CSV 형식
pandas_df.to_csv()
JSON 형식
{
"dataframe_split": {
"columns": ["R&D Spend", "Administration", "Marketing Spend", "State"],
"data": [["165349.20", 136897.80, 471784.10, 1]]
}
}
# 페이로드를 invocations 엔드포인트로 전송
curl http://127.0.0.1:5000/invocations -H 'Content-Type: application/json' -d
{
"dataframe_split": {
"columns": ["R&D Spend", "Administration", "Marketing Spend", "State"],
"data": [["165349.20", 136897.80, 471784.10, 1]]
}
}
[[104055.1842384]]
MLflow 소개