Skip to content

Commit cdbfc61

Browse files
authored
[FSTORE-1666] Import transformations functions from Hopsworks API in tutorials so that they are compatible with all project in APP (#295)
1 parent 5cd30d1 commit cdbfc61

13 files changed

+54
-169
lines changed

api_examples/feature_monitoring.ipynb

+27-140
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,10 @@
4545
},
4646
{
4747
"cell_type": "code",
48-
"execution_count": 1,
48+
"execution_count": null,
4949
"id": "78326a44",
5050
"metadata": {},
51-
"outputs": [
52-
{
53-
"name": "stdout",
54-
"output_type": "stream",
55-
"text": [
56-
"Connected. Call `.close()` to terminate connection gracefully.\n",
57-
"\n",
58-
"Logged in to project, explore it here https://hopsworks0.logicalclocks.com/p/120\n",
59-
"Connected. Call `.close()` to terminate connection gracefully.\n"
60-
]
61-
}
62-
],
51+
"outputs": [],
6352
"source": [
6453
"import hopsworks\n",
6554
"import numpy as np\n",
@@ -82,7 +71,7 @@
8271
},
8372
{
8473
"cell_type": "code",
85-
"execution_count": 2,
74+
"execution_count": null,
8675
"id": "42e1c8b0",
8776
"metadata": {},
8877
"outputs": [],
@@ -120,42 +109,10 @@
120109
},
121110
{
122111
"cell_type": "code",
123-
"execution_count": 3,
112+
"execution_count": null,
124113
"id": "a1ad04fa",
125114
"metadata": {},
126-
"outputs": [
127-
{
128-
"name": "stdout",
129-
"output_type": "stream",
130-
"text": [
131-
"Feature Group created successfully, explore it at \n",
132-
"https://hopsworks0.logicalclocks.com/p/120/fs/68/fg/14\n"
133-
]
134-
},
135-
{
136-
"data": {
137-
"application/vnd.jupyter.widget-view+json": {
138-
"model_id": "719e5cea6dca47bdbfd8e87f5b145c45",
139-
"version_major": 2,
140-
"version_minor": 0
141-
},
142-
"text/plain": [
143-
"Uploading Dataframe: 0.00% | | Rows 0/106020 | Elapsed Time: 00:00 | Remaining Time: ?"
144-
]
145-
},
146-
"metadata": {},
147-
"output_type": "display_data"
148-
},
149-
{
150-
"name": "stdout",
151-
"output_type": "stream",
152-
"text": [
153-
"Launching job: trans_fg_1_offline_fg_materialization\n",
154-
"Job started successfully, you can follow the progress at \n",
155-
"https://hopsworks0.logicalclocks.com/p/120/jobs/named/trans_fg_1_offline_fg_materialization/executions\n"
156-
]
157-
}
158-
],
115+
"outputs": [],
159116
"source": [
160117
"# Feature Group\n",
161118
"trans_fg = fs.get_or_create_feature_group(\n",
@@ -174,32 +131,15 @@
174131
},
175132
{
176133
"cell_type": "code",
177-
"execution_count": 4,
134+
"execution_count": null,
178135
"id": "176ad761",
179136
"metadata": {},
180-
"outputs": [
181-
{
182-
"name": "stdout",
183-
"output_type": "stream",
184-
"text": [
185-
"Feature view created successfully, explore it at \n",
186-
"https://hopsworks0.logicalclocks.com/p/120/fs/68/fv/trans_fv/version/1\n",
187-
"Training dataset job started successfully, you can follow the progress at \n",
188-
"https://hopsworks0.logicalclocks.com/p/120/jobs/named/trans_fv_1_create_fv_td_16022024133852/executions\n"
189-
]
190-
},
191-
{
192-
"name": "stderr",
193-
"output_type": "stream",
194-
"text": [
195-
"VersionWarning: Incremented version to `1`.\n"
196-
]
197-
}
198-
],
137+
"outputs": [],
199138
"source": [
200139
"query = trans_fg.select([\"fraud_label\", \"amount\", \"cc_num\"])\n",
201140
"\n",
202-
"min_max_scaler = fs.get_transformation_function(name=\"min_max_scaler\")\n",
141+
"# Import transformation functions from Hopsworks.\n",
142+
"from hopsworks.hsfs.builtin_transformations import min_max_scaler\n",
203143
"\n",
204144
"transformation_functions = [\n",
205145
" min_max_scaler(\"amount\") \n",
@@ -224,26 +164,10 @@
224164
},
225165
{
226166
"cell_type": "code",
227-
"execution_count": 5,
167+
"execution_count": null,
228168
"id": "29ae9922",
229169
"metadata": {},
230-
"outputs": [
231-
{
232-
"name": "stdout",
233-
"output_type": "stream",
234-
"text": [
235-
"Training dataset job started successfully, you can follow the progress at \n",
236-
"https://hopsworks0.logicalclocks.com/p/120/jobs/named/trans_fv_1_create_fv_td_16022024134233/executions\n"
237-
]
238-
},
239-
{
240-
"name": "stderr",
241-
"output_type": "stream",
242-
"text": [
243-
"VersionWarning: Incremented version to `2`.\n"
244-
]
245-
}
246-
],
170+
"outputs": [],
247171
"source": [
248172
"_, _ = trans_fv.create_train_validation_test_split(\n",
249173
" description = 'test extra filters',\n",
@@ -275,7 +199,7 @@
275199
},
276200
{
277201
"cell_type": "code",
278-
"execution_count": 6,
202+
"execution_count": null,
279203
"id": "b82685fb",
280204
"metadata": {},
281205
"outputs": [],
@@ -303,7 +227,7 @@
303227
},
304228
{
305229
"cell_type": "code",
306-
"execution_count": 7,
230+
"execution_count": null,
307231
"id": "703da6cc",
308232
"metadata": {},
309233
"outputs": [],
@@ -325,7 +249,7 @@
325249
},
326250
{
327251
"cell_type": "code",
328-
"execution_count": 8,
252+
"execution_count": null,
329253
"id": "28a891bf",
330254
"metadata": {},
331255
"outputs": [],
@@ -347,7 +271,7 @@
347271
},
348272
{
349273
"cell_type": "code",
350-
"execution_count": 9,
274+
"execution_count": null,
351275
"id": "fa5651be",
352276
"metadata": {},
353277
"outputs": [],
@@ -382,7 +306,7 @@
382306
},
383307
{
384308
"cell_type": "code",
385-
"execution_count": 10,
309+
"execution_count": null,
386310
"id": "dce248fb",
387311
"metadata": {},
388312
"outputs": [],
@@ -408,21 +332,10 @@
408332
},
409333
{
410334
"cell_type": "code",
411-
"execution_count": 11,
335+
"execution_count": null,
412336
"id": "7fcc0236",
413337
"metadata": {},
414-
"outputs": [
415-
{
416-
"data": {
417-
"text/plain": [
418-
"FeatureMonitoringConfig('fg_amount_monitoring_reference_value', STATISTICS_COMPARISON)"
419-
]
420-
},
421-
"execution_count": 11,
422-
"metadata": {},
423-
"output_type": "execute_result"
424-
}
425-
],
338+
"outputs": [],
426339
"source": [
427340
"fg_amount_monitoring_reference_value.with_reference_value(\n",
428341
" value=100,\n",
@@ -444,7 +357,7 @@
444357
},
445358
{
446359
"cell_type": "code",
447-
"execution_count": 12,
360+
"execution_count": null,
448361
"id": "b5ecd419",
449362
"metadata": {},
450363
"outputs": [],
@@ -477,7 +390,7 @@
477390
},
478391
{
479392
"cell_type": "code",
480-
"execution_count": 13,
393+
"execution_count": null,
481394
"id": "2acd07e4",
482395
"metadata": {},
483396
"outputs": [],
@@ -530,7 +443,7 @@
530443
},
531444
{
532445
"cell_type": "code",
533-
"execution_count": 14,
446+
"execution_count": null,
534447
"id": "07c863f2",
535448
"metadata": {},
536449
"outputs": [],
@@ -554,25 +467,10 @@
554467
},
555468
{
556469
"cell_type": "code",
557-
"execution_count": 15,
470+
"execution_count": null,
558471
"id": "58483800",
559472
"metadata": {},
560-
"outputs": [
561-
{
562-
"data": {
563-
"text/plain": [
564-
"[FeatureMonitoringConfig('fg_full_monitoring_sliding', STATISTICS_COMPUTATION),\n",
565-
" FeatureMonitoringConfig('fg_full_monitoring', STATISTICS_COMPUTATION),\n",
566-
" FeatureMonitoringConfig('fg_amount_monitoring_reference_value', STATISTICS_COMPARISON),\n",
567-
" FeatureMonitoringConfig('fg_amount_monitoring_reference_sliding', STATISTICS_COMPARISON),\n",
568-
" FeatureMonitoringConfig('fg_amount_feature_monitoring', STATISTICS_COMPUTATION)]"
569-
]
570-
},
571-
"execution_count": 15,
572-
"metadata": {},
573-
"output_type": "execute_result"
574-
}
575-
],
473+
"outputs": [],
576474
"source": [
577475
"trans_fg.get_feature_monitoring_configs()"
578476
]
@@ -587,21 +485,10 @@
587485
},
588486
{
589487
"cell_type": "code",
590-
"execution_count": 16,
488+
"execution_count": null,
591489
"id": "3372c2d8",
592490
"metadata": {},
593-
"outputs": [
594-
{
595-
"data": {
596-
"text/plain": [
597-
"FeatureMonitoringConfig('fg_full_monitoring', STATISTICS_COMPUTATION)"
598-
]
599-
},
600-
"execution_count": 16,
601-
"metadata": {},
602-
"output_type": "execute_result"
603-
}
604-
],
491+
"outputs": [],
605492
"source": [
606493
"trans_fg.get_feature_monitoring_configs(name=\"fg_full_monitoring\")"
607494
]
@@ -624,7 +511,7 @@
624511
"hash": "e1ddeae6eefc765c17da80d38ea59b893ab18c0c0904077a035ef84cfe367f83"
625512
},
626513
"kernelspec": {
627-
"display_name": "Python 3",
514+
"display_name": "Python 3 (ipykernel)",
628515
"language": "python",
629516
"name": "python3"
630517
},
@@ -638,7 +525,7 @@
638525
"name": "python",
639526
"nbconvert_exporter": "python",
640527
"pygments_lexer": "ipython3",
641-
"version": "3.10.11"
528+
"version": "3.12.5"
642529
}
643530
},
644531
"nbformat": 4,

batch-ai-systems/churn/2_churn_training_pipeline.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@
158158
"metadata": {},
159159
"outputs": [],
160160
"source": [
161-
"# Load transformation functions from the feature store\n",
162-
"min_max_scaler = fs.get_transformation_function(name=\"min_max_scaler\")\n",
163-
"label_encoder = fs.get_transformation_function(name=\"label_encoder\")\n",
161+
"# Import transformation functions from Hopsworks.\n",
162+
"from hopsworks.hsfs.builtin_transformations import label_encoder, min_max_scaler\n",
163+
"\n",
164164
"\n",
165165
"# Define lists of numerical and categorical features\n",
166166
"numerical_features = [\"tenure\", \"monthlycharges\", \"totalcharges\"]\n",

batch-ai-systems/credit_scores/3_credit_scores_training_pipeline.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@
286286
"# Extracting the names of categorical columns in the 'selected_features_show5query_show5' DataFrame\n",
287287
"cat_cols = selected_features_show5.dtypes[selected_features_show5.dtypes == 'object'].index\n",
288288
"\n",
289-
"# Retrieving the Label Encoder transformation function from Featuretools\n",
290-
"label_encoder = fs.get_transformation_function(name='label_encoder') \n",
289+
"# Import transformation functions from Hopsworks.\n",
290+
"from hopsworks.hsfs.builtin_transformations import label_encoder\n",
291291
"\n",
292292
"# Creating a dictionary of transformation functions, where each categorical column is associated with the Label Encoder\n",
293293
"transformation_functions = [\n",

batch-ai-systems/fraud_batch/2_fraud_batch_training_pipeline.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@
155155
"metadata": {},
156156
"outputs": [],
157157
"source": [
158-
"# Load transformation functions.\n",
159-
"label_encoder = fs.get_transformation_function(name=\"label_encoder\")\n",
158+
"# Import transformation functions from Hopsworks.\n",
159+
"from hopsworks.hsfs.builtin_transformations import label_encoder\n",
160160
"\n",
161161
"# Map features to transformations.\n",
162162
"transformation_functions = [\n",

batch-ai-systems/hospital_wait_time/2_training_pipeline.ipynb

+2-3
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@
139139
"metadata": {},
140140
"outputs": [],
141141
"source": [
142-
"label_encoder = fs.get_transformation_function(name=\"label_encoder\")\n",
143-
"\n",
144-
"standard_scaler = fs.get_transformation_function(name=\"standard_scaler\")"
142+
"# Import transformation functions from Hopsworks.\n",
143+
"from hopsworks.hsfs.builtin_transformations import label_encoder, standard_scaler"
145144
]
146145
},
147146
{

integrations/mage_ai/mage_tutorial/custom/transactions_feature_view.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def transform_custom(*args, **kwargs):
3939
query = trans_fg.select(["fraud_label", "category", "amount", "age_at_transaction", "days_until_card_expires", "loc_delta"])\
4040
.join(window_aggs_fg.select_except(["cc_num"]))
4141

42-
# Load transformation functions.
43-
label_encoder = fs.get_transformation_function(name="label_encoder")
42+
# Import transformation functions from Hopsworks.
43+
from hopsworks.hsfs.builtin_transformations import label_encoder
4444

4545
# Map features to transformations.
4646
transformation_functions = [

integrations/mage_ai/mage_tutorial/data_exporters/transactions_feature_view.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def create_feature_view(data, *args, **kwargs):
3737
query = trans_fg.select(["fraud_label", "category", "amount", "age_at_transaction", "days_until_card_expires", "loc_delta"])\
3838
.join(window_aggs_fg.select_except(["cc_num"]))
3939

40-
# Load transformation functions.
41-
label_encoder = fs.get_transformation_function(name="label_encoder")
40+
# Import transformation functions from Hopsworks.
41+
from hopsworks.hsfs.builtin_transformations import label_encoder
4242

4343
# Map features to transformations.
4444
transformation_functions = [

integrations/neo4j/2_training_pipeline.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@
145145
"metadata": {},
146146
"outputs": [],
147147
"source": [
148-
"# Load built in transformation functions.\n",
149-
"min_max_scaler = fs.get_transformation_function(name=\"min_max_scaler\")\n",
148+
"# Import transformation functions from Hopsworks.\n",
149+
"from hopsworks.hsfs.builtin_transformations import min_max_scaler\n",
150150
"\n",
151151
"# Map features to transformations.\n",
152152
"transformation_functions = [\n",

0 commit comments

Comments
 (0)