【问题标题】:Environment conflict within an azure ML pipelineAzure ML 管道中的环境冲突
【发布时间】:2022-10-06 20:11:50
【问题描述】:

到目前为止,我一直在 azure 上使用我的模型训练管道,没有任何问题。上周我启动它并收到有关环境版本冲突的错误。我什么都没改变,但它不再起作用了。我该如何解决这个问题?

from azureml.train.automl import automl\\nImportError: cannot import name \'automl\' from \'azureml.train.automl\'

我也开始同时收到这个警告。

WARNING:azureml.pipeline.core.run:Expected a StepRun object but received <class \'azureml.core.run.Run\'> instead.
This usually indicates a package conflict with one of the dependencies of azureml-core or azureml-pipeline-core.
Please check for package conflicts in your python environment

这是我的环境笔记本块:

from azureml.core.runconfig import RunConfiguration
from azureml.core.conda_dependencies import CondaDependencies

aml_run_config = RunConfiguration()
# Use just-specified compute target (\"cpu-cluster\")
aml_run_config.target = compute_target

# Specify CondaDependencies obj, add necessary packages
aml_run_config.environment.python.conda_dependencies = CondaDependencies.create(
    conda_packages=[\'pandas\',\'scikit-learn\',\'pyodbc\'], 
    pip_packages=[\'azureml-sdk[automl]\',\'pyarrow\', \'azureml-core>=1.42.0\', \'msrest==0.6.21\', \'xgboost\'])

我尝试更改 azureml-core、sdk、mrest 等的版本控制,但它仍然给我同样的错误。

  • 从问题来看,这似乎是警告而不是错误?
  • 第一条消息是错误,第二条是警告,但我很确定它们都是相关的。

标签: python azure azure-pipelines azure-machine-learning-studio


【解决方案1】:
from azureml.train.automl import automl

上述语法用于导入 automl。但由于版本更新,使用 Automl 功能的程序不是这样。以下两个过程是可用于替换现有工作的代码块。

from azure.ai.ml import automl, Input

上述代码块可用于检索执行 autoML 训练所需的所有特征。使用上述语法后

# training data from your local directory
my_training_data_input = Input(
    type=AssetTypes.MLTABLE, path="./data/training-mltable-folder"
)

# Remote MLTable definition
my_training_data_input  = Input(type=AssetTypes.MLTABLE, path="azureml://datastores/workspaceblobstore/paths/Classification/Train")
# note that the below is a code snippet -- you might have to modify the variable values to run it successfully
classification_job = automl.classification(
    compute=my_compute_name,
    experiment_name=my_exp_name,
    training_data=my_training_data_input,
    target_column_name="y",
    primary_metric="accuracy",
    n_cross_validations=5,
    enable_model_explainability=True,
    tags={"my_custom_tag": "My custom value"}
)

# Limits are all optional

classification_job.set_limits(
    timeout_minutes=600, 
    trial_timeout_minutes=20, 
    max_trials=5,
    enable_early_termination=True,
)

# Training properties are optional
classification_job.set_training(
    blocked_training_algorithms=["LogisticRegression"], 
    enable_onnx_compatible_models=True
)

以上是在训练模型中使用的属性。

这是实现类似工作的另一种方法。

Using AutoMLRun class can help to run the model.
from azureml.train.automl.run import AutoMLRun
   ws = Workspace.from_config()
   experiment = ws.experiments['my-experiment-name']
   automl_run = AutoMLRun(experiment, run_id = your run ID')

【讨论】:

    猜你喜欢
    • 2021-08-26
    • 2020-05-16
    • 2019-09-01
    • 1970-01-01
    • 2022-01-03
    • 1970-01-01
    • 2022-10-05
    • 2020-12-19
    • 2020-06-15
    相关资源
    最近更新 更多