AutoMLRun Class

Represents an automated ML experiment run in Azure Machine Learning.

The AutoMLRun class can be used to manage a run, check run status, and retrieve run details once an AutoML run is submitted. For more information on working with experiment runs, see the Run class.

Inheritance
AutoMLRun

Constructor

AutoMLRun(experiment, run_id, **kwargs)

Parameters

experiment
Experiment

The experiment associated with the run.

run_id
str

The ID of the run.

Remarks

An AutoMLRun object is returned when you use the azureml.core.Experiment.submit method of an experiment.

To retrieve a run that has already started, use the following code:


   from azureml.train.automl.run import AutoMLRun
   ws = Workspace.from_config()
   experiment = ws.experiments['my-experiment-name']
   automl_run = AutoMLRun(experiment, run_id = 'AutoML_9fe201fe-89fd-41cc-905f-2f41a5a98883')

Methods

cancel

Cancel an AutoML run.

Return True if the AutoML run was canceled successfully.

cancel_iteration

Cancel a particular child run.

complete

Complete an AutoML Run.

continue_experiment

Continue an existing AutoML experiment.

fail

Fail an AutoML Run.

Optionally set the Error property of the run with a message or exception passed to error_details.

get_best_child

Return the child run with the best score for this AutoML Run.

get_guardrails

Print and return detailed results from running Guardrail verification.

get_output

Return the run with the corresponding best pipeline that has already been tested.

If no input parameters are provided, get_output returns the best pipeline according to the primary metric. Alternatively, you can use either the iteration or metric parameter to retrieve a particular iteration or the best run per provided metric, respectively.

get_run_sdk_dependencies

Get the SDK run dependencies for a given run.

pause

Return True if the AutoML run was paused successfully.

This method is not implemented.

register_model

Register the model with AzureML ACI service.

resume

Return True if the AutoML run was resumed successfully.

This method is not implemented.

retry

Return True if the AutoML run was retried successfully.

This method is not implemented.

summary

Get a table containing a summary of algorithms attempted and their scores.

wait_for_completion

Wait for the completion of this run.

Returns the status object after the wait.

cancel

Cancel an AutoML run.

Return True if the AutoML run was canceled successfully.

cancel()

Returns

None

cancel_iteration

Cancel a particular child run.

cancel_iteration(iteration)

Parameters

iteration
int

The iteration to cancel.

Returns

None

complete

Complete an AutoML Run.

complete(**kwargs)

Returns

None

continue_experiment

Continue an existing AutoML experiment.

continue_experiment(X=None, y=None, sample_weight=None, X_valid=None, y_valid=None, sample_weight_valid=None, data=None, label=None, columns=None, cv_splits_indices=None, spark_context=None, experiment_timeout_hours=None, experiment_exit_score=None, iterations=None, show_output=False, training_data=None, validation_data=None, **kwargs)

Parameters

X
DataFrame or ndarray or Dataflow
default value: None

Training features.

y
DataFrame or ndarray or Dataflow
default value: None

Training labels.

sample_weight
DataFrame or ndarray or Dataflow
default value: None

Sample weights for training data.

X_valid
DataFrame or ndarray or Dataflow
default value: None

Validation features.

y_valid
DataFrame or ndarray or Dataflow
default value: None

Validation labels.

sample_weight_valid
DataFrame or ndarray or Dataflow
default value: None

validation set sample weights.

data
DataFrame
default value: None

Training features and label.

label
str
default value: None

Label column in data.

columns
list(str)
default value: None

A list of allowed columns in the data to use as features.

cv_splits_indices
ndarray
default value: None

Indices where to split training data for cross validation. Each row is a separate cross fold and within each crossfold, provide 2 arrays, the first with the indices for samples to use for training data and the second with the indices to use for validation data. i.e [[t1, v1], [t2, v2], ...] where t1 is the training indices for the first cross fold and v1 is the validation indices for the first cross fold.

spark_context
<xref:SparkContext>
default value: None

Spark context, only applicable when used inside azure databricks/spark environment.

experiment_timeout_hours
float
default value: None

How many additional hours to run this experiment for.

experiment_exit_score
int
default value: None

If specified indicates that the experiment is terminated when this value is reached.

iterations
int
default value: None

How many additional iterations to run for this experiment.

show_output
bool
default value: False

Flag indicating whether to print output to console.

training_data
Dataflow or DataFrame
default value: None

Input training data.

validation_data
Dataflow or DataFrame
default value: None

Validation data.

Returns

