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: tutorials/ai-core-metrics/ai-core-metrics.md
+58-34Lines changed: 58 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: Log and Compare Machine Learning Model Quality in SAP AI Core
3
-
description: Explore different ways of logging model quality metrics during training and associate custom tags with the generated model for identification.
2
+
title: Generate metrics and compare models in SAP AI Core
3
+
description: Different ways of Log metrics during training and tag the generated model with the same.
This reflectsas shown in SAP AI Launchpad, Please zoom in to view.
138
+
This reflects, after execution, as shown in SAP AI Launchpad, please zoom in to view.
139
139
140
140
!
141
141
@@ -163,7 +163,7 @@ The variable `i` in is already present in your code to pass to the parameter `st
163
163
164
164
[ACCORDION-BEGIN [Step 5: ](Attach metrics to generated model)]
165
165
166
-
Add the following snippet to store metrics on step information. The parameter `value="housepricemodel"` is reference of the artifact name, which references the model that is to be stored in AWS S3. Same name (that is `housepricemodel`) to be used in your workflow.
166
+
Add the following snippet to store metrics on step information.
The parameter `value="housepricemodel"` refers to the artifact name, which references the model that will be stored in AWS S3. It is vital that the name of this parameter matches the name that you defined in your YAML workflow.
184
+
185
+
Your code should resemble:
186
+
187
+
!
188
+
183
189
This reflects as shown in SAP AI Launchpad, when executed:
184
-
!
190
+
!
185
191
186
192
[DONE]
187
193
[ACCORDION-END]
188
194
189
-
[ACCORDION-BEGIN [Step 5: ](Custom Metrics for model inspection)]
195
+
[ACCORDION-BEGIN [Step 6: ](Custom Metrics for model inspection)]
190
196
191
-
Add the following snippet to store metrics based on customized structure. The structure must be type-cast to `str` (string). Here the structure used is [**permutation feature importance**](https://scikit-learn.org/stable/modules/permutation_importance.html#permutation-importance).
192
-
The variable `r` and `feature_importances` are already created in the template code.
197
+
Add the following snippet to store metrics based on a customized structure.
The structure must be type-cast to `str` (string). Here, the structure used is [**permutation feature importance**](https://scikit-learn.org/stable/modules/permutation_importance.html#permutation-importance).
209
+
210
+
The variables `r` and `feature_importances` are already created in the starter code.
211
+
212
+
This reflects as shown in SAP AI Launchpad, when executed:
> - Indicates which feature is important relative to the model
212
-
> -How much change in "error" (loss) can be expected in prediction of the model relative to a feature
222
+
> - Indicates, for a given target, model, dataset and task, how much the model depends on a given feature.
223
+
> -Gives an empirical estimate of how much loss is attributed to the removal of a given feature.
213
224
>
214
-
> What it is not?
225
+
> What it is not:
215
226
>
216
-
> -Importance of feature in predicting relative to all the models/ dataset in general.
217
-
> -Measure of how good a feature is towards predicting the target.
227
+
> -A model, dataset or task agnostic indication of the importance of a given feature. While the method is agnostic, the results are applicable only to the specific input combination.
228
+
> -A perfectly accurate indication of the importance of a given feature for a specific prediction. While this is the goal of the method, it does not account for weaknesses in the model.
218
229
>
219
-
> Advantage in using
230
+
> Advantages:
220
231
>
221
-
> - Model agonist, global `explainability`.
222
-
> - "error" can be customized, with reference to `scikit` package implementation.
232
+
> - Model agnostic,
233
+
> - provides global `explainability` - meaning that it estimates each feature's importance to the prediction task.
234
+
> - contributes to model transparency.
235
+
> - The method or function used to measure "error" can be customized, with reference to `scikit` package implementation.
236
+
223
237
224
238
[DONE]
225
239
[ACCORDION-END]
226
240
227
241
[ACCORDION-BEGIN [Step 6: ](Tags for execution meta after training)]
228
242
229
-
Add the following snippet to tag you execution. The `tags` are customizable key-value.
243
+
Add the following snippet to tag you execution. The `tags` are customizable key-values.
Create a AI workflow file in you GitHub repository named `hello-metrics.yaml`with following snippet. Edit with you own Docker registry secret and username.
407
+
Paste the following snippet to a file named `hello-metrics.yaml`in your GitHub repository. Edit it with you own Docker registry secret and username. This file is your AI workflow file.
392
408
393
409
```YAML
394
410
apiVersion: argoproj.io/v1alpha1
@@ -444,9 +460,9 @@ spec:
444
460
[ACCORDION-END]
445
461
446
462
447
-
[ACCORDION-BEGIN [Step 8: ](Create configuration and execution)]
463
+
[ACCORDION-BEGIN [Step 9: ](Create configuration and execution)]
448
464
449
-
Create configuration using the following information. The information is taken from the workflow from previous step.
465
+
Create a configuration using the following information. The information is taken from the workflow from previous steps. For a reminder of how to create a configuration, see step 11 of [this tutorial](https://developers.sap.com/tutorials/ai-core-data.html/#).
450
466
451
467
| | Value |
452
468
| --- | --- |
@@ -457,24 +473,27 @@ Create configuration using the following information. The information is taken f
457
473
| Scenario ID | `learning-datalines`
458
474
| Executable ID | `house-metrics-train`
459
475
460
-
You can type any value for `Input Parameters` `DT_MAX_DEPTH`.
461
-
Attach your registered artifact to `Input Artifact` `housedataset`.
476
+
The value for `Input Parameters` `DT_MAX_DEPTH` is your choice. Until now, this was set using an environment variable. If no variable is specified, this parameter will continue to be defined by the environment variables.
477
+
478
+
> Information: This parameter can be defined using an integer to set a maximum depth or as `None`, which means that nodes are expanded until all leaves are single nodes, or contain all contain fewer data points than specified in the `min_samples_split samples`, if specified. For more information, see [the Scikit learn documentation](https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html\#)
462
479
463
-
Create execution from the configuration.
480
+
Attach your registered artifact to `Input Artifact`, by specifying `housedataset` for this value.
481
+
482
+
Create an execution from this configuration.
464
483
465
484
[DONE]
466
485
[ACCORDION-END]
467
486
468
-
[ACCORDION-BEGIN [Step 9: ](Retrieve metrics)]
487
+
[ACCORDION-BEGIN [Step 10: ](Retrieve metrics)]
469
488
470
489
471
490
[OPTION BEGIN [SAP AI Launchpad]]
472
491
473
-
Click on the `Metrics Resource` tab of your execution.
492
+
Navigate through `ML Operations` > `Executions` > `Metrics Resource` tab of your execution.
474
493
475
494
!
476
495
477
-
For metrics tagged with the artifact name, you can also locate in the **Models** details page of the artifact.
496
+
For metrics tagged with the artifact name, you can also locate the metrics in the **Models** details page of the artifact.
478
497
479
498
!
480
499
@@ -483,12 +502,16 @@ For metrics tagged with the artifact name, you can also locate in the **Models**
483
502
484
503
[OPTION BEGIN [Postman]]
485
504
505
+
Navigate through `AI Core` > `lm` > `metrics` > `Get metrics` and double check the `executionId`.
506
+
486
507
!
487
508
488
509
[OPTION END]
489
510
490
511
[OPTION BEGIN [SAP AI Core SDK]]
491
512
513
+
Paste and edit, and execute the following snippet:
0 commit comments