Microsoft Azure Machine Learning Client Library for Python providing comprehensive SDK for ML workflows including job execution, pipeline components, model deployment, and AutoML capabilities
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Microsoft Azure Machine Learning Client Library for Python providing comprehensive SDK for ML workflows including job execution, pipeline components, model deployment, and AutoML capabilities. The SDK v2 introduces a unified object model that ensures consistency across different ML operations, supports local and cloud-based execution, provides built-in telemetry and monitoring, and integrates seamlessly with Azure Identity for authentication.
pip install azure-ai-mlfrom azure.ai.ml import MLClientCommon imports for working with Azure ML:
from azure.ai.ml import MLClient, command, spark, Input, Output
from azure.ai.ml import (
MpiDistribution,
PyTorchDistribution,
TensorFlowDistribution,
RayDistribution
)
from azure.ai.ml.entities import (
CommandJob,
SparkJob,
Model,
Environment,
Data,
Component,
Workspace,
BatchEndpoint,
OnlineEndpoint
)from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential
# Create ML client
ml_client = MLClient(
credential=DefaultAzureCredential(),
subscription_id="your-subscription-id",
resource_group_name="your-resource-group",
workspace_name="your-workspace"
)
# Submit a simple command job
from azure.ai.ml import command
from azure.ai.ml.entities import Environment
job = command(
code="./src",
command="python train.py --learning_rate ${{inputs.learning_rate}}",
inputs={"learning_rate": 0.01},
environment=Environment(
image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04:latest"
),
compute="cpu-cluster"
)
submitted_job = ml_client.jobs.create_or_update(job)
print(f"Job submitted: {submitted_job.name}")The Azure AI ML SDK is built around a unified object model with several key components:
command(), spark() for creating job configurationsThe SDK supports both imperative programming through direct API calls and declarative approaches through YAML-based configurations, enabling flexible workflows for different use cases.
Main client class for Azure Machine Learning operations with authentication and workspace management capabilities.
class MLClient:
def __init__(
self,
credential,
subscription_id: str = None,
resource_group_name: str = None,
workspace_name: str = None,
**kwargs
): ...Comprehensive job execution capabilities including command jobs, pipeline jobs, Spark jobs, sweep jobs for hyperparameter tuning, and AutoML jobs for automated machine learning.
def command(
*,
code: str = None,
command: str,
inputs: dict = None,
outputs: dict = None,
environment: Environment = None,
compute: str = None,
**kwargs
) -> CommandJob: ...
def spark(
*,
code: str,
entry: SparkJobEntry,
compute: str,
inputs: dict = None,
outputs: dict = None,
**kwargs
) -> SparkJob: ...
class CommandJob:
def __init__(
self,
*,
command: str,
code: str = None,
inputs: dict = None,
outputs: dict = None,
environment: Environment = None,
compute: str = None,
**kwargs
): ...Online and batch deployment capabilities for model inference with comprehensive endpoint and deployment management.
class OnlineEndpoint:
def __init__(
self,
*,
name: str,
auth_mode: str = "key",
description: str = None,
tags: dict = None,
**kwargs
): ...
class ManagedOnlineDeployment:
def __init__(
self,
*,
name: str,
endpoint_name: str,
model: Model,
environment: Environment = None,
code_configuration: CodeConfiguration = None,
instance_type: str = "Standard_DS3_v2",
instance_count: int = 1,
**kwargs
): ...Comprehensive asset management for models, data, environments, and components with versioning and lineage tracking.
class Model:
def __init__(
self,
*,
name: str,
path: str = None,
version: str = None,
description: str = None,
tags: dict = None,
**kwargs
): ...
class Data:
def __init__(
self,
*,
name: str,
path: str = None,
version: str = None,
type: str = "uri_folder",
description: str = None,
**kwargs
): ...Compute resource management including Azure ML compute clusters, compute instances, and attached compute resources.
class AmlCompute:
def __init__(
self,
*,
name: str,
type: str = "amlcompute",
size: str,
min_instances: int = 0,
max_instances: int = 1,
idle_time_before_scale_down: int = 1800,
**kwargs
): ...
class ComputeInstance:
def __init__(
self,
*,
name: str,
size: str,
**kwargs
): ...Automated machine learning capabilities for tabular data (classification, regression, forecasting), computer vision tasks (image classification, object detection), and natural language processing.
def classification(
*,
target_column_name: str,
training_data: Data,
validation_data: Data = None,
test_data: Data = None,
primary_metric: str = "accuracy",
**kwargs
) -> ClassificationJob: ...
def regression(
*,
target_column_name: str,
training_data: Data,
validation_data: Data = None,
test_data: Data = None,
primary_metric: str = "normalized_root_mean_squared_error",
**kwargs
) -> RegressionJob: ...
def forecasting(
*,
target_column_name: str,
time_column_name: str,
training_data: Data,
validation_data: Data = None,
test_data: Data = None,
primary_metric: str = "normalized_root_mean_squared_error",
**kwargs
) -> ForecastingJob: ...
def image_classification(
*,
target_column_name: str,
training_data: Data,
validation_data: Data = None,
primary_metric: str = "accuracy",
**kwargs
) -> ImageClassificationJob: ...
def text_classification(
*,
target_column_name: str,
training_data: Data,
validation_data: Data = None,
primary_metric: str = "accuracy",
**kwargs
) -> TextClassificationJob: ...Advanced hyperparameter optimization with various search spaces, sampling algorithms, and early termination policies.
class Choice:
def __init__(self, values: list): ...
class Uniform:
def __init__(self, min_value: float, max_value: float): ...
class SweepJob:
def __init__(
self,
*,
trial: CommandJob,
search_space: dict,
objective: Objective,
sampling_algorithm: SamplingAlgorithm = None,
**kwargs
): ...Workspace operations, registry management, and workspace connections for external services.
class Workspace:
def __init__(
self,
*,
name: str,
description: str = None,
tags: dict = None,
location: str = None,
**kwargs
): ...
class Registry:
def __init__(
self,
*,
name: str,
location: str,
**kwargs
): ...Note: Workspace management, pipelines/components, data management, feature store, and monitoring capabilities are also available through the MLClient operation groups. Refer to the API reference notes for complete details.
class Input:
def __init__(
self,
*,
type: str,
path: str = None,
mode: str = None,
**kwargs
): ...
class Output:
def __init__(
self,
*,
type: str,
path: str = None,
mode: str = None,
**kwargs
): ...
class SystemData:
created_at: str
created_by: str
created_by_type: str
last_modified_at: str
last_modified_by: str
last_modified_by_type: strInstall with Tessl CLI
npx tessl i tessl/pypi-azure-ai-ml