The AutoML parent run.

Return type

Exceptions

fail

Fail an AutoML Run.

Optionally set the Error property of the run with a message or exception passed to error_details.

fail(error_details=None, error_code=None, _set_status=True, **kwargs)

Parameters

error_details
str or BaseException
default value: None

Optional details of the error.

error_code
str
default value: None

Optional error code of the error for the error classification.

_set_status
bool
default value: True

Indicates whether to send the status event for tracking.

get_best_child

Return the child run with the best score for this AutoML Run.

get_best_child(metric: typing.Union[str, NoneType] = None, onnx_compatible: bool = False, **kwargs: typing.Any) -> azureml.core.run.Run

Parameters

metric
str

The metric to use to when selecting the best run to return. Defaults to the primary metric.

onnx_compatible

Whether to only return runs that generated onnx models.

kwargs

Returns

AutoML Child Run.

get_guardrails

Print and return detailed results from running Guardrail verification.

get_guardrails(to_console: bool = True) -> typing.Dict[str, typing.Any]

Parameters

to_console
bool

Indicates whether to write the verification results to the console.

Returns

A dictionary of verifier results.

Return type

Exceptions

get_output

Return the run with the corresponding best pipeline that has already been tested.

If no input parameters are provided, get_output returns the best pipeline according to the primary metric. Alternatively, you can use either the iteration or metric parameter to retrieve a particular iteration or the best run per provided metric, respectively.

get_output(iteration: typing.Union[int, NoneType] = None, metric: typing.Union[str, NoneType] = None, return_onnx_model: bool = False, return_split_onnx_model: typing.Union[azureml.automl.core.onnx_convert.onnx_convert_constants.SplitOnnxModelName, NoneType] = None, **kwargs: typing.Any) -> typing.Tuple[azureml.core.run.Run, typing.Any]

Parameters

iteration
int

The iteration number of the corresponding run and fitted model to return.

metric
str

The metric to use to when selecting the best run and fitted model to return.

return_onnx_model
bool

This method will return the converted ONNX model if the enable_onnx_compatible_models parameter was set to True in the AutoMLConfig object.

return_split_onnx_model
SplitOnnxModelName

The type of the split onnx model to return

Returns

The run, the corresponding fitted model.

Return type

Run, <xref:Model>

Exceptions

Remarks

If you'd like to inspect the preprocessor(s) and algorithm (estimator) used, you can do so through Model.steps, similar to sklearn.pipeline.Pipeline.steps. For instance, the code below shows how to retrieve the estimator.


   best_run, model = parent_run.get_output()
   estimator = model.steps[-1]

get_run_sdk_dependencies

Get the SDK run dependencies for a given run.

get_run_sdk_dependencies(iteration=None, check_versions=True, **kwargs)

Parameters

iteration
int
default value: None

The iteration number of the fitted run to be retrieved. If None, retrieve the parent environment.

check_versions
bool
default value: True

If True, check the versions with current environment. If False, pass.

Returns

The dictionary of dependencies retrieved from RunHistory.

Return type

Exceptions

pause

Return True if the AutoML run was paused successfully.

This method is not implemented.

pause()

Exceptions

register_model

Register the model with AzureML ACI service.

register_model(model_name=None, description=None, tags=None, iteration=None, metric=None)

Parameters

model_name
str
default value: None

The name of the model being deployed.

description
str
default value: None

The description for the model being deployed.

tags
dict
default value: None

Tags for the model being deployed.

iteration
int
default value: None

Override for which model to deploy. Deploys the model for a given iteration.

metric
str
default value: None

Override for which model to deploy. Deploys the best model for a different metric.

Returns

The registered model object.

Return type

<xref:Model>

resume

Return True if the AutoML run was resumed successfully.

This method is not implemented.

resume()

retry

Return True if the AutoML run was retried successfully.

This method is not implemented.

retry()

Exceptions

summary

Get a table containing a summary of algorithms attempted and their scores.

summary()

Returns

Pandas DataFrame containing AutoML model statistics.

Return type

wait_for_completion

Wait for the completion of this run.

Returns the status object after the wait.

wait_for_completion(show_output=False, wait_post_processing=False)

Parameters

show_output
bool
default value: False

Indicates whether to show the run output on sys.stdout.

wait_post_processing
bool
default value: False

Indicates whether to wait for the post processing to complete after the run completes.

Returns

The status object.

Return type

Exceptions

Attributes

run_id

Return the run ID of the current run.

Returns

The run ID of the current run.

Return type

str