MLflow Projects の概要

MLflow 入門

Weston Bassler

Senior MLOps Engineer

MLflow Projects

  • 再現可能

  • 再利用可能

  • 移植可能

生産性を加速

1 unsplash.com
MLflow 入門

MLproject

project/
    MLproject
    train_model.py
    python_env.yaml
    requirements.txt

Github の Git リポジトリ

1 github.com
MLflow 入門

MLproject ファイル

  • name: - プロジェクト名

  • entry_points:

    • 実行コマンド
    • .py.sh ファイル
    • ワークフロー
  • python_env:

    • Python 環境
    • python_env.yaml

YAML

1 wikipedia.org
MLflow 入門

MLproject の例

name: salary_model

entry_points: main: command: "python train_model.py"
python_env: python_env.yaml
MLflow 入門

train_model.py

# Import libraries and modules
import mlflow
import mlflow.sklearn
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

# Training Data df = pd.read_csv('Salary_predict.csv') X = df[["experience", "age", "interview_score"]] y = df[["Salary"]] X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.7,random_state=0)
MLflow 入門

train_model.py

# Set Auto logging for Scikit-learn flavor
mlflow.sklearn.autolog()

# Train the model lr = LinearRegression() lr.fit(X_train, y_train)
MLflow 入門

python_env.yaml

python: 3.10.8

build_dependencies: - pip - setuptools - wheel
dependencies: - -r requirements.txt
MLflow 入門

requirements.txt

mlflow
scikit-learn
MLflow 入門

練習しましょう!

MLflow 入門

Preparing Video For Download...