You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/machine-learning/v1/how-to-log-view-metrics.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.reviewer: shwinne
9
9
ms.service: azure-machine-learning
10
10
ms.subservice: core
11
11
ms.custom: UpdateFrequency5, devx-track-python
12
-
ms.date: 10/26/2022
12
+
ms.date: 07/25/2025
13
13
ms.topic: how-to
14
14
---
15
15
@@ -21,7 +21,7 @@ ms.topic: how-to
21
21
22
22
Log real-time information using both the default Python logging package and Azure Machine Learning Python SDK-specific functionality. You can log locally and send logs to your workspace in the portal.
23
23
24
-
Logs can help you diagnose errors and warnings, or track performance metrics like parameters and model performance. In this article, you learn how to enable logging in the following scenarios:
24
+
Logs help you diagnose errors and warnings, and track performance metrics like parameters and model performance. In this article, you learn how to enable logging in the following scenarios:
25
25
26
26
> [!div class="checklist"]
27
27
> * Log run metrics
@@ -40,19 +40,19 @@ You can log multiple data types including scalar values, lists, tables, images,
40
40
41
41
## Logging run metrics
42
42
43
-
Use the following methods in the logging APIs to influence the metrics visualizations. Note the [service limits](../resource-limits-quotas-capacity.md#metrics) for these logged metrics.
43
+
Use the following methods in the logging APIs to influence metrics visualizations. Note the [service limits](../resource-limits-quotas-capacity.md#metrics) for these logged metrics.
44
44
45
45
|Logged Value|Example code| Format in portal|
46
46
|----|----|----|
47
47
|Log an array of numeric values|`run.log_list(name='Fibonacci', value=[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89])`|single-variable line chart|
48
-
|Log a single numeric value with the same metric name repeatedly used (like from within a for loop)|`for i in tqdm(range(-10, 10)): run.log(name='Sigmoid', value=1 / (1 + np.exp(-i))) angle = i / 2.0`| Single-variable line chart|
49
-
|Log a row with 2 numerical columns repeatedly|`run.log_row(name='Cosine Wave', angle=angle, cos=np.cos(angle)) sines['angle'].append(angle) sines['sine'].append(np.sin(angle))`|Two-variable line chart|
50
-
|Log table with 2 numerical columns|`run.log_table(name='Sine Wave', value=sines)`|Two-variable line chart|
51
-
|Log image|`run.log_image(name='food', path='./breadpudding.jpg', plot=None, description='desert')`|Use this method to log an image file or a matplotlib plot to the run. These images will be visible and comparable in the run record|
48
+
|Log a single numeric value with the same metric name repeatedly (such as from within a for loop)|`for i in tqdm(range(-10, 10)): run.log(name='Sigmoid', value=1 / (1 + np.exp(-i))) angle = i / 2.0`| Single-variable line chart|
49
+
|Log a row with two numerical columns repeatedly|`run.log_row(name='Cosine Wave', angle=angle, cos=np.cos(angle)) sines['angle'].append(angle) sines['sine'].append(np.sin(angle))`|Two-variable line chart|
50
+
|Log table with two numerical columns|`run.log_table(name='Sine Wave', value=sines)`|Two-variable line chart|
51
+
|Log image|`run.log_image(name='food', path='./breadpudding.jpg', plot=None, description='desert')`|Use this method to log an image file or a matplotlib plot to the run. These images are visible and comparable in the run record|
52
52
53
53
## Logging with MLflow
54
54
55
-
We recommend logging your models, metrics and artifacts with MLflow as it's open source and it supports local mode to cloud portability. The following table and code examples show how to use MLflow to log metrics and artifacts from your training runs.
55
+
We recommend logging your models, metrics, and artifacts with MLflow as it's open source and supports local mode to cloud portability. The following table and code examples show how to use MLflow to log metrics and artifacts from your training runs.
56
56
[Learn more about MLflow's logging methods and design patterns](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.log_artifact).
57
57
58
58
Be sure to install the `mlflow` and `azureml-mlflow` pip packages to your workspace.
|Log a numeric value (int or float) |`mlflow.log_metric('my_metric', 1)`||
83
-
|Log a boolean value |`mlflow.log_metric('my_metric', 0)`| 0 = True, 1 = False|
83
+
|Log a boolean value |`mlflow.log_metric('my_metric', 0)`| 0 = False, 1 = True|
84
84
|Log a string |`mlflow.log_text('foo', 'my_string')`| Logged as an artifact|
85
85
|Log numpy metrics or PIL image objects|`mlflow.log_image(img, 'figure.png')`||
86
-
|Log matlotlib plot or image file|`mlflow.log_figure(fig, "figure.png")`||
86
+
|Log matplotlib plot or image file|`mlflow.log_figure(fig, "figure.png")`||
87
87
88
88
## View run metrics via the SDK
89
89
You can view the metrics of a trained model using `run.get_metrics()`.
@@ -101,9 +101,9 @@ metrics.get('metric-name')
101
101
# list of metrics in the order they were recorded
102
102
```
103
103
104
-
You can also access run information using MLflow through the run object's data and info properties. See the [MLflow.entities.Run object](https://mlflow.org/docs/latest/python_api/mlflow.entities.html#mlflow.entities.Run) documentation for more information.
104
+
You can also access run information using MLflow through the run object's data and info properties. For more information, see the [MLflow.entities.Run object](https://mlflow.org/docs/latest/python_api/mlflow.entities.html#mlflow.entities.Run) documentation.
105
105
106
-
After the run completes, you can retrieve it using the MlFlowClient().
106
+
After the run completes, you can retrieve it using the MlflowClient().
> The metrics dictionary under `mlflow.entities.Run.data.metrics` only returns the most recently logged value for a given metric name. For example, if you log, in order, 1, then 2, then 3, then 4 to a metric called `sample_metric`, only 4 is present in the metrics dictionary for `sample_metric`.
126
126
>
127
-
> To get all metrics logged for a particular metric name, you can use [`MlFlowClient.get_metric_history()`](https://www.mlflow.org/docs/latest/python_api/mlflow.client.html#mlflow.client.MlflowClient.get_metric_history).
127
+
> To get all metrics logged for a particular metric name, you can use [`MlflowClient.get_metric_history()`](https://www.mlflow.org/docs/latest/python_api/mlflow.client.html#mlflow.client.MlflowClient.get_metric_history).
@@ -141,7 +141,7 @@ You can also edit the run list table to select multiple runs and display either
141
141
142
142
### View and download log files for a run
143
143
144
-
Log files are an essential resource for debugging the Azure Machine Learning workloads. After submitting a training job, drill down to a specific run to view its logs and outputs:
144
+
Log files are an essential resource for debugging Azure Machine Learning workloads. After submitting a training job, drill down to a specific run to view its logs and outputs:
145
145
146
146
1. Navigate to the **Experiments** tab.
147
147
1. Select the runID for a specific run.
@@ -153,25 +153,25 @@ Log files are an essential resource for debugging the Azure Machine Learning wor
153
153
154
154
#### user_logs folder
155
155
156
-
This folder contains information about the usergenerated logs. This folder is open by default, and the **std_log.txt** log is selected. The **std_log.txt** is where your code's logs (for example, print statements) show up. This file contains `stdout` log and `stderr` logs from your control script and training script, one per process. In the majority of cases, you will monitor the logs here.
156
+
This folder contains information about user-generated logs. This folder is open by default, and the **std_log.txt** log is selected. The **std_log.txt** is where your code's logs (for example, print statements) show up. This file contains `stdout` log and `stderr` logs from your control script and training script, one per process. In most cases, you monitor the logs here.
157
157
158
158
#### system_logs folder
159
159
160
-
This folder contains the logs generated by Azure Machine Learning and it will be closed by default. The logs generated by the system are grouped into different folders, based on the stage of the job in the runtime.
160
+
This folder contains the logs generated by Azure Machine Learning and is closed by default. The logs generated by the system are grouped into different folders, based on the stage of the job in the runtime.
161
161
162
162
#### Other folders
163
163
164
-
For jobs training on multi-compute clusters, logs are present for each node IP. The structure for each node is the same as singlenode jobs. There is one more logs folder for overall execution, stderr, and stdout logs.
164
+
For jobs that run on multi-compute clusters, logs are organized by node IP address. Each node has the same log folder structure as single-node jobs. Additionally, there's a separate logs folder that contains overall execution logs, including stderr and stdout from the entire cluster.
165
165
166
-
Azure Machine Learning logs information from various sources during training, such as AutoML or the Docker container that runs the training job. Many of these logs are not documented. If you encounter problems and contact Microsoft support, they may be able to use these logs during troubleshooting.
166
+
Azure Machine Learning logs information from various sources during training, such as AutoML or the Docker container that runs the training job. Many of these logs aren't documented. If you encounter problems and contact Microsoft support, they may be able to use these logs during troubleshooting.
167
167
168
168
## Interactive logging session
169
169
170
170
Interactive logging sessions are typically used in notebook environments. The method [Experiment.start_logging()](/python/api/azureml-core/azureml.core.experiment%28class%29#start-logging--args----kwargs-) starts an interactive logging session. Any metrics logged during the session are added to the run record in the experiment. The method [run.complete()](/python/api/azureml-core/azureml.core.run%28class%29#complete--set-status-true-) ends the sessions and marks the run as completed.
171
171
172
172
## ScriptRun logs
173
173
174
-
In this section, you learn how to add logging code inside of runs created when configured with ScriptRunConfig. You can use the [**ScriptRunConfig**](/python/api/azureml-core/azureml.core.scriptrunconfig) class to encapsulate scripts and environments for repeatable runs. You can also use this option to show a visual Jupyter Notebooks widget for monitoring.
174
+
In this section, you learn how to add logging code inside runs created when configured with ScriptRunConfig. You can use the [**ScriptRunConfig**](/python/api/azureml-core/azureml.core.scriptrunconfig) class to encapsulate scripts and environments for repeatable runs. You can also use this option to show a visual Jupyter Notebooks widget for monitoring.
175
175
176
176
This example performs a parameter sweep over alpha values and captures the results using the [run.log()](/python/api/azureml-core/azureml.core.run%28class%29#log-name--value--description----) method.
177
177
@@ -180,14 +180,14 @@ This example performs a parameter sweep over alpha values and captures the resul
The `show_output` parameter turns on verbose logging, which lets you see details from the training process as well as information about any remote resources or compute targets. Use the following code to turn on verbose logging when you submit the experiment.
190
+
The `show_output` parameter turns on verbose logging, which lets you see details from the training process and information about any remote resources or compute targets. Use the following code to turn on verbose logging when you submit the experiment.
Azure Machine Learning can also log information from other sources during training, such as automated machine learning runs, or Docker containers that run the jobs. These logs aren't documented, but if you encounter problems and contact Microsoft support, they may be able to use these logs during troubleshooting.
213
+
Azure Machine Learning can also log information from other sources during training, such as automated machine learning runs or Docker containers that run the jobs. These logs aren't documented, but if you encounter problems and contact Microsoft support, they may be able to use these logs during troubleshooting.
214
214
215
215
For information on logging metrics in Azure Machine Learning designer, see [How to log metrics in the designer](how-to-track-designer-experiments.md)
0 commit comments