简体   繁体   中英

Creating a ML Pipeline with AutoML component using Azure ML Python SDK v2

How would I create a machine learning pipeline with AutoML component using Azure Machine Learning Python SDK v2? I see that there is a way to pass in a custom user script as a component in this official guide , but I want to pass in Microsoft AutoML as a component instead.

I tried doing something like below:

...

train_component = automl.regression(
    compute=compute_target,
    experiment_name=args.experiment_name,
    training_data=Input(type="uri_folder"),
    validation_data=Input(type="uri_folder"),
    target_column_name=args.target,
    primary_metric="accuracy",
)

...

@dsl.pipeline(
    compute=args.compute_name,
    description="AutoML pipeline",
)
def automl_pipeline(
    pipeline_job_data_input,
    pipeline_job_test_size,
):
    data_prep_job = data_prep_component(
        data=pipeline_job_data_input,
        test_size=pipeline_job_test_size,
    )
    train_job = train_component(
        training_data=data_prep_job.outputs.train_data,
        validation_data=data_prep_job.outputs.test_data,
    )
    return {
        "pipeline_job_train_data": data_prep_job.outputs.train_data,
        "pipeline_job_test_data": data_prep_job.outputs.test_data,
        "pipeline_job_model": train_job.outputs.model,
    }

pipeline = automl_pipeline(
    pipeline_job_data_input=data.name,
    pipeline_job_test_size=0.2,
)
pipeline_job = ml_client.jobs.create_or_update(
    pipeline,
    experiment_name="test_pipeline",
)

But I am getting TypeError: 'RegressionJob' object is not callable error. Is this not implemented yet?

I have tried to reproduce the steps and it worked for me. Follow the below steps and instructions:

  • We need to use AutoMLStep object when we need to use AutoML as the component for the pipeline.

  • There are few steps to be followed to assign the AutoML as the component.

  • **AutoMLStep** is having the sub class called PipelineStep

  • There are few steps to be followed.

  1. Retrieve initial dataset
  • Link , refers to the code block to be used for the retrieving the initial dataset. if the dataset is not created, the following link to create azure machine learning dataset.
  1. Configure your storage and compute target
  • Link , Refers to the code block to be followed for the configurations
  1. Configure the training run
  • Link , refers to the code block to configure the model
  1. Finally preparing the data for automated machine learning. link

EDIT 2:

  1. For version 2 of python SDK the following link refers the complete procedure

Document Credits: Larry Franks and Team

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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