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
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.
21
+
In this tutorial, you'll 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
23
> Important: Comparing models is only available using SAP AI Launchpad, and not the API endpoints. The comparison step is optional.
> 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.
103
+
> The snippet includes some placeholders that state`# <PASTE CODE HERE>`. You'll 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
@@ -109,15 +109,15 @@ This Python script contains all of the modifications needed for logging metrics,
109
109
110
110
[ACCORDION-BEGIN [Step 2: ](Add connection)]
111
111
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.
112
+
Add the following code snippet.
113
113
114
114
```PYTHON
115
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
116
+
aic_connection = Tracking()
117
117
...
118
118
```
119
119
120
-
> **CAUTION**: The above code is very similar to the code used to connect the SAP AI Core SDK to your local system. However, here it is required to establish connection within the SAP AI Core execution environment.
120
+
> **CAUTION**: This code snippet is very similar to the code used to connect the SAP AI Core SDK to your local system. However, in this case, it is required to establish a connection within the SAP AI Core execution environment.
121
121
122
122
[DONE]
123
123
[ACCORDION-END]
@@ -127,7 +127,8 @@ aic_connection = Tracking(base_url='') # DO NOT Change, the value is intentional
127
127
Add the following snippet to log the number of observations in your dataset.
@@ -147,14 +148,14 @@ After execution, this is shown in SAP AI Launchpad. You can zoom in for details.
147
148
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.
The variable `i` in is already present in your code to pass to the parameter `step=i`. This reflects as shown in SAP AI Launchpad, when executed. Please zoom in to view.
158
+
The variable `i` in is already present in your code to pass to the parameter `step=i`. This is also shown in SAP AI Launchpad. You can zoom in to view.
158
159
159
160
!
160
161
@@ -166,7 +167,7 @@ The variable `i` in is already present in your code to pass to the parameter `st
166
167
Add the following snippet to store metrics for step information.
167
168
168
169
```PYTHON
169
-
aic_connection.metrics.log_metrics(
170
+
aic_connection.log_metrics(
170
171
metrics= [
171
172
Metric(
172
173
name="Test data R2",
@@ -186,7 +187,8 @@ Your code should resemble:
186
187
187
188
!
188
189
189
-
After execution, this is shown in SAP AI Launchpad.
190
+
After execution, this is shown in SAP AI Launchpad.
191
+
190
192
!
191
193
192
194
[DONE]
@@ -197,7 +199,7 @@ After execution, this is shown in SAP AI Launchpad.
197
199
Add the following snippet to store metrics based on a customized structure.
@@ -209,7 +211,7 @@ The structure must be type-cast to `str` (string). Here, the structure used is [
209
211
210
212
The variables `r` and `feature_importances` are already created in the starter code.
211
213
212
-
After execution, this is shown in SAP AI Launchpad.
214
+
After execution, you can see this in SAP AI Launchpad.
213
215
214
216
!
215
217
@@ -219,13 +221,13 @@ After execution, this is shown in SAP AI Launchpad.
219
221
>
220
222
> What it is?
221
223
>
222
-
> -Indicates for a given target, model, dataset and task, how much the model depends on a given feature.
224
+
> -Shows how much a model depends on a given feature for a given target, model, dataset and task.
223
225
> - Gives an empirical estimate of how much loss is attributed to the removal of a given feature.
224
226
>
225
227
> What it is not:
226
228
>
227
-
> - A model, dataset or taskagnostic 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.
229
+
> - 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.
230
+
> -An accurate indication of the importance of a given feature for a specific prediction. Although this is the goal of the method, it does not account for weaknesses in the model.
229
231
>
230
232
> Advantages:
231
233
>
@@ -238,27 +240,27 @@ After execution, this is shown in SAP AI Launchpad.
238
240
[DONE]
239
241
[ACCORDION-END]
240
242
241
-
[ACCORDION-BEGIN [Step 6: ](Add tags for execution meta after training)]
243
+
[ACCORDION-BEGIN [Step 7: ](Add tags for execution meta after training)]
242
244
243
-
Add the following snippet to tag you execution. The `tags` are customizable key-values.
245
+
Add the following snippet to tag your execution. The `tags` are customizable key-values.
244
246
245
247
```PYTHON
246
-
aic_connection.metrics.set_tags(
248
+
aic_connection.set_tags(
247
249
tags= [
248
250
MetricTag(name="Validation Method Used", value="K-Fold"), # your custom name and value
249
251
MetricTag(name="Metrics", value="R2"),
250
252
]
251
253
)
252
254
```
253
255
254
-
After execution, this is shown in SAP AI Launchpad.
256
+
After execution, you can see this in SAP AI Launchpad.
255
257
256
258
!
257
259
258
260
[DONE]
259
261
[ACCORDION-END]
260
262
261
-
[ACCORDION-BEGIN [Step 7: ](Complete files)]
263
+
[ACCORDION-BEGIN [Step 8: ](Complete files)]
262
264
263
265
Check your modified `main.py` by comparing it with the following expected `main.py`.
264
266
@@ -271,8 +273,8 @@ from datetime import datetime
271
273
import pandas as pd
272
274
from ai_core_sdk.models import Metric, MetricTag, MetricCustomInfo, MetricLabel
273
275
#
274
-
from ai_core_sdk.ai_core_v2_clientimportAICoreV2Client
275
-
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
MetricTag(name="Validation Method Used", value="K-Fold"), # your custom name and value
362
364
MetricTag(name="Metrics", value="R2"),
@@ -369,10 +371,10 @@ Check your modified `main.py` by comparing it with the following expected `main.
369
371
```TEXT
370
372
sklearn==0.0
371
373
pandas
372
-
ai-core-sdk>=1.12.0
374
+
ai-core-sdk>=1.15.1
373
375
```
374
376
375
-
Create a file called `Dockerfile` with following snippet. This file must not have a file extension or alternative name.
377
+
Create a file called `Dockerfile` with the following snippet. This file must not have a file extension or alternative name.
376
378
377
379
```TEXT
378
380
# Specify which base layers (default dependencies) to use
@@ -473,7 +475,7 @@ Create a configuration using the following values. The values are taken from the
473
475
| Scenario ID | `learning-datalines`
474
476
| Executable ID | `house-metrics-train`
475
477
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.
478
+
The value for `Input Parameters` `DT_MAX_DEPTH` is your choice. Until now, this has been set using an environment variable. If a variable is not specified, this parameter continues to be defined by the environment variables.
477
479
478
480
> 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
481
@@ -489,7 +491,7 @@ Create an execution from this configuration.
489
491
490
492
[OPTION BEGIN [SAP AI Launchpad]]
491
493
492
-
In the `ML Operations` app, choose `Executions`. Navigate to your execution and choose the `Metrics Resource` tab.
494
+
In the `ML Operations` app, choose `Executions`. Navigate to your execution and choose the `Metric Resources` tab.
493
495
494
496
!
495
497
@@ -513,7 +515,7 @@ Navigate through `AI Core` > `lm` > `metrics` > `Get metrics` and double check t
513
515
Paste and edit, then execute the following snippet:
514
516
515
517
```PYTHON
516
-
response = ai_core_client.metrics.query(
518
+
response = tracking_client.query(
517
519
execution_ids = [
518
520
'e1f2169db8760b5d' # list of execution IDs for which to query metrics
0 commit comments