Giới thiệu về MLflow
Weston Bassler
Senior MLOps Engineer
Đơn giản hóa tích hợp thư viện ML
Đơn giản hóa triển khai
Quy ước gọi là "Flavor"


Viết công cụ tùy chỉnh từ thư viện ML
Flavor giúp đơn giản hóa việc thêm mã tùy chỉnh
# Import flavor từ module mlflow
import mlflow.FLAVOR
# Tự động log mô hình và chỉ số
mlflow.FLAVOR.autolog()
# Flavor tích hợp cho scikit-learn
mlflow.sklearn.autolog()
# Import scikit-learn import mlflow from sklearn.linear_model import \ LinearRegression# Dùng auto-logging mlflow.sklearn.autolog()
# Huấn luyện mô hình
lr = LinearRegression()
lr.fit(X, y)
Mô hình sẽ được ghi log tự động khi gọi model.fit()
MODEL.get_params()
# Huấn luyện mô hình lr = LinearRegression() lr.fit(X, y)# Lấy tham số params = lr.get_params(deep=True)params
{'copy_X': True, 'fit_intercept': True, 'n_jobs': None,
'normalize': 'deprecated', 'positive': False}

# Mô hình
lr = LinearRegression()
lr.fit(X, y)

# Mô hình
lr = LinearRegression()
lr.fit(X, y)
Cấu trúc thư mục của một mô hình:
model/
MLmodel
model.pkl
python_env.yaml
requirements.txt
# Autolog
mlflow.sklearn.autolog()

artifact_path: model
flavors:
python_function:
env:
virtualenv: python_env.yaml
loader_module: mlflow.sklearn
model_path: model.pkl
predict_fn: predict
python_version: 3.10.8
sklearn:
code: null
pickled_model: model.pkl
serialization_format: cloudpickle
sklearn_version: 1.1.3

Giới thiệu về MLflow