[MLOps] MLflow Tracking

2022. 4. 16. 23:54ใ†๐Ÿ›  Data Engineering/MLOps

 

 

 

์ด๋ฒˆ ํฌ์ŠคํŒ…์€ MLflow์˜ ์ฃผ์š” ๊ธฐ๋Šฅ ์ค‘ ํ•˜๋‚˜์ธ Tracking์ด๋‹ค.

MLflow ์‹คํ—˜ํ•œ ๊ฒƒ๋“ค์„ ๋ฐ์ดํ„ฐ๋กœ ๋‚จ๊ธฐ๋Š” ๊ธฐ๋Šฅ์ด๋ฉฐ,

์–ด๋””์—/ ์–ด๋–ค ๊ฒƒ์„/ ์–ด๋–ป๊ฒŒ Tracking ํ•˜๋Š”์ง€ ํ†บ์•„๋ณด์ž. 

 

 

 

๋งŒ์•ฝ, MLflow์˜ ๊ฐœ๋…์„ ๋จผ์ € ์•Œ๊ณ  ์‹ถ๋‹ค๋ฉด ์ด๊ณณ์— ๋“ค์—ˆ๋‹ค ์˜ค์ž.

[์ด์ „ ํฌ์ŠคํŒ…: https://mengu.tistory.com/16?category=927678 ]

 

[MLOps] MLflow ์‹œ์ž‘ & ๊ฐœ๋… ์ •๋ฆฌ

์ตœ๊ทผ MLOps๋ž€ ๋‹จ์–ด๊ฐ€ ๋งŽ์ด ๋“ฑ์žฅํ–ˆ๋‹ค. MLOps : ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ ๊ธฐ๊ณ„ํ•™์Šต์„ ์•ˆ์ •์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ์ผ๋ จ์˜ ๊ณผ์ • MLOps = DevOps + Machine Learning ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ, ๋ถ„์„, ๋ชจ๋ธ๋ง์„ ์ฃผ๋กœ ๊ณต๋ถ€ํ•ด์™”์ง€๋งŒ, ์ตœ

mengu.tistory.com

 

 

 


 

 

 

MLflow Tracking

is organized around the concept of runs, which are executions of some piece of data science code. Each run records the following information

 

 

์ฐธ๊ณ  URL - https://www.mlflow.org/docs/latest/tracking.html

 

MLflow Tracking — MLflow 1.25.1 documentation

The MLflow Tracking component is an API and UI for logging parameters, code versions, metrics, and output files when running your machine learning code and for later visualizing the results. MLflow Tracking lets you log and query experiments using Python,

www.mlflow.org

 

 

Tracking ์ €์žฅ ๋ฐ์ดํ„ฐ ์ข…๋ฅ˜ & ์ €์žฅ์†Œ

 

1) Code Version

2) Start & End Time

3) Source

4) Parameters

5) Metrics

6) Artifacts

 

Tracking์„ ํ•˜๋ฉด ์ผ๋‹จ ๋กœ์ปฌ ํด๋”(mlruns)์— ์ €์žฅ๋œ๋‹ค. ํ•˜์ง€๋งŒ SQL ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค, Tracking server๋ฅผ ์„ค์ •ํ•˜์—ฌ ์ด๊ณณ์— ์ €์žฅ๋˜๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

 

 

 

1) Experiments ๋งŒ๋“ค๊ธฐ

 

๋จผ์ €, Tracking์„ ํ•˜๊ธฐ ์ „์— ์‹คํ—˜์‹ค์„ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค. ๊ทธ ์•ˆ์—์„œ ํ–‰ํ•œ ๊ฒƒ๋“ค์ด Tracking ๋œ๋‹ค๊ณ  ๋ณด๋ฉด ๋œ๋‹ค. 

 

$ export MLFLOW_EXPERIMENT_NAME=[Experiment name]
$ mlflow experiments create --experiment-name [Experiment name]

 

์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด, ์›ํ•˜๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์‹คํ—˜์‹ค์„ ๊ฐœ์„คํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  Tracking ๋˜๋Š” ๋ฐ์ดํ„ฐ๋“ค์€ /mlruns/{์‹คํ—˜์‹ค ๋ฒˆํ˜ธ}์— ์ €์žฅ๋œ๋‹ค.

 

 

 

 

base.py ํŒŒ์ผ์„ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์„œ ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์ž.

# Launch a run. The experiment is inferred from the MLFLOW_EXPERIMENT_NAME environment
# variable, or from the --experiment-name parameter passed to the MLflow CLI (the latter
# taking precedence)
with mlflow.start_run():
    mlflow.log_param("a", 1)
    mlflow.log_metric("b", 2)
$ python base_ml.py

 

 

ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋ฉด /mlruns/0/ ์— ๋ฐ์ดํ„ฐ๊ฐ€ ๊ธฐ๋ก๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

 

$ mlflow ui
INFO:waitress:Serving on http://127.0.0.1:5000

 

 

 

 

MLflow ui์—์„œ๋„ ์ž˜ Tracking ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

 

'๐Ÿ›  Data Engineering > MLOps' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[MLOps] MLflow ์‹œ์ž‘ & ๊ฐœ๋… ์ •๋ฆฌ  (0) 2022.04.14