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
- You have the knowledge on ingesting data and generating models with SAP AI Core, from [this tutorial](https://developers.sap.com/tutorials/ai-core-data.html/#)
13
+
- You have an understanding of using data and generating models in SAP AI Core, from [this tutorial](https://developers.sap.com/tutorials/ai-core-data.html/#)
14
14
15
15
## Details
16
16
### You will learn
17
17
- How to log simple metrics on validation data and training data
18
18
- How to log step information along with metrics
19
19
- How to log custom metrics structure
20
20
21
-
By the end of the tutorial you will be able to use SAP AI Launchpad to compare two models that have been generated with SAP AI Core. This tutorial builds on the previous tutorials on house price prediction and ingesting data.
21
+
In this tutorial, you will use SAP AI Launchpad to compare two models that have been generated using SAP AI Core. This tutorial builds on the previous tutorials on house price prediction and ingesting data.
22
22
23
-
> Important: Comparing functionality is only available the SAP AI Launchpad interface, and not the API endpoints. However, this step is optional.
23
+
> Important: Comparing models is only available using SAP AI Launchpad, and not the API endpoints. The comparison step is optional.
> Note that the snippet includes some place holders that say `# <PASTE CODE HERE>`. We complete these entries throughout the tutorial. For clarity, the comments in the code also include the relevant step number.
103
+
> The snippet includes some placeholders that say `# <PASTE CODE HERE>`. We complete these entries throughout the tutorial. For clarity, the comments in the code also include the relevant step number.
104
104
105
105
This Python script contains all of the modifications needed for logging metrics, meaning that you can leave your previous workflows as they are.
106
106
@@ -112,8 +112,8 @@ This Python script contains all of the modifications needed for logging metrics,
112
112
Add the following connection snippet. The initialization value of `base_url=''` - an empty string - is mandatory, as it indicates the code should be connected to the SAP AI Core environment.
113
113
114
114
```PYTHON
115
-
from ai_core_sdk.ai_core_v2_clientimportAICoreV2Client
116
-
aic_connection =AICoreV2Client(base_url='') # DO NOT Change, the value is intentionally passed as empty string, When this code will run inside SAP AI Core then the values will be auto-populated
115
+
from ai_core_sdk.trackingimportTracking
116
+
aic_connection =Tracking(base_url='') # DO NOT Change, the value is intentionally passed as empty string, When this code will run inside SAP AI Core then the values will be auto-populated
117
117
...
118
118
```
119
119
@@ -122,7 +122,7 @@ aic_connection = AICoreV2Client(base_url='') # DO NOT Change, the value is inten
This reflects, after execution, as shown in SAP AI Launchpad, please zoom in to view.
138
+
After execution, this is shown in SAP AI Launchpad. You can zoom in for details.
139
139
140
140
!
141
141
@@ -144,7 +144,7 @@ This reflects, after execution, as shown in SAP AI Launchpad, please zoom in to
144
144
145
145
[ACCORDION-BEGIN [Step 4: ](Step information)]
146
146
147
-
Add the following snippet to store the metrics on step information. This snippet is also useful for tracking the metrics on epochs of the training process.
147
+
Add the following snippet to store metrics for step information. This snippet is also useful for tracking the metrics on epochs of the training process.
148
148
149
149
```PYTHON
150
150
aic_connection.metrics.log_metrics(
@@ -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.
166
+
Add the following snippet to store metrics for 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.
183
+
The parameter `value="housepricemodel"` refers to the artifact name, which references the model that will be stored in AWS S3. The name of this parameter must match the name that you defined in your YAML workflow.
184
184
185
185
Your code should resemble:
186
186
187
187
!
188
188
189
-
This reflects as shown in SAP AI Launchpad, when executed:
189
+
After execution, this is shown in SAP AI Launchpad.
190
190
!
191
191
192
192
[DONE]
193
193
[ACCORDION-END]
194
194
195
-
[ACCORDION-BEGIN [Step 6: ](Custom Metrics for model inspection)]
195
+
[ACCORDION-BEGIN [Step 6: ](Custom metrics for model inspection)]
196
196
197
197
Add the following snippet to store metrics based on a customized structure.
198
198
@@ -209,7 +209,7 @@ The structure must be type-cast to `str` (string). Here, the structure used is [
209
209
210
210
The variables `r` and `feature_importances` are already created in the starter code.
211
211
212
-
This reflects as shown in SAP AI Launchpad, when executed:
212
+
After execution, this is shown in SAP AI Launchpad.
213
213
214
214
!
215
215
@@ -219,7 +219,7 @@ This reflects as shown in SAP AI Launchpad, when executed:
219
219
>
220
220
> What it is?
221
221
>
222
-
> - Indicates, for a given target, model, dataset and task, how much the model depends on a given feature.
222
+
> - Indicates for a given target, model, dataset and task, how much the model depends on a given feature.
223
223
> - Gives an empirical estimate of how much loss is attributed to the removal of a given feature.
224
224
>
225
225
> What it is not:
@@ -229,16 +229,16 @@ This reflects as shown in SAP AI Launchpad, when executed:
229
229
>
230
230
> Advantages:
231
231
>
232
-
> - Model agnostic,
233
-
> -provides global `explainability` - meaning that it estimates each feature's importance to the prediction task.
234
-
> -contributes to model transparency.
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
235
> - The method or function used to measure "error" can be customized, with reference to `scikit` package implementation.
236
236
237
237
238
238
[DONE]
239
239
[ACCORDION-END]
240
240
241
-
[ACCORDION-BEGIN [Step 6: ](Tags for execution meta after training)]
241
+
[ACCORDION-BEGIN [Step 6: ](Add tags for execution meta after training)]
242
242
243
243
Add the following snippet to tag you execution. The `tags` are customizable key-values.
[ACCORDION-BEGIN [Step 9: ](Create configuration and execution)]
464
464
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/#).
465
+
Create a configuration using the following values. The values are taken from the workflow from previous steps. For help creating a configuration, see step 11 of [this tutorial](https://developers.sap.com/tutorials/ai-core-data.html/#).
466
466
467
467
| | Value |
468
468
| --- | --- |
@@ -475,7 +475,7 @@ Create a configuration using the following information. The information is taken
475
475
476
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
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)
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).
479
479
480
480
Attach your registered artifact to `Input Artifact`, by specifying `housedataset` for this value.
481
481
@@ -489,11 +489,11 @@ Create an execution from this configuration.
489
489
490
490
[OPTION BEGIN [SAP AI Launchpad]]
491
491
492
-
Navigate through `ML Operations` > `Executions` > `Metrics Resource` tab of your execution.
492
+
In the `ML Operations` app, choose `Executions`. Navigate to your execution and choose the `Metrics Resource` tab.
493
493
494
494
!
495
495
496
-
For metrics tagged with the artifact name, you can also locate the metrics 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 for the artifact.
497
497
498
498
!
499
499
@@ -510,7 +510,7 @@ Navigate through `AI Core` > `lm` > `metrics` > `Get metrics` and double check t
510
510
511
511
[OPTION BEGIN [SAP AI Core SDK]]
512
512
513
-
Paste and edit, and execute the following snippet:
513
+
Paste and edit, then execute the following snippet:
514
514
515
515
```PYTHON
516
516
response = ai_core_client.metrics.query(
@@ -575,7 +575,7 @@ Create two configurations: one with `DT_MAX_DEPTH = 3` and another with `DT_MAX_
575
575
576
576
!
577
577
578
-
You can then get a metric wise comparison of the executions from the two different configurations.
578
+
You can then compare metrics for the executions using two different configurations.
- How to store model accuracy using Postman or Python in SAP AI Core
18
+
- How to store model accuracy data using Postman or Python in SAP AI Core
19
19
20
-
Using **Execution** in SAP AI Core, you can train a ML model and even do batch-inferencing on data. In this tutorial you will learn to store the model performance indicators after the execution has been completed. The steps demonstrated help you store any type of indicators, accuracy, mean-squared-loss or even your own custom information about the execution.
20
+
In SAP AI Core, you use an **Execution** to train an ML model and even do batchinferencing on data. In this tutorial, you will learn to store the performance indicators for a model after the execution has been completed. The steps demonstrate how to store any type of indicator, such as accuracy, mean-squared-loss, or your own custom information about the execution.
21
21
22
-
All the steps demonstrated here, will only send request to SAP AI Core from your local system to store metrics about an execution. Hence needs to be performed after your execution has been completed.
22
+
The steps demonstrated in the tutorial, send requests to store metrics about an execution from your local system to SAP AI Core. Therefore, these steps need to be performed after the execution is completed.
23
23
24
24
---
25
25
26
26
[ACCORDION-BEGIN [Step 1: ](Create client)]
27
27
28
-
Install `SAP AI Core SDK` to use APIs available for using SAP AI Core functionalities.
28
+
Install `SAP AI Core SDK` to use APIs available for SAP AI Core functions.
29
29
30
30
```BASH
31
31
pip install ai-core-sdk
32
32
```
33
33
34
34
!
35
35
36
-
Replace with your SAP AI Core credentials and execute. This creates client to make API call to SAP AI Core.
36
+
Replace with your SAP AI Core credentials and execute. This creates a client to make API calls to SAP AI Core.
37
37
38
38
```PYTHON[5, 7, 9, 11]
39
-
from ai_core_sdk.ai_core_v2_client import AICoreV2Client
39
+
from ai_core_sdk.tracking import Tracking
40
40
41
-
ai_core_client = AICoreV2Client(
41
+
tracking_client = Tracking(
42
42
# `AI_API_URL`
43
43
base_url = "https://api.ai.ml.hana.ondemand.com" + "/v2", # The present SAP AI Core API version is 2
The code creates an object of class **Metric** with name of a metric as`Accuracy`. Then passes this object to `metric` parameter of metric of the `.metrics.modify` function to update metrics information in your SAP AI Core instance.
165
+
The code creates an object of class **Metric** with metric name of `Accuracy`. Then passes this object to `metric` parameter of metric of the `.metrics.modify` function to update metrics information in your SAP AI Core instance.
166
166
167
-
You may either supply list of multiple metrics in a single function call or in separate function calls, in all cases the update will append over existing metrics information.
167
+
You may either supply a list of multiple metrics in a single function call or in separate function calls. In either case, the update will append over existing metrics information.
168
168
169
169
View stored metrics.
170
170
@@ -189,7 +189,7 @@ for execution in response.resources:
189
189
190
190
!
191
191
192
-
Alternatively, view over SAP AI Launchpad. The **Timestamp** is always converted to local time of the user.
192
+
Alternatively, check the metric data using SAP AI Launchpad. The **Timestamp** is always converted to the local time of the user.
193
193
194
194
!
195
195
@@ -200,7 +200,7 @@ Alternatively, view over SAP AI Launchpad. The **Timestamp** is always converted
200
200
201
201
Use the **step** parameter, although the metric **name** will remain same.
202
202
203
-
You may call the function `ai_core_client.metrics.modify` multiple times after each training epoch, each call will be appended new metrics to previous information.
203
+
You may call the function `ai_core_client.metrics.modify` multiple times after each training epoch, each call will append new metrics to previous information.
204
204
205
205
Change the `execution_id` and execute.
206
206
@@ -266,7 +266,7 @@ Alternatively, view over SAP AI Launchpad.
Any Custom information structure stored as **Character Large Object (CLOB)** and hence must be converted to string `str` type while passing as argument to function call. Here you will store and retrieve a snippet of [classification report](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html) for your model.
269
+
Any custom information structure stored as **Character Large Object (CLOB)** and hence must be converted to string `str` type while passing as argument to function call. Here you will store and retrieve a snippet of [classification report](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html) for your model.
270
270
271
271
Change the `execution_id` and execute.
272
272
@@ -322,7 +322,7 @@ for execution in response.resources:
322
322
323
323
!
324
324
325
-
Alternatively, view over SAP AI Launchpad.
325
+
Alternatively, you can view the metric data using SAP AI Launchpad.
326
326
327
327
!
328
328
@@ -332,9 +332,9 @@ Alternatively, view over SAP AI Launchpad.
332
332
333
333
[ACCORDION-BEGIN [Step 7: ](Store visualization)]
334
334
335
-
This step is similar to storing custom metric information. Here you will generate a demo visualization, save visualization locally in **Portable Network Graphics (PNG)** format, which you will load (as bytes) and encode to base64 then convert to string to store it SAP AI Core.
335
+
This step is similar to storing custom metric information. Here you will generate a demo visualization, save the visualization locally in **Portable Network Graphics (PNG)** format, which you will load (as bytes) and encode to base64 then convert to string to store it SAP AI Core.
336
336
337
-
> TIP: Another approach is to store visualization locally in **Scalable Vector Graphics (SVG)** format. The default read format for SVG (in python) is string which is the required format for storing custom metrics in SAP AI Core. Advantage of SVG image is it can be scaled (zoom) without observing blur effect.
337
+
> TIP: Another approach is to store the visualization locally in **Scalable Vector Graphics (SVG)** format. The default read format for SVG (in python) is string which is the required format for storing custom metrics in SAP AI Core. The advantage of SVG images is that they can be scaled (zoom) without a blur effect.
Copy file name to clipboardExpand all lines: tutorials/ai-core-tensorflow-byod/ai-core-tensorflow-byod.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ for rg in response.resources:
67
67
[ACCORDION-END]
68
68
69
69
70
-
[ACCORDION-BEGIN [Step 3: ](Upload model files to AWS S3)]
70
+
[ACCORDION-BEGIN [Step 2: ](Upload model files to AWS S3)]
71
71
72
72
1. Install the AWS CLI client. [Download here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
73
73
@@ -156,6 +156,8 @@ You should see the following response:
156
156
157
157
!
158
158
159
+
> Note that depending on your region, your AWS endpoint syntax may differ from the example above. In the event of an error, try this step again with alternative syntax. For available syntaxes, please see the [AWS documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteEndpoints.html)
0 commit comments