Download metrics of a job python sdk v2

Tadikonda Tarun HYD DIWID23 20 Reputation points
2024-02-21T12:00:50.8533333+00:00

How to get the data of the metrics logged by a job using python sdk v2

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,339 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 33,631 Reputation points Volunteer Moderator
    2024-02-21T13:16:30.8466667+00:00

    Based on the documentation, you need to authenticate first then you can retrieve the job using its ID and then access the logged metrics :

    from azure.ai.ml import MLClient
    from azure.identity import DefaultAzureCredential
    
    # Use DefaultAzureCredential for authentication
    credential = DefaultAzureCredential()
    
    # Your subscription ID, resource group, and workspace name
    subscription_id = 'your-subscription-id'
    resource_group = 'your-resource-group'
    workspace_name = 'your-workspace-name'
    
    # Create MLClient
    ml_client = MLClient(credential, subscription_id, resource_group, workspace_name)
    job_name = 'your-job-name'
    # Retrieve the job
    job = ml_client.jobs.get(name=job_name)
    # Access the metrics logged by the job
    metrics = job.outputs.get('logs') or job.outputs.get('metrics')
    if metrics:
        print(metrics)
    else:
        print("No metrics found for job:", job_name)
    
    
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.