Skip to content

Commit 1cb3aef

Browse files
committed
freshness pass
1 parent b07b00a commit 1cb3aef

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

articles/machine-learning/v1/how-to-log-view-metrics.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.reviewer: shwinne
99
ms.service: azure-machine-learning
1010
ms.subservice: core
1111
ms.custom: UpdateFrequency5, devx-track-python
12-
ms.date: 10/26/2022
12+
ms.date: 07/25/2025
1313
ms.topic: how-to
1414
---
1515

@@ -21,7 +21,7 @@ ms.topic: how-to
2121

2222
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.
2323

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:
2525

2626
> [!div class="checklist"]
2727
> * Log run metrics
@@ -40,19 +40,19 @@ You can log multiple data types including scalar values, lists, tables, images,
4040

4141
## Logging run metrics
4242

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.
4444

4545
|Logged Value|Example code| Format in portal|
4646
|----|----|----|
4747
|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|
5252

5353
## Logging with MLflow
5454

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.
5656
[Learn more about MLflow's logging methods and design patterns](https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.log_artifact).
5757

5858
Be sure to install the `mlflow` and `azureml-mlflow` pip packages to your workspace.
@@ -80,10 +80,10 @@ mlflow_run = mlflow.start_run()
8080
|Logged Value|Example code| Notes|
8181
|----|----|----|
8282
|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|
8484
|Log a string | `mlflow.log_text('foo', 'my_string')`| Logged as an artifact|
8585
|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")`||
8787

8888
## View run metrics via the SDK
8989
You can view the metrics of a trained model using `run.get_metrics()`.
@@ -101,9 +101,9 @@ metrics.get('metric-name')
101101
# list of metrics in the order they were recorded
102102
```
103103

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.
105105

106-
After the run completes, you can retrieve it using the MlFlowClient().
106+
After the run completes, you can retrieve it using the MlflowClient().
107107

108108
```python
109109
from mlflow.tracking import MlflowClient
@@ -124,7 +124,7 @@ params = finished_mlflow_run.data.params
124124
>[!NOTE]
125125
> 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`.
126126
>
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).
128128
129129
<a name="view-the-experiment-in-the-web-portal"></a>
130130

@@ -141,7 +141,7 @@ You can also edit the run list table to select multiple runs and display either
141141

142142
### View and download log files for a run
143143

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:
145145

146146
1. Navigate to the **Experiments** tab.
147147
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
153153

154154
#### user_logs folder
155155

156-
This folder contains information about the 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 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.
157157

158158
#### system_logs folder
159159

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.
161161

162162
#### Other folders
163163

164-
For jobs training on multi-compute clusters, logs are present for each node IP. The structure for each node is the same as single node 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.
165165

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.
167167

168168
## Interactive logging session
169169

170170
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.
171171

172172
## ScriptRun logs
173173

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.
175175

176176
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.
177177

@@ -180,14 +180,14 @@ This example performs a parameter sweep over alpha values and captures the resul
180180
[!code-python[](~/MachineLearningNotebooks/how-to-use-azureml/training/train-on-local/scripts/train.py)]
181181

182182

183-
1. Submit the ```train.py``` script to run in a user-managed environment. The entire script folder is submitted for training.
183+
1. Submit the `train.py` script to run in a user-managed environment. The entire script folder is submitted for training.
184184

185185
[!notebook-python[] (~/MachineLearningNotebooks/how-to-use-azureml/training/train-on-local/train-on-local.ipynb?name=src)]
186186

187187

188188
[!notebook-python[] (~/MachineLearningNotebooks/how-to-use-azureml/training/train-on-local/train-on-local.ipynb?name=run)]
189189

190-
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.
191191

192192
```python
193193
run = exp.submit(src, show_output=True)
@@ -210,7 +210,7 @@ logging.basicConfig(level=logging.DEBUG)
210210

211211
## Other logging sources
212212

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.
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.
214214

215215
For information on logging metrics in Azure Machine Learning designer, see [How to log metrics in the designer](how-to-track-designer-experiments.md)
216216

0 commit comments

Comments
 (0)