【mlflow系列6】mlflow model registry

是什么

本文基于mlflow 1.11.0版本
正如官网说的:

The MLflow Model Registry component is a centralized model store, set of APIs, and UI, to collaboratively manage the full lifecycle of an MLflow Model. It provides model lineage (which MLflow experiment and run produced the model), model versioning, stage transitions (for example from staging to production), and annotations

model registry 是一个集中的模型存储,apis,UI,用来全周期的管理model,他能提供一种模型血缘,模型版本,以及模型的阶段切换。

那它究竟能做什么呢,我们看看前面mlflow系列1 这篇文章,如果没用到model registry,我们启动服务的时候,得按照如下方式:

 export MLFLOW_TRACKING_URI=http://localhost:5002        
  mlflow models serve -m runs:/e69aed0b22fb45debd115dfc09dbc75a/model -p 1234 --no-conda       

这里我们得提供RUN_ID,也就是e69aed0b22fb45debd115dfc09dbc75a
而如果我们采用model registry的话,启动服务的时候,我们可以按照如下方式:

export MLFLOW_TRACKING_URI=http://localhost:5002

mlflow models serve -m "models:/sk-learn-random-forest-reg-model/Production"

其中sk-learn-random-forest-reg-model是model的名字,Production 是stag阶段,详细的我们会接下里介绍
那具体有什么作用呢:
model registry让我们在启动服务的时候,不需要指定RUN_ID,这样的话,我们在每次启动服务的时候,不需要再去查找RUN_ID,这样的话我们在每次重启的时候就不需要再进行文件的修改,对于算法人员来说,方便很多,而且model registry从逻辑上进行了stag的划分,且可以stag的切换,这样我们管理model的时候,就能很直观的知道当前算法服务是基于那个模型来的

怎么操作

我们现在来演示怎么进行model registry的操作,假设我们已经按照mlflow系列1进行了多次python wine.py 操作,这样我们在界面上就能看到一个实验的多个版本,如下:
【mlflow系列6】mlflow model registry_第1张图片

点击Registry model如下:
【mlflow系列6】mlflow model registry_第2张图片

这样我们就可以注册模型,模型的名字(假设我们这里为wine)可以自己选择输入

点击wine,

【mlflow系列6】mlflow model registry_第3张图片

点击Version3,

【mlflow系列6】mlflow model registry_第4张图片
当然也可以具体的删除某个版本的model,只要点击版本,之后删除位置和上面的位置一样

这样我们按照如下方式启动和访问服务即可,不需要关心具体的RUN_ID,只需要在界面上把stage切换成Production就行

# 启动服务
mlflow models serve -m "models:/wine/Production" -p 12346 -h 0.0.0.0 --no-conda
# 访问服务
curl -X POST -H "Content-Type:application/json; format=pandas-split" --data '{"columns":["alcohol", "chlorides", "citric acid", "density", "fixed acidity", "free sulfur dioxide", "pH", "residual sugar", "sulphates", "total sulfur dioxide", "volatile acidity"],"data":[[12.8, 0.029, 0.48, 0.98, 6.2, 29, 3.33, 1.2, 0.39, 75, 0.66]]}' http://localhost:12346/invocations 

至此,mlflow model registry的主要部分就介绍完了

你可能感兴趣的:(mlflow,大数据,算法)