Model sunumu

MLflow’a Giriş

Weston Bassler

Senior MLOps Engineer

MLflow Modelleri

  • Model paketlemeyi standartlaştırır

  • Modelleri kaydeder

  • Model değerlendirme

MLflow’a Giriş

Model Dağıtımı

ml-yaşam döngüsü

1 datacamp.com
MLflow’a Giriş

REST API

  • /ping - sağlık kontrolü için

  • /health - sağlık kontrolü için

  • /version - MLflow sürümünü almak için

  • /invocations - model skorlama için

  • 5000 portu

MLflow’a Giriş

Invocations uç noktası

/invocations

No,Name,Subject
1,Bill Johnson,English
2,Gary Valentine,Mathematics

Content-Type:application/json veya application/csv

{
    "1": {
        "No": "1",
        "Name": "Bill Johnson",
        "Subject": "English"
    },
    "2": {
        "No": "2",
        "Name": "Gary Valentine",
        "Subject": "Mathematics"
    }
}
MLflow’a Giriş

CSV biçimi

  • Pandas DataFrame

  • pandas_df.to_csv()

JSON biçimi

  • dataframe_split - split yöneliminde pandas DataFrame

  • dataframe_records - records yöneliminde pandas DataFrame

MLflow’a Giriş

DataFrame split

# DataFrame split yönelimi
{
  "dataframe_split": {
      "columns": ["sex", "age", "weight"],
      "data": [["male", 23, 160], ["female", 33, 120]]
  }
}
MLflow’a Giriş

Modelleri sunma

# MLflow serve komutu
mlflow models serve --help
Usage: mlflow models serve [OPTIONS]
MLflow’a Giriş

Serve URI

# Yerel dosya sistemi
mlflow models serve -m relative/path/to/local/model
# Çalıştırma ID'si
mlflow models serve -m runs:/<mlflow_run_id>/artifacts/model
# AWS S3
mlflow models serve -m s3://my_bucket/path/to/model
MLflow’a Giriş

Sunum örneği

# Çalıştırmadan modeli sunma
mlflow models serve -m runs:/e84a122920de4bdeaedb54146deeb429/artifacts/model
2023/03/12 16:28:28 INFO mlflow.models.flavor_backend_registry: 
Selected backend for flavor 'python_function'
2023/03/12 16:28:28 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-12 16:28:29 -0400] [48431] [INFO] Starting gunicorn 20.1.0
[2023-03-12 16:28:29 -0400] [48431] [INFO] Listening at: http://127.0.0.1:5000 
(48431)
[2023-03-12 16:28:29 -0400] [48431] [INFO] Using worker: sync
[2023-03-12 16:28:29 -0400] [48432] [INFO] Booting worker with pid: 48432
MLflow’a Giriş

Invocations isteği

# dataframe_split yönelimli payload'ı MLflow'a gönderme
curl http://127.0.0.1:5000/invocations -H 'Content-Type: application/json' -d '{
  "dataframe_split": {
      "columns": ["sex", "age", "weight"],
      "data": [["male", 23, 160], ["female", 33, 120]]
  }
}'
{"predictions": [1, 0]}
MLflow’a Giriş

Ayo berlatih!

MLflow’a Giriş

Preparing Video For Download...