繁体   English   中英

如何修复 MLflow UI 中未显示的工件

[英]How to fix Artifacts not showing in MLflow UI

我使用了 MLflow 并使用下面的 function(来自 pydataberlin)记录了参数。

def train(alpha=0.5, l1_ratio=0.5):
    # train a model with given parameters
    warnings.filterwarnings("ignore")
    np.random.seed(40)

    # Read the wine-quality csv file (make sure you're running this from the root of MLflow!)
    data_path = "data/wine-quality.csv"
    train_x, train_y, test_x, test_y = load_data(data_path)

    # Useful for multiple runs (only doing one run in this sample notebook)    
    with mlflow.start_run():
        # Execute ElasticNet
        lr = ElasticNet(alpha=alpha, l1_ratio=l1_ratio, random_state=42)
        lr.fit(train_x, train_y)

        # Evaluate Metrics
        predicted_qualities = lr.predict(test_x)
        (rmse, mae, r2) = eval_metrics(test_y, predicted_qualities)

        # Print out metrics
        print("Elasticnet model (alpha=%f, l1_ratio=%f):" % (alpha, l1_ratio))
        print("  RMSE: %s" % rmse)
        print("  MAE: %s" % mae)
        print("  R2: %s" % r2)

        # Log parameter, metrics, and model to MLflow
        mlflow.log_param(key="alpha", value=alpha)
        mlflow.log_param(key="l1_ratio", value=l1_ratio)
        mlflow.log_metric(key="rmse", value=rmse)
        mlflow.log_metrics({"mae": mae, "r2": r2})
        mlflow.log_artifact(data_path)
        print("Save to: {}".format(mlflow.get_artifact_uri()))
        
        mlflow.sklearn.log_model(lr, "model")

一旦我使用它的参数运行train() ,在 UI 中我看不到工件,但我可以看到模型及其参数和指标。

在 artifact 选项卡中写着No Artifacts Recorded Use the log artifact APIs to store file outputs from MLflow runs. 但是在模型文件夹中的查找器中,所有工件都与模型 Pickle 一起存在。

帮助

有类似的问题。 就我而言,我通过在实验的mlruns目录中运行mlflow ui解决了这个问题。

此处查看有关 Github 的完整讨论

希望能帮助到你!

这段代码不是在本地运行吗? 您是否正在移动 mlruns 文件夹? 我建议检查 meta.yaml 文件中存在的工件 URI。 如果那里的路径不正确,则可能会出现此类问题。

我有同样的问题(对于mlflow.pytorch )。 对我来说,它是通过替换log_model()log_atrifacts()来修复的。

所以记录工件的是:

mlflow.log_metric("metric name", [metric value])
mlflow.pytorch.log_model(model, "model")
mlflow.log_artifacts(output_dir)

此外,对于终端中的ui ,cd 到mlruns所在的目录。 例如,如果mlruns的位置是...\your-project\mlruns

cd ...\your-project

go 到安装mlflow的环境。

...\your-project> conda activate [myenv]

然后,运行mlflow ui

(myenv) ...\your-project> mlflow ui

我有一个类似的问题。 更改脚本文件夹后,我的 UI 没有显示新的运行。

对我有用的解决方案是在启动新 UI 之前停止所有 MLflow UI,以防您更改文件夹。

我在运行 mlflow 服务器并在 S3 中存储工件时遇到了这个问题。 能够通过安装boto3来修复

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM