Skip to content

Commit 1c3c815

Browse files
updates
updates
1 parent 3787c38 commit 1c3c815

4 files changed

Lines changed: 52 additions & 50 deletions

File tree

tutorials/ai-core-code/ai-core-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ print(f"Test Data Score {test_r2_score}")
9595

9696
Create another file `requirements.txt` in the same directory. Here you will mention which python libraries are required to execute your code.
9797

98-
> **RECOMMENDED** In production you should use the terminal command `pip list --format freeze > requirements.txt` to auto generate `requirement.txt`.
98+
> **RECOMMENDED** In production you should use the terminal command `pip list --format freeze > requirements.txt` to auto generate `requirements.txt`.
9999
100100
Paste the following snippet into `requirements.txt`.
101101

tutorials/ai-core-metrics/ai-core-metrics.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
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.
2+
title: Generate Metrics and Compare Models in SAP AI Core
3+
description: Explore different ways of logging metrics during training and compare generated models.
44
auto_validation: true
55
time: 45
66
tags: [ tutorial>license, tutorial>beginner, topic>artificial-intelligence, topic>machine-learning, software-product>sap-ai-launchpad, software-product>sap-ai-core ]
@@ -10,17 +10,17 @@ author_profile: https://github.com/dhrubpaul
1010
---
1111

1212
## Prerequisites
13-
- 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/#)
1414

1515
## Details
1616
### You will learn
1717
- How to log simple metrics on validation data and training data
1818
- How to log step information along with metrics
1919
- How to log custom metrics structure
2020

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

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.
2424
2525
---
2626

@@ -100,7 +100,7 @@ pickle.dump(clf, open(MODEL_PATH, 'wb'))
100100
# <PASTE CODE HERE>
101101
```
102102

103-
> 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.
104104
105105
This Python script contains all of the modifications needed for logging metrics, meaning that you can leave your previous workflows as they are.
106106

@@ -112,8 +112,8 @@ This Python script contains all of the modifications needed for logging metrics,
112112
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.
113113

114114
```PYTHON
115-
from ai_core_sdk.ai_core_v2_client import AICoreV2Client
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.tracking import Tracking
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
117117
...
118118
```
119119

@@ -122,7 +122,7 @@ aic_connection = AICoreV2Client(base_url='') # DO NOT Change, the value is inten
122122
[DONE]
123123
[ACCORDION-END]
124124

125-
[ACCORDION-BEGIN [Step 3: ](Add Basic metric logging)]
125+
[ACCORDION-BEGIN [Step 3: ](Add basic metric logging)]
126126

127127
Add the following snippet to log the number of observations in your dataset.
128128

@@ -135,7 +135,7 @@ aic_connection.metrics.log_metrics(
135135
)
136136
```
137137

138-
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.
139139

140140
!![image](img/ail/basic.png)
141141

@@ -144,7 +144,7 @@ This reflects, after execution, as shown in SAP AI Launchpad, please zoom in to
144144

145145
[ACCORDION-BEGIN [Step 4: ](Step information)]
146146

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

149149
```PYTHON
150150
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
163163

164164
[ACCORDION-BEGIN [Step 5: ](Attach metrics to generated model)]
165165

166-
Add the following snippet to store metrics on step information.
166+
Add the following snippet to store metrics for step information.
167167

168168
```PYTHON
169169
aic_connection.metrics.log_metrics(
@@ -180,19 +180,19 @@ aic_connection.metrics.log_metrics(
180180
)
181181
```
182182

183-
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.
184184

185185
Your code should resemble:
186186

187187
!![image](img/ail/modelA.png)
188188

189-
This reflects as shown in SAP AI Launchpad, when executed:
189+
After execution, this is shown in SAP AI Launchpad.
190190
!![image](img/ail/modelB.png)
191191

192192
[DONE]
193193
[ACCORDION-END]
194194

195-
[ACCORDION-BEGIN [Step 6: ](Custom Metrics for model inspection)]
195+
[ACCORDION-BEGIN [Step 6: ](Custom metrics for model inspection)]
196196

197197
Add the following snippet to store metrics based on a customized structure.
198198

@@ -209,7 +209,7 @@ The structure must be type-cast to `str` (string). Here, the structure used is [
209209

210210
The variables `r` and `feature_importances` are already created in the starter code.
211211

212-
This reflects as shown in SAP AI Launchpad, when executed:
212+
After execution, this is shown in SAP AI Launchpad.
213213

214214
!![image](img/ail/custom.png)
215215

@@ -219,7 +219,7 @@ This reflects as shown in SAP AI Launchpad, when executed:
219219
>
220220
> What it is?
221221
>
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.
223223
> - Gives an empirical estimate of how much loss is attributed to the removal of a given feature.
224224
>
225225
> What it is not:
@@ -229,16 +229,16 @@ This reflects as shown in SAP AI Launchpad, when executed:
229229
>
230230
> Advantages:
231231
>
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,
235235
> - The method or function used to measure "error" can be customized, with reference to `scikit` package implementation.
236236
237237

238238
[DONE]
239239
[ACCORDION-END]
240240

241-
[ACCORDION-BEGIN [Step 6: ](Tags for execution meta after training)]
241+
[ACCORDION-BEGIN [Step 6: ](Add tags for execution meta after training)]
242242

243243
Add the following snippet to tag you execution. The `tags` are customizable key-values.
244244

@@ -251,14 +251,14 @@ aic_connection.metrics.set_tags(
251251
)
252252
```
253253

254-
This reflects as shown in SAP AI Launchpad, when executed:
254+
After execution, this is shown in SAP AI Launchpad.
255255

256256
!![image](img/ail/tag.png)
257257

258258
[DONE]
259259
[ACCORDION-END]
260260

261-
[ACCORDION-BEGIN [Step 7: ](Complete Files)]
261+
[ACCORDION-BEGIN [Step 7: ](Complete files)]
262262

263263
Check your modified `main.py` by comparing it with the following expected `main.py`.
264264

@@ -397,7 +397,7 @@ RUN chgrp -R 65534 /app && \
397397
chmod -R 777 /app
398398
```
399399

400-
Build your Docker image and push the contents to the cloud, using the following commands in the terminal.
400+
Use the following commands to build your Docker image and push the contents to the cloud.
401401

402402
```BASH
403403
docker build -t <YOUR_DOCKER_REGISTRY>/<YOUR_DOCKER_USERNAME>/house-price:04 .
@@ -462,7 +462,7 @@ spec:
462462
463463
[ACCORDION-BEGIN [Step 9: ](Create configuration and execution)]
464464
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/#).
466466
467467
| | Value |
468468
| --- | --- |
@@ -475,7 +475,7 @@ Create a configuration using the following information. The information is taken
475475

476476
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.
477477

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).
479479

480480
Attach your registered artifact to `Input Artifact`, by specifying `housedataset` for this value.
481481

@@ -489,11 +489,11 @@ Create an execution from this configuration.
489489

490490
[OPTION BEGIN [SAP AI Launchpad]]
491491

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

494494
!![image](img/ail/locate.png)
495495

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

498498
!![image](img/ail/artifact.png)
499499

@@ -510,7 +510,7 @@ Navigate through `AI Core` > `lm` > `metrics` > `Get metrics` and double check t
510510

511511
[OPTION BEGIN [SAP AI Core SDK]]
512512

513-
Paste and edit, and execute the following snippet:
513+
Paste and edit, then execute the following snippet:
514514

515515
```PYTHON
516516
response = ai_core_client.metrics.query(
@@ -575,7 +575,7 @@ Create two configurations: one with `DT_MAX_DEPTH = 3` and another with `DT_MAX_
575575
576576
!![image](img/ail/compare-1.png)
577577
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.
579579
580580
!![image](img/ail/compare-2.png)
581581

tutorials/ai-core-post-metrics/ai-core-post-metrics.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@ author_profile: https://github.com/dhrubpaul
1515

1616
## Details
1717
### You will learn
18-
- 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
1919

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 batch inferencing 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.
2121

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

2424
---
2525

2626
[ACCORDION-BEGIN [Step 1: ](Create client)]
2727

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

3030
```BASH
3131
pip install ai-core-sdk
3232
```
3333

3434
!![install using pip](img/acs/pip-install.png)
3535

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

3838
```PYTHON[5, 7, 9, 11]
39-
from ai_core_sdk.ai_core_v2_client import AICoreV2Client
39+
from ai_core_sdk.tracking import Tracking
4040
41-
ai_core_client = AICoreV2Client(
41+
tracking_client = Tracking(
4242
# `AI_API_URL`
4343
base_url = "https://api.ai.ml.hana.ondemand.com" + "/v2", # The present SAP AI Core API version is 2
4444
# `URL`
@@ -58,7 +58,7 @@ ai_core_client = AICoreV2Client(
5858

5959
[ACCORDION-BEGIN [Step 2: ](List executions)]
6060

61-
List all executions of your **resource group**.
61+
List all executions for your **resource group**.
6262

6363
Change the `resource_group` and execute.
6464

@@ -127,7 +127,7 @@ for execution in response.resources:
127127

128128
!![View Tags](img/acs/3.png)
129129

130-
Alternatively, view over SAP AI Launchpad.
130+
Alternatively, you can view the tags using SAP AI Launchpad.
131131

132132
!![View Tags](img/ail/3.png)
133133

@@ -136,7 +136,7 @@ Alternatively, view over SAP AI Launchpad.
136136

137137
[ACCORDION-BEGIN [Step 4: ](Add basic metric)]
138138

139-
A basic metric will have a **name**, **value** and **timestamp**.
139+
A basic metric has a **name**, **value** and **timestamp**.
140140

141141
Example usage of **step** and **labels** are explained in other steps.
142142

@@ -162,9 +162,9 @@ ai_core_client.metrics.modify(
162162
)
163163
```
164164

165-
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.
166166

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

169169
View stored metrics.
170170

@@ -189,7 +189,7 @@ for execution in response.resources:
189189

190190
!![img](img/acs/4.png)
191191

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

194194
!![View Tags](img/ail/4.png)
195195

@@ -200,7 +200,7 @@ Alternatively, view over SAP AI Launchpad. The **Timestamp** is always converted
200200

201201
Use the **step** parameter, although the metric **name** will remain same.
202202

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

205205
Change the `execution_id` and execute.
206206

@@ -266,7 +266,7 @@ Alternatively, view over SAP AI Launchpad.
266266

267267
[ACCORDION-BEGIN [Step 6: ](Add custom metrics information)]
268268

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

271271
Change the `execution_id` and execute.
272272

@@ -322,7 +322,7 @@ for execution in response.resources:
322322

323323
!![img](img/acs/6.png)
324324

325-
Alternatively, view over SAP AI Launchpad.
325+
Alternatively, you can view the metric data using SAP AI Launchpad.
326326

327327
!![View Tags](img/ail/6.png)
328328

@@ -332,9 +332,9 @@ Alternatively, view over SAP AI Launchpad.
332332

333333
[ACCORDION-BEGIN [Step 7: ](Store visualization)]
334334

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

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.
338338
339339
Change the `execution_id` and execute.
340340

tutorials/ai-core-tensorflow-byod/ai-core-tensorflow-byod.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ for rg in response.resources:
6767
[ACCORDION-END]
6868

6969

70-
[ACCORDION-BEGIN [Step 3: ](Upload model files to AWS S3)]
70+
[ACCORDION-BEGIN [Step 2: ](Upload model files to AWS S3)]
7171

7272
1. Install the AWS CLI client. [Download here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html).
7373

@@ -156,6 +156,8 @@ You should see the following response:
156156

157157
!![img](img/acs/3.png)
158158

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)
160+
159161
[DONE]
160162
[ACCORDION-END]
161163

0 commit comments

Comments
 (0)