MLFぉw

pip install mlflow

mlflow server

 

import mlflow from sklearn.datasets import load_iris from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split # データの読み込み iris = load_iris() X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, random_state=42) # ランダムフォレストモデルのトレーニン with mlflow.start_run(): rf = RandomForestClassifier(n_estimators=10) rf.fit(X_train, y_train) # モデルの評価 score = rf.score(X_test, y_test) print("Accuracy: %f" % score) # MLFlowにメトリクスとパラメータを記録 mlflow.log_metric("accuracy", score) mlflow.log_param("n_estimators", 10) # MLFlowにモデルを保存 mlflow.sklearn.log_model(rf, "model")

 

http://localhost:5000にアクセスすることで、MLFlow UIにアクセスすることができます。