Compare commits

...
Author SHA1 Message Date
Andrew FerlitschandGitHub 06daeb1575 Merge branch 'main' into instance_schema 2022-10-31 13:30:28 -07:00
Andrew Ferlitsch 2074fb56a9 feat: add example of instance schema 2022-10-31 20:29:16 +00:00
Andrew FerlitschandGitHub 1bdbb7921a fix: reduce visibility of proto code (#1202) 2022-10-31 16:00:27 -04:00
7154a722ba Update Experiments notebook for log_classification_metrics (#1182)
* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-31 12:27:27 -07:00
halio-gandGitHub 99d4a8c31a Adding Open Source Vizier converstion sample[Updated] (#1187)
* Add a colab to show how to integrate the training job with Dask.

* Reformat the notebook xgboost_data_parallel_training_on_cpu_using_dask

* Add the code owner of the sample training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Changed the project id to [your-project-id].

* Fixed the issue for Non colab.

* Adding the sample of converting the Vertex Vizier SDK with Open source Vizier.

* Add the owner for conversions_vertex_vizier_and_open_source_vizier.ipynb

* Addressed the comments in the xgboost_data_parallel_training_on_cpu_using_dask

* Fixed the format of xgboost_data_parallel_training_on_cpu_using_dask

* Addressed the comments in the training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Add explanation that Docker is not available on Colab.

* Add  before docker command.

* add timeout in the worker to wait for the scheduler.

* Addressed the comments in the pr.

* Addressed the comments in the pr.
2022-10-28 15:26:14 -07:00
f9cedf2850 Added notebook demonstrating hyperparameter tuning (#1168)
* Added notebook demonstrating hyperparameter tuning

* fix lint errors

* fix failing test

* ran linter

* ran linter

* resolved editorial comments

* small editorial edits

* fix failing test

* fix linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-28 09:53:22 -07:00
f4f0112a6a Pipelines xgboost (#1196)
* feat: add notebook

* feat: add notebook

* fix: typos in text

Co-authored-by: gericdong <itseric@google.com>
2022-10-27 20:18:20 -04:00
Kevin NaughtonandGitHub e441568c38 Quick typo update in model_monitoring.ipynb (#1197)
The Monitoring Interval is in hours, not seconds.
2022-10-27 17:10:42 -07:00
Andrew FerlitschandGitHub fee8c969e4 feat: add xgboost pipeline notebook (#1194)
* feat: add notebook

* feat: add notebook
2022-10-27 15:20:10 -04:00
Andrew FerlitschandGitHub bdac091e3f feat: add sklearn pipeline notebook (#1193)
* feat: add notebook

* feat: add notebook

* fix: typo in text for dataset-url
2022-10-27 13:32:09 -04:00
kthytangandGitHub ff9338ed3c chore: remove preview note from CPR notebooks (#1192) 2022-10-26 11:31:42 -07:00
Andrew FerlitschandGitHub 1a538fd249 fix: multi-class vs binary classifier (#1191) 2022-10-26 08:28:35 -07:00
4f09c94b5f fix: textual corrections and Upgrade the gcpc version for automl_video_classification_model_evaluation notebook. (#1169)
* added model evaluation component

* linter test cases

* linter test cases

* model_name param issues resolved

* linter test case

* import issues resloved

* linter test cases

* made review changes

* made review changes

* ran linter test

* made review changes

* made review changes

* made review changes

* linter test

* ran linter test

* made review changes

* ran linter test

* made review changes

* ran linter test

* linter test

* review changes

* ran linter test

* added The links for Colab, Github and Workbench

* added The links for Colab, Github and Workbench

* ran linter test

* added The links for Colab, Github and Workbench

* ran linter test

* added The links for Colab, Github and Workbench

* ran linter test

* notebook title changed

* ran linter test

* text changes and made review changes

* ran linter test

* made review changes

* linter test

* made review changes

* linter test

* content changes

* ran linter test

* textual corrections and links

* ran linter test

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Soheila Zangeneh <49654056+soheilazangeneh@users.noreply.github.com>
2022-10-25 17:32:44 -04:00
bcf3e6b0f5 Updated file custom_tabular_regression_model_evaluation (#1180)
* made text corrections

* ran linter

* modified notebook

* modified notebook

* ran linter

* modified installation step

* ran linter

Co-authored-by: Soheila Zangeneh <49654056+soheilazangeneh@users.noreply.github.com>
2022-10-25 12:42:48 -04:00
Bo zhengandGitHub fbcf783064 feat: change E2E AutoML dataset to use bank marketing data
* Change E2E AutoML dataset to use bank marketing data

* Remove vs code config
2022-10-24 22:15:43 -07:00
halio-gandGitHub 2f5fe80f34 Adding the official version for Dask parallel training on cpu (#1153)
* Add a colab to show how to integrate the training job with Dask.

* Reformat the notebook xgboost_data_parallel_training_on_cpu_using_dask

* Add the code owner of the sample training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Changed the project id to [your-project-id].

* Fixed the issue for Non colab.

* Addressed the comments in the xgboost_data_parallel_training_on_cpu_using_dask

* Fixed the format of xgboost_data_parallel_training_on_cpu_using_dask

* Addressed the comments in the training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Add explanation that Docker is not available on Colab.

* Add  before docker command.

* add timeout in the worker to wait for the scheduler.
2022-10-24 10:37:13 -07:00
a850f3a88a fix: missed bad links (#1183)
* fix: missed bad links

* fix: missed bad links

Co-authored-by: gericdong <itseric@google.com>
2022-10-21 11:09:11 -04:00
Andrew FerlitschandGitHub de91feaca1 Update README.md (#1181)
added missing link
2022-10-21 07:15:38 -07:00
Andrew FerlitschandGitHub a7fd0734dc feat: XGBoost online serving (#1175)
* feat: xgboost online serving

* fix: review comments and added pipeline example

* fix: review comments
2022-10-19 08:49:31 -07:00
Soheila ZangenehandGitHub ce1b167f08 Edit folder and file name for model registry (#1178)
* Update folder and file name

* Update file name

* Update CODEOWNERS

* Update notebook links

* Update README

* Run linter
2022-10-18 14:40:52 -07:00
Soheila ZangenehandGitHub 65ff3cab60 Revert "Update folder and file names (#1176)" (#1177)
This reverts commit c7ef72f1d3.
2022-10-18 16:59:39 -04:00
Soheila ZangenehandGitHub c7ef72f1d3 Update folder and file names (#1176)
* Rename folder

* Rename file

* Update the links

* Update CODOWNERS

* Run linter
2022-10-18 16:42:36 -04:00
Andrew FerlitschandGitHub bd58428857 fix: issue 1122 (#1173) 2022-10-18 15:09:35 -04:00
Andrew FerlitschandGitHub a4a6ed848b fix: working on abstract class (#1156)
* fix: working on abstract class

* fix: working on abstract class
2022-10-13 10:56:17 -04:00
Andrew FerlitschandGitHub b753bc58d3 fix: enum and cell index naming (#1152) 2022-10-12 14:54:57 -04:00
6279e12eea Bug fixes and automation improvements for google_cloud_pipeline_components_dataproc_tabular.ipynb (#1139)
* Bug fixes and improved automation

* Clean up notebook

* Add --quiet flag to gcloud call

* Add Python prediction and subnetwork parameter

Co-authored-by: Win Woo <wwoo@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-12 08:19:25 -07:00
Andrew FerlitschandGitHub fc0c34c905 Boilerplate 2 (#1148)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script

* tuning: boiler plate

* tuning: boiler plate

* tuning: boiler plate
2022-10-11 14:01:41 -07:00
Andrew FerlitschandGitHub ef388ecf30 Boilerplate 2 (#1147)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script

* tuning: boiler plate

* tuning: boiler plate
2022-10-11 13:57:40 -07:00
Andrew FerlitschandGitHub bafb2c6f59 Boilerplate 2 (#1146)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script

* tuning: boiler plate
2022-10-11 13:43:27 -07:00
Andrew FerlitschandGitHub f2d431c182 tuning: boiler plate (#1145)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script
2022-10-11 13:31:55 -07:00
Andrew FerlitschandGitHub 2e4b6a1b1b fix: structure (#1138) 2022-10-11 13:29:11 -07:00
95cebcbf8f Update google_cloud_pipeline_components_dataproc_tabular.ipynb (#1136)
Removed extraneous `$` from CWD variable causing scala-sbt build to fail

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-11 13:04:28 -07:00
Andrew FerlitschandGitHub 08f1b659c5 Boilerplate 1 (#1144)
* feat: boiler plate reduction

* feat: boiler plate reduction
2022-10-11 11:30:08 -07:00
Andrew FerlitschandGitHub 86ba71931d fix: merge corruption (#1143) 2022-10-11 11:19:05 -07:00
d811306fb9 minor fixes (#1140)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-11 11:09:24 -07:00
Andrew FerlitschandGitHub 4173e6d561 Boilerplate 1 (#1142)
* feat: boiler plate reduction

* feat: boiler plate reduction
2022-10-11 10:27:04 -07:00
Andrew FerlitschandGitHub 499d25055a feat: boiler plate reduction (#1141) 2022-10-11 09:32:30 -07:00
Andrew FerlitschandGitHub 60776de953 fix: bad links and branding (#1137) 2022-10-10 15:57:22 -07:00
Andrew FerlitschandGitHub 182ebcf285 fix: script format (#1134)
* fix: script format

* fix: script format

* fix: script format

* fix: script format
2022-10-10 15:56:31 -07:00
MarcandGitHub 39359a5b21 switch mm ownership to Andy (#1133) 2022-10-10 09:48:12 -07:00
0d72cfe070 Modified file automl_forecasting_bqml_arima_plus_comparison (#1124)
* modified notebook

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-10 08:51:51 -07:00
64fef140a2 Vertex SDK AutoML Image Classification (#1123)
* tf library issues solved

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-07 15:14:53 -07:00
015809b948 Cleans up official/migration/UJ3 notebook and fixes the issue from regression logs (#1063)
* cleans up the notebook,replaces docker with cloud build, textual edits still in progress

* cleans up the notebook

* ran linter test

* changes tf train/serve version to 2.9

* ran linter test

* adds '=' to fix a typo

* ran linter test

* updates the opencv installation package

* ran linter test

* updates the opencv installation dependencies

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-07 09:37:12 -07:00
gericdongandGitHub faccdd081f fix: improved notebook comments and readme (#1131)
* fix: improved notebook comments

* fix: improved notebook comments and formatting
2022-10-07 08:00:02 -07:00
3e8a3cf28e updates: autoreview (#1126)
Co-authored-by: gericdong <itseric@google.com>
2022-10-06 16:11:13 -04:00
Andrew FerlitschandGitHub 821bba2776 fix: loose ends on objective conformance (#1125) 2022-10-06 15:46:31 -04:00
c82bdee299 fix: incorrect linking (#1119)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* fix: incorrect linking for index

* fix: incorrect linking

Co-authored-by: gericdong <itseric@google.com>
2022-10-06 10:11:45 -04:00
Andrew FerlitschandGitHub c27381139b fix: incorrect linking (#1121) 2022-10-05 18:28:32 -07:00
Andrew FerlitschandGitHub 01236836f2 fix: incorrect linking (#1120) 2022-10-05 18:12:30 -07:00
Andrew FerlitschandGitHub b8380650bd fix: incorrect linking (#1118)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* fix: incorrect linking for index
2022-10-05 17:52:45 -07:00
Andrew FerlitschandGitHub 69d266cb90 add: autogen index for official/vizier (#1117)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:25:04 -07:00
Andrew FerlitschandGitHub 530524ac6e feat: add autogen index for official/training (#1116)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:22:17 -07:00
Andrew FerlitschandGitHub ba66961fce feat: add autoindex for official/tensorboard (#1115)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:20:06 -07:00
Andrew FerlitschandGitHub aca7035482 add: add autogen index for official/tabular_workflows (#1114)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:17:15 -07:00
Andrew FerlitschandGitHub 3d270cde69 feat: add autoindex for official/tabnet (#1113)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:14:48 -07:00
Andrew FerlitschandGitHub 9754c265ff feat: add autoindex for official/structured_data (#1112)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:09:35 -07:00
Andrew FerlitschandGitHub f5d730c9f1 feat: add autoindex for official/sdk (#1111)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:02:06 -07:00
Andrew FerlitschandGitHub acd42a3a1b feat: add autogen index for official/reduction_server (#1110)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:58:46 -07:00
Andrew FerlitschandGitHub eb7cf4b6bc feat: add autoindex for official/pipelines (#1109)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:54:26 -07:00
Andrew FerlitschandGitHub 34b1011ac9 feat: add autoindex for official/model-registry (#1108)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:46:04 -07:00
Andrew FerlitschandGitHub 239d664990 feat: add autogen index for official/model_monitoring (#1107)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:43:16 -07:00
Andrew FerlitschandGitHub 920c771238 feat: add autogen index for official/model_evaluation (#1106)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:41:01 -07:00
Andrew FerlitschandGitHub e7c68ecb78 fix: autogen index for official/ml_metadata (#1105)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:37:29 -07:00
Andrew FerlitschandGitHub cfeb118d8b feat: add autogen index for official/matching_engine (#1104)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:30:00 -07:00
Andrew FerlitschandGitHub 2c9c8db15c feat: add autogen index for official/feature_store (#1103)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index
2022-10-05 16:24:10 -07:00
Andrew FerlitschandGitHub 6778a2cfbf fix: update autogen index for official/automl (#1102)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index
2022-10-05 16:14:24 -07:00
Andrew FerlitschandGitHub 26c5d56e6d feat: update autogen index for official/explainable_ai (#1101)
* feat: add autogen index

* fix: missed the REAME
2022-10-05 16:08:41 -07:00
Andrew FerlitschandGitHub 527fe79f15 feat: add autogen index (#1100) 2022-10-05 16:06:38 -07:00
Andrew FerlitschandGitHub 2a003fa9c3 add: autogen index (#1085) 2022-10-05 15:55:29 -07:00
Andrew FerlitschandGitHub 03b9b6026f feat: add index (#1084) 2022-10-05 15:55:09 -07:00
Andrew FerlitschandGitHub ff8d6a9d56 feat: add autogen index (#1083) 2022-10-05 13:21:55 -07:00
Andrew FerlitschandGitHub 874c881ad6 feat: add autogen index (#1080) 2022-10-05 13:21:24 -07:00
Andrew FerlitschandGitHub f484429a89 fix: auto regen index for curated (#1076)
* fix: auto regen index for curated

* fix: bad links
2022-10-05 13:20:22 -07:00
Andrew FerlitschandGitHub 7fa2502c09 PR: bad links and objective (#1099)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:13:12 -07:00
Andrew FerlitschandGitHub 056791fadd fix: bad links and objective (#1098)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:10:35 -07:00
Andrew FerlitschandGitHub 154be75dce fix: bad links and objective (#1097)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:07:09 -07:00
Andrew FerlitschandGitHub ed7e900a02 fix: bad links and objective (#1096)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:01:19 -07:00
Andrew FerlitschandGitHub f109fefbfa fix: bad links (#1095)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 10:54:19 -07:00
Andrew FerlitschandGitHub 6f9c99d1df fix: bad links and objective (#1094)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 10:49:41 -07:00
Andrew FerlitschandGitHub ed39d78005 fix: bad links and objective conformance (#1093)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 10:25:02 -07:00
Andrew FerlitschandGitHub d6466ab1a6 fix: bad links and objective (#1092)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective
2022-10-05 10:15:36 -07:00
Andrew FerlitschandGitHub 65e310e4e6 fix: bad links and objective (#1091)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance
2022-10-05 10:08:39 -07:00
Andrew FerlitschandGitHub 0e773ba90f fix: bad links and objective (#1090)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance
2022-10-05 10:07:35 -07:00
Andrew FerlitschandGitHub 0747f9efb8 fix: objective (#1089)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance
2022-10-05 09:38:50 -07:00
Andrew FerlitschandGitHub 53785fb812 fix: objective section (#1088)
* fix: objective conformance

* fix: objective conformance
2022-10-05 09:33:13 -07:00
Andrew FerlitschandGitHub b85c24dca5 fix: objective conformance (#1087) 2022-10-05 09:21:49 -07:00
Andrew FerlitschandGitHub ea5c12c22a Autoreview 17 (#1082)
* fix: bad link

* fix: objective
2022-10-04 17:32:04 -07:00
Andrew FerlitschandGitHub 392c1b7361 fix: bad link (#1081) 2022-10-04 17:26:30 -07:00
Andrew FerlitschandGitHub c5980e636e Autoreview 15 (#1079)
* fix: tag handling

* fix: objective

* fix: bad links
2022-10-04 17:08:46 -07:00
Andrew FerlitschandGitHub 8859e9426d fix: tag handling (#1078) 2022-10-04 16:57:34 -07:00
Andrew FerlitschandGitHub db7cc9000a fix: bad links (#1077)
* fix: bad links

* fix: bad links and branding
2022-10-04 16:44:03 -07:00
Andrew FerlitschandGitHub d1fe50a1d9 fix: last tag handling (#1075) 2022-10-04 14:18:22 -07:00
Andrew FerlitschandGitHub 9e3597692f Autoreview text fixes (#1074)
* fix: bad links

* fix: bad links

* fix: objective intro

* fix: objective

* fix: objective statement

* fix: objective statement
2022-10-04 14:07:17 -07:00
Andrew FerlitschandGitHub 45c8deebe5 Autoreview text fixes (#1073)
* fix: bad links

* fix: bad links

* fix: objective intro

* fix: objective

* fix: objective statement
2022-10-04 14:03:10 -07:00
Andrew FerlitschandGitHub 6705c4e4ee Autoreview text fixes (#1072)
* fix: bad links

* fix: bad links

* fix: objective intro

* fix: objective
2022-10-04 13:54:50 -07:00
Andrew FerlitschandGitHub b7f06d948a Autoreview text fixes (#1071)
* fix: bad links

* fix: bad links

* fix: objective intro
2022-10-04 13:20:29 -07:00
Andrew FerlitschandGitHub 7f3c1a9a36 fix: bad links (#1070)
* fix: bad links

* fix: bad links
2022-10-04 13:12:54 -07:00
2e991c5b9d New notebook for PyTorch distributed training on reduction server (#1064)
* feat: added new notebook for PyTorch distributed training on reduction server

* Fixed linter errors

* Addressed review comments

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-04 13:07:43 -07:00
Andrew FerlitschandGitHub f8ac68ec10 Autoreview 10 (#1069)
* fix: handling of linkback for web output

* fix: tune markdown output
2022-10-04 13:06:38 -07:00
Andrew FerlitschandGitHub a591c39367 fix: handling of linkback for web output (#1068) 2022-10-04 12:08:46 -07:00
Andrew FerlitschandGitHub d938982aae feat: calculate links for new notebooks (#1065) 2022-10-04 12:08:18 -07:00
1397c9a64a Fixed line break (#1067)
* Added tags, links to corresponding documentation pages

* Fixed line break issue

Co-authored-by: Max Reznitskii <reznitskii@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-04 11:31:32 -07:00
da97ec2244 Added tags, links to corresponding documentation pages (#1066)
Co-authored-by: Max Reznitskii <reznitskii@google.com>
2022-10-04 11:20:08 -07:00
c3f1f8239b UJ15 Vertex SDK AutoML Object Tracking (#1055)
* resloved tf library issues

* ran linter test

* made review changes

* ran linter test

* made review changes

* ran linter

* made review changes

* linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-04 08:51:17 -07:00
Andrew FerlitschandGitHub 73878dcc01 update: support for multi-tags and desc for web output (#1061) 2022-10-04 09:32:20 -04:00
Andrew FerlitschandGitHub 13bad2e6a3 Autoreview readme (#1060)
* fix: re autogen index

* fix: descriptions

* fix: descriptions
2022-10-03 13:24:59 -07:00
Andrew FerlitschandGitHub 0172f2b11b fix: re autogen index (#1059) 2022-10-03 12:39:50 -07:00
Andrew FerlitschandGitHub 1ba0c17555 fix: tuning README output (#1058) 2022-10-03 15:14:32 -04:00
399c961074 Modified notebook chicago_taxi_fare_prediction according to notebook template (#1043)
* error resolved

* ran linter

* andrew comments resolved

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-03 08:35:59 -07:00
d44836db9d Modified notebook inventory_prediction (#1041)
* resolved error

* resolved error

* ran linter

* andrew comments resolved

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-03 08:34:47 -07:00
4e236fd553 Text classification evaluation (#959)
* Model evaluation for text classification using Automl

* Removed unused library

* Ran Linter Test

* Commented text

* Commented Text

* Ran Linter test

* Made changes suggested in review

* Removed unused import

* Ran Linter Test

* Removed dataflow parameters as mentioned in the review

* Ran Linter Test

* Made review changes and changed notebook links in the beginning of the notebook

* Ran Linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-02 13:49:06 -07:00
Andrew FerlitschandGitHub 352b1e2710 fix: error handling improvements (#1053) 2022-09-30 15:40:30 -04:00
13cc94d3b7 feat: Add notebook for Wide & Deep on Vertex Pipelines (#984)
* Add notebook for Wide & Deep on Vertex Pipelines

* Address comments

* Clear output

* Fix deletion logic

* Run linter

* Rename custom_job and hpt_job to pipeline_job

* Use Vertex SDK for deletion instead of gcloud

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-30 09:46:23 -07:00
632362ed80 Modified notebook fraud-detection-model notebook (#1052)
* resolved error

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-30 09:44:45 -07:00
90b5575b0c feat: Add notebook for TabNet on Vertex Pipelines (#726)
* Added notebook for TabNet on Vertex Pipelines

* Added notebook for TabNet on Vertex Pipelines

* Added notebook for TabNet on Vertex Pipelines

* Run linter

* Ran linter

* Ran linter again

* Addressed comments

* Addressed more comments

* Remove parameter definitions, reference documentation, add details under CustomJob/HPT job sections

* Address more comments

* Fix tests

* Bug fix

* Rework TabNet HPT job section

* Addressed more comments

* Update documentation links

* Fix tests

* Fix tests

* Linter and some changes

* Address more comments

* Update CustomJob description to align with documentation

* Use bank-marketing dataset instead of safedriver

* Rename variables

* Rename variables

* Update gcs location to official one

* Changes to make notebook run with updated SDK

* Bug fix

* Rewording

* Fix workbench link

* Update notebook format to align with template

* Fix deletion logic

* Run linter

* Rename custom_job and hpt_job to pipeline_job

* Use Vertex SDK for deletion instead of gcloud

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 16:58:53 -07:00
2d96cc0af1 Rapid prototyping bqml automl (#877)
* Made changes in accordance with Notebook template

* Ran Linter Test

* Attached UUID to BQ_DATSET and use bq to delete dataset

* Removed unused imports

* Ran Linter Test

* Fixed BQ_DATASET

* Fixed BQ_DATASET

* Ran linter test

* Made review changes

* Removed unused library

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 13:17:14 -07:00
aadc80752b UJ6 Vertex SDK AutoML Text Classification (#1039)
* add The links for Colab, Github and Workbench

* added The links for Colab, Github and Workbench

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 13:15:10 -07:00
e8745a750b Modified notebook telecom-subscriber-churn-prediction (#874)
* modified notebook telecom-subscriber-churn-prediction.ipynb

* ran linter

* changes suggested by andrew are done

* ran linter

* changes suggested by andrew done

* ran linter

* resolved error

* ran linter

* fixed a monor bug

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 13:13:40 -07:00
Andrew FerlitschandGitHub 67b54685be fix: bad link (#1050)
* fix: bad link

* fix: bad link
2022-09-29 12:07:27 -07:00
Andrew FerlitschandGitHub 738dc1e01c fix: bad links (#1049)
* fix: bad link

* fix: bad link
2022-09-29 12:02:54 -07:00
Andrew FerlitschandGitHub 3b481a43a9 fix: bad links (#1048)
* fix: bad links

* fix: bad links
2022-09-29 12:02:08 -07:00
Andrew FerlitschandGitHub 35d0dee5a0 fix: bad link (#1047)
* fix: bad link

* fix: bad link
2022-09-29 11:47:25 -07:00
Andrew FerlitschandGitHub 90a0bb9b4c fix: bad link (#1046)
* fix: bad link

* fix: bad link
2022-09-29 11:47:01 -07:00
Andrew FerlitschandGitHub e59d5462b4 fix: improve args and add webdoc generation (#1045) 2022-09-29 14:15:52 -04:00
153 changed files with 45820 additions and 850977 deletions
+2 -1
View File
@@ -7,7 +7,7 @@
/gapic @andrewferlitsch
/gapic/custom/showcase_custom_image_classification_online_explain_example_based_api.ipynb @inardini
/ml_ops @andrewferlitsch
/model_monitoring/* @mco-gh
/model_monitoring/* @andrewferlitsch
/structured_data/rapid_prototyping_* @rafael-carvalho
/managed_notebooks/
@@ -33,3 +33,4 @@
/notebooks/community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb @fhirschmann
/notebooks/community/vertex-ai-samples/notebooks/community/model_registry/vertex_ai_model_registry_bqml_custom_model_versioning.ipynb @inardini
/notebooks/community/vertex-ai-samples/notebooks/community/model_registry/vertex_ai_model_registry_automl_model_versioning.ipynb @inardini
/notebooks/community/vizier/conversions_vertex_vizier_and_open_source_vizier.ipynb @halio-g
+1 -1
View File
@@ -14,5 +14,5 @@ The purpose of this set of notebooks and markdown files is to demonstrate Google
4. [Evaluation](stage4)
5. [Deployment](stage5)
6. [Serving](stage6)
7. Monitoring
7. Monitoring(stage7)
8. Continuous Training
+43
View File
@@ -0,0 +1,43 @@
## Before you begin
### Set up your Google Cloud project
**The following steps are required, regardless of your notebook environment.**
1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.
1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).
1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).
1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).
1. Enter your project ID in the cell below. Then run the cell to make sure the
Cloud SDK uses the right project for all the commands in this notebook.
**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands.
### Set up your local development environment
**If you are using Colab or Vertex AI Workbench Notebooks**, your environment already meets all the requirements to run this notebook. You can skip this step.
**Otherwise**, make sure your environment meets this notebook's requirements. You need the following:
- The Cloud Storage SDK
- Python 3
- virtualenv
- Jupyter notebook running in a virtual environment with Python 3
The Cloud Storage guide to [Setting up a Python development environment](https://cloud.google.com/python/setup) and the [Jupyter installation guide](https://jupyter.org/install) provide detailed instructions for meeting these requirements. The following steps provide a condensed set of instructions:
1. [Install and initialize the SDK](https://cloud.google.com/sdk/docs/).
2. [Install Python 3](https://cloud.google.com/python/setup#installing_python).
3. [Install virtualenv](https://cloud.google.com/python/setup#installing_and_using_virtualenv) and create a virtual environment that uses Python 3. Activate the virtual environment.
4. To install Jupyter, run `pip3 install jupyter` on the command-line in a terminal shell.
5. To launch Jupyter, run `jupyter notebook` on the command-line in a terminal shell.
6. Open this notebook in the Jupyter Notebook Dashboard.
+112
View File
@@ -0,0 +1,112 @@
import os
import sys
import argparse
import subprocess
import random
import string
parser = argparse.ArgumentParser()
parser.add_argument('--bucket', dest='bucket_required', action='store_true',
default=False, help='Bucket required')
parser.add_argument('--email', dest='email_required', action='store_true',
default=False, help='Email required')
parser.add_argument('--sa', dest='sa_required', action='store_true',
default=False, help='Service account required')
parser.add_argument('--packages', dest='extra_packages',
default='', type=str, help='additional required packages')
args = parser.parse_args()
extra_pkgs = args.extra_packages
# Installation
# The Vertex AI Workbench Notebook product has specific requirements
IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME")
IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(
"/opt/deeplearning/metadata/env_version"
)
IS_COLAB = "google.colab" in sys.modules
# Vertex AI Notebook requires dependencies to be installed with '--user'
USER_FLAG = ""
if IS_WORKBENCH_NOTEBOOK:
USER_FLAG = "--user"
# not used
'''
print("Installing packages")
os.system(f"pip3 install --upgrade --quiet {USER_FLAG} google-cloud-aiplatform {args.extra_packages}")
print("Done installation")
'''
# Authenticate
if IS_COLAB:
from google.colab import auth as google_auth
google_auth.authenticate_user()
# project ID
if IS_WORKBENCH_NOTEBOOK:
shell_output = subprocess.check_output("gcloud config list --format 'value(core.project)' 2>/dev/null", shell=True)
PROJECT_ID = shell_output[0:-1].decode('utf-8')
print("PROJECT ID: ", PROJECT_ID)
else:
PROJECT_ID = input("Enter PROJECT_ID: ")
os.system(f"gcloud config set project {PROJECT_ID}")
# email
if args.email_required:
shell_output = subprocess.check_output("gcloud config list --format 'value(core.account)' 2>/dev/null", shell=True)
EMAIL_ADDR = shell_output[0:-1].decode('utf-8')
if EMAIL_ADDR == '':
EMAIL_ADDR = input("Enter Email Address: ")
print("EMAIL_ADDR: ", EMAIL_ADDR)
# region
shell_output = subprocess.check_output("gcloud config list --format 'value(ai.region)'", shell=True)
REGION = shell_output[0:-1].decode('utf-8')
if REGION == '':
REGION = input("Enter REGION: ")
print("REGION: ", REGION)
# multi-region
MULTI_REGION = REGION.split('-')[0]
# UUID
# Generate a uuid of a specifed length(default=8)
def generate_uuid(length: int = 8) -> str:
return "".join(random.choices(string.ascii_lowercase + string.digits, k=length))
UUID = generate_uuid()
print("UUID", UUID)
# Bucket
if args.bucket_required:
BUCKET_NAME = PROJECT_ID + "aip-" + UUID
BUCKET_URI = f"gs://{BUCKET_NAME}"
os.system(f"gsutil mb -l {REGION} {BUCKET_URI}")
print("BUCKET_URI", BUCKET_URI)
# Project Number
if args.sa_required:
if IS_WORKBENCH_NOTEBOOK:
shell_output = subprocess.check_output("gcloud auth list 2>/dev/null", shell=True)
SERVICE_ACCOUNT = shell_output[:-1].decode('utf-8').split('\n')[2].strip()
PROJECT_NUMBER = SERVICE_ACCOUNT.split('-')[0]
else:
shell_output = subprocess.check_output(f"gcloud projects describe {PROJECT_ID}", shell=True)
try:
PROJECT_NUMBER = shell_output[:-1].decode('utf-8').split('\n')[7].split(':')[-1].strip().replace("'", "")
SERVICE_ACCOUNT = f"{PROJECT_NUMBER}-compute@developer.gserviceaccount.com"
except:
PROJECT_NUMBER = input("Enter project number: ")
SERVICE_ACCOUNT = f"{PROJECT_NUMBER}-compute@developer.gserviceaccount.com"
print("SERVICE_ACCOUNT", SERVICE_ACCOUNT)
print("PROJECT_NUMBER", PROJECT_NUMBER)
+42 -33
View File
@@ -28,50 +28,46 @@ The first stage in MLOps is the collection and preparation for the purpose of de
### Get Started
[Get started with Vertex AI datasets](get_started_vertex_datasets.ipynb)
[Get started with Dataflow](community/ml_ops/stage1/get_started_dataflow.ipynb)
In this tutorial, you learn how to use `Dataflow` for training with `Vertex AI`.
```
The steps performed include:
- Create a Vertex AI `Dataset` resource for:
- image data
- text data
- video data
- tabular data
- forecasting data
- Search `Dataset` resources using a filter.
- Read a sample of a `BigQuery` dataset into a dataframe.
- Generate statistics and data schema using TensorFlow Data Validation from the samples in the dataframe.
- Detect anomalies in new data using TensorFlow Data Validation.
- Generate a TFRecord feature specification using TensorFlow Transform from the data schema.
- Export a dataset and convert to TFRecords.
```
[Get started with Dataflow](get_started_dataflow.ipynb)
```
The steps performed include:
- Offline preprocessing of data:
- Serially - w/o dataflow
- Parallel - with dataflow
- Upstream preprocessing of data:
- tabular data
- image data
```
[Create an unlabelled Vertex AI AutoML text entity extraction dataset from pdfs using Vision API](get_started_with_visionapi_and_vertex_datasets.ipynb)
[Get started with Vertex AI datasets](community/ml_ops/stage1/get_started_vertex_datasets.ipynb)
In this tutorial, you learn how to use `Vertex AI Dataset` for training with `Vertex AI`.
```
The steps performed include:
1. Using `Vision API` to perform Optical Character Recognition (OCR) to extract text from PDF files.
2. Processing the results and saving them to text files.
3. Generating a `Vertex AI Dataset` import file.
4. Creating a new unlabelled text entity extraction `Vertex AI Dataset` resource in `Vertex AI`.
```
[Get started with BigQuery datasets](get_started_bq_datasets.ipynb)
- Create a Vertex AI `Dataset` resource for:
- image data
- text data
- video data
- tabular data
- forecasting data
- Search `Dataset` resources using a filter.
- Read a sample of a `BigQuery` dataset into a dataframe.
- Generate statistics and data schema using TensorFlow Data Validation from the samples in the dataframe.
- Detect anomalies in new data using TensorFlow Data Validation.
- Generate a TFRecord feature specification using TensorFlow Transform from the data schema.
- Export a dataset and convert to TFRecords.
[Get started with BigQuery datasets](community/ml_ops/stage1/get_started_bq_datasets.ipynb)
In this tutorial, you learn how to use `BigQuery` as a dataset for training with `Vertex AI`.
```
The steps performed include:
- Create a Vertex AI `Dataset` resource from `BigQuery` table -- compatible for `AutoML` training.
- Extract a copy of the dataset from `BigQuery` to a CSV file in Cloud Storage -- compatible for `AutoML` or custom training.
- Select rows from a `BigQuery` dataset into a `pandas` dataframe -- compatible for custom training.
@@ -79,19 +75,32 @@ The steps performed include:
- Select rows from extracted CSV files into a `tf.data.Dataset` -- compatible for custom training `TensorFlow` models.
- Create a `BigQuery` dataset from CSV files.
- Extract data from `BigQuery` table into a `DMatrix` -- compatible for custom training `XGBoost` models.
```
[Get started with Vertex AI data labeling](get_started_with_data_labeling.ipynb)
[Get started with Vertex AI Data Labeling](community/ml_ops/stage1/get_started_with_data_labeling.ipynb)
In this tutorial, you learn how to use the `Vertex AI Data Labeling` service.
```
The steps performed include:
- Create a Specialist Pool for data labelers.
- Create a data labeling job.
- Submit the data labeling job.
- List data labeling jobs.
- Cancel a data labeling job.
```
[Create an unlabelled Vertex AI AutoML text entity extraction dataset from PDFs using Vision API](community/ml_ops/stage1/get_started_with_visionapi_and_vertex_datasets.ipynb)
In this tutorial, you learn to use `Vision API` to extract text from PDF files stored on a Cloud Storage bucket. You then process the results and create an unlabelled `Vertex AI Dataset`, compatible with `AutoML`, for text entity extraction.
The steps performed include:
1. Using `Vision API` to perform Optical Character Recognition (OCR) to extract text from PDF files.
2. Processing the results and saving them to text files.
3. Generating a `Vertex AI Dataset` import file.
4. Creating a new unlabelled text entity extraction `Vertex AI Dataset` resource in `Vertex AI`.
### E2E Stage Example
@@ -120,7 +120,7 @@
" - XGBoost model training:\n",
" - Use BigQuery ML built-in XGBoost training.\n",
" - Alternatively, create a DMatrix generator from CSV files extracted from BigQuery table.\n",
" - Pytorch model training:\n",
" - PyTorch model training:\n",
" - Extract the BigQuery to a pandas dataframe.\n",
" - Preprocess the data in the dataframe.\n",
" - Create a DataLoader generator from the pandas dataframe.\n",
@@ -191,13 +191,8 @@
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"# Install the packages\n",
"! pip3 install --upgrade pyarrow $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install -U xgboost $USER_FLAG -q\n",
"! pip3 install -U tensorflow $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q"
"extra_pkgs = \"tensorflow tensorflow-io==0.18 pyarrow xgboost google-cloud-bigquery\"\n",
"! pip3 install --upgrade --quiet {USER_FLAG} google-cloud-aiplatform $extra_pkgs"
]
},
{
@@ -219,9 +214,9 @@
},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
"if \"google.colab\" in sys.modules:\n",
" # Automatically restart kernel after installs\n",
" import IPython\n",
"\n",
@@ -232,274 +227,42 @@
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
"id": "fc8fb52b5cca"
},
"source": [
"## Before you begin\n",
"### Common setup\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "project_id"
},
"source": [
"#### Set your project ID\n",
"\n",
"**If you don't know your project ID**, you may be able to get your project ID using `gcloud`."
"Now, execute the common setup for the notebook tutorials."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_project_id"
"id": "001a0fcd5d78"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
"# Common code setup for notebook tutorials\n",
"\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.py -O setup.py\n",
"\n",
"%run setup.py --bucket"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_project_id"
"id": "d809f07a8935"
},
"outputs": [],
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n",
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_gcloud_project_id"
},
"outputs": [],
"source": [
"! gcloud config set project $PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "region"
},
"source": [
"#### Region\n",
"# Other Common setup instructions for notebook tutorials\n",
"\n",
"You can also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.md -O setup.md\n",
"\n",
"- Americas: `us-central1`\n",
"- Europe: `europe-west4`\n",
"- Asia Pacific: `asia-east1`\n",
"\n",
"You may not use a multi-regional bucket for training with Vertex AI. Not all regions provide support for all Vertex AI services.\n",
"\n",
"Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "region"
},
"outputs": [],
"source": [
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bucket:custom"
},
"source": [
"### Create a Cloud Storage bucket\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you create a dataset resource using the Vertex SDK, you can provide a Cloud Storage bucket that contains the data. Vertex AI creates the dataset resource from the data. In this tutorial, Vertex AI also creates a dataset resource from your data in the Cloud Storage bucket.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bucket"
},
"outputs": [],
"source": [
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_bucket"
},
"outputs": [],
"source": [
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_bucket"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "validate_bucket"
},
"source": [
"Finally, validate access to your Cloud Storage bucket by examining its contents:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
"%load setup.md"
]
},
{
@@ -620,7 +383,7 @@
"outputs": [],
"source": [
"dataset = aiplatform.TabularDataset.create(\n",
" display_name=\"NOAA historical weather data\" + \"_\" + TIMESTAMP,\n",
" display_name=\"NOAA historical weather data\" + \"_\" + UUID,\n",
" bq_source=[IMPORT_FILE],\n",
" labels={\"user_metadata\": BUCKET_URI[5:]},\n",
")\n",
@@ -695,7 +458,7 @@
"gcs_source = IMPORT_FILES\n",
"\n",
"dataset = aiplatform.TabularDataset.create(\n",
" display_name=\"NOAA historical weather data\" + \"_\" + TIMESTAMP,\n",
" display_name=\"NOAA historical weather data\" + \"_\" + UUID,\n",
" gcs_source=gcs_source,\n",
" labels={\"user_metadata\": BUCKET_URI[5:]},\n",
")\n",
@@ -737,10 +500,10 @@
" or BQ_MY_DATASET is None\n",
" or BQ_MY_DATASET == \"[your-dataset-name]\"\n",
"):\n",
" BQ_MY_DATASET = \"mlops_dataset_\" + TIMESTAMP\n",
" BQ_MY_DATASET = \"mlops_dataset_\" + UUID\n",
"\n",
"if BQ_MY_TABLE == \"\" or BQ_MY_TABLE is None or BQ_MY_TABLE == \"[your-view-name]\":\n",
" BQ_MY_TABLE = \"mlops_view_\" + TIMESTAMP"
" BQ_MY_TABLE = \"mlops_view_\" + UUID"
]
},
{
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_dataflow.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage1/get_started_dataflow.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -186,13 +186,9 @@
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install -U tensorflow==2.5 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-transform==1.2 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
"! pip3 install --upgrade apache-beam[gcp] $USER_FLAG -q"
"extra_pkgs = \"tensorflow==2.5 tensorflow-data-validation==1.2 tensorflow-transform==1.2 \\\n",
" tensorflow-io==0.18 pyarrow pandas apache-beam[gcp] google-cloud-bigquery\"\n",
"! pip3 install --upgrade --quiet {USER_FLAG} google-cloud-aiplatform $extra_pkgs"
]
},
{
@@ -214,9 +210,9 @@
},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
"if \"google.colab\" in sys.modules:\n",
" # Automatically restart kernel after installs\n",
" import IPython\n",
"\n",
@@ -227,279 +223,42 @@
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
"id": "fc8fb52b5cca"
},
"source": [
"## Before you begin\n",
"### Common setup\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "project_id"
},
"source": [
"#### Set your project ID\n",
"\n",
"**If you don't know your project ID**, you may be able to get your project ID using `gcloud`."
"Now, execute the common setup for the notebook tutorials."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_project_id"
"id": "001a0fcd5d78"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
"# Common code setup for notebook tutorials\n",
"\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.py -O setup.py\n",
"\n",
"%run setup.py --bucket"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_project_id"
"id": "d809f07a8935"
},
"outputs": [],
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n",
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_gcloud_project_id"
},
"outputs": [],
"source": [
"! gcloud config set project $PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "region"
},
"source": [
"#### Region\n",
"# Other Common setup instructions for notebook tutorials\n",
"\n",
"You can also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.md -O setup.md\n",
"\n",
"- Americas: `us-central1`\n",
"- Europe: `europe-west4`\n",
"- Asia Pacific: `asia-east1`\n",
"\n",
"You may not use a multi-regional bucket for training with Vertex AI. Not all regions provide support for all Vertex AI services.\n",
"\n",
"Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "region"
},
"outputs": [],
"source": [
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bucket:custom"
},
"source": [
"### Create a Cloud Storage bucket\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you submit a custom training job using the Vertex SDK, you upload a Python package\n",
"containing your training code to a Cloud Storage bucket. Vertex AI runs\n",
"the code from this package. In this tutorial, Vertex AI also saves the\n",
"trained model that results from your job in the same bucket. You can then\n",
"create an `Endpoint` resource based on this output in order to serve\n",
"online predictions.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bucket"
},
"outputs": [],
"source": [
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_bucket"
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_bucket"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "validate_bucket"
},
"source": [
"Finally, validate access to your Cloud Storage bucket by examining its contents:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
"%load setup.md "
]
},
{
@@ -1319,7 +1078,7 @@
},
"outputs": [],
"source": [
"delete_storage = True\n",
"delete_storage = False\n",
"\n",
"if delete_storage or os.getenv(\"IS_TESTING\"):\n",
" if \"BUCKET_URI\" in globals():\n",
@@ -33,12 +33,12 @@
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
"<img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
+182 -150
View File
@@ -35,44 +35,59 @@ The second stage in MLOps is experimenting in developing one or more baseline mo
### Get Started
[Get started with Vertex AI Training for R](community/ml_ops/stage2/get_started_vertex_training_r.ipynb)
[Get started with Vertex AI Training for Pytorch](get_started_vertex_training_pytorch.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a R custom model.
```
The steps performed include:
- Single node training using a Python package.
- Locally train an R model in a notebook using %%R magic commands
- Create a deployment image with trained R model and serving functions.
- Test the deployment image locally.
- Create a `Vertex AI Model` resource for the deployment image with embedded R model.
- Deploy the deployment image with embedded R model to a `Vertex AI Endpoint` resource.
- Test the deployment image with embedded R model.
- Create a R-to-Python training package.
- Create a training image for training the model.
- Train a R model using `Vertex AI Trainingh` service with the R-to-Python training package.
[Get started with Logging](community/ml_ops/stage2/get_started_with_logging.ipynb)
In this tutorial, you learn how to use Python and Cloud logging awhen training with `Vertex AI`.
The steps performed include:
- Use Python logging to log training configuration/results locally.
- Use Google Cloud Logging to log training configuration/results in cloud storage.
[Get started with Vertex AI Hyperparameter Tuning for XGBoost] (community/ml_ops/stage2/get_started_vertex_hpt_xgboost.ipynb)
In this tutorial, you learn how to use `Vertex AI Hyperparameter Tuning` for training a XGBoost custom model.
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with prebuilt TFHub models](get_started_with_tfhub_models.ipynb)
[Get started with Vertex AI Training for XGBoost](community/ml_ops/stage2/get_started_vertex_training_xgboost.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a XGBoost custom model.
```
The steps performed include:
- Download a TensorFlow Hub prebuilt model.
- Add the task component as a classifier for the CIFAR-10 dataset.
- Fine tune locally the model with transfer learning training.
- Construct a custom training script:
- Get training data from TensorFlow Datasets
- Get model architecture from TensorFlow Hub
- Train then model
- Save model artifacts and upload as Vertex AI Model resource.
```
[Get started with Vertex AI TensorBoard](get_started_vertex_tensorboard.ipynb)
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
[Get started with TabNet builtin algorithm for training tabular models](community/ml_ops/stage2/get_started_with_tabnet.ipynb)
In this notebook, you learn how to run `Vertex AI TabNet` built algorithm for training custom tabular models.
```
The steps performed include:
- Create a TensorBoard callback when training a model.
- Using Tensorboard with locally trained model.
- Using Vertex AI TensorBoard with Vertex AI Training.
```
[Get started with TabNet builtin algorithm for training tabular models](get_started_with_tabnet.ipynb)
```
The steps performed include:
- Get the training data.
- Configure training parameters for the `Vertex AI TabNet` container.
- Train the model using `Vertex AI Training` using CSV data.
@@ -82,50 +97,107 @@ The steps performed include:
- Hyperparameter tuning the `Vertex AI TabNet` model.
- Train the model using `Vertex AI Training` using BigQuery table.
```
[Get started with prebuilt TFHub models](community/ml_ops/stage2/get_started_with_tfhub_models.ipynb)
[Get started with Vertex AI Vizier](get_started_vertex_vizier.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` with prebuilt models from TensorFlow Hub.
```
The steps performed include:
- Download a TensorFlow Hub prebuilt model.
- Add the task component as a classifier for the CIFAR-10 dataset.
- Fine tune locally the model with transfer learning training.
- Construct a custom training script:
- Get training data from TensorFlow Datasets
- Get model architecture from TensorFlow Hub
- Train then model
- Save model artifacts and upload as Vertex AI Model resource.
[Get started with BigQuery ML Training](community/ml_ops/stage2/get_started_bqml_training.ipynb)
In this tutorial, you learn how to use `BigQueryML` (BQML) for training with `Vertex AI`.
The steps performed include:
- Create a local BigQuery table in your project
- Train a BQML model
- Evaluate the BQML model
- Export the BQML model as a cloud model
- Upload the exported model as a `Vertex AI Model` resource
- Hyperparameter tune a BQML model with `Vertex AI Vizier`
- Automatically register a BQML model to `Vertex AI Model Registry`
[Get started with Vertex AI Vizier](community/ml_ops/stage2/get_started_vertex_vizier.ipynb)
In this tutorial, you learn how to use `Vertex AI Vizier` for when training with `Vertex AI`.
The steps performed include:
- Hyperparameter tuning with Random algorithm.
- Hyperparameter tuning with Vizier (Bayesian) algorithm.
```
- Suggesting trials and updating results for Vizier study
[Automl image classfication training with customer managed encryption keys (CMEK)](get_started_with_cmek_training.ipynb)
[Get started with distributed training using DASK](community/ml_ops/stage2/get_started_with_distributed_training_xgboost.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for distributed training of XGBoost model using the OSS package DASK. Additionally, you learn to construct and deploy a custom serving container using a Flask web server.
```
The steps performed include:
- Creating a customer managed encryption key.
- Creating an image dataset with CMEK encryption.
- Train an AutoML model with CMEK encryption.
```
[Get started with Vertex AI distributed training](get_started_vertex_distributed_training.ipynb)
- Construct an XGBoost training script using DASK for distributed training.
- Construct a custom training container.
- Configure a distributed custom training job.
- Execute the custom training job.
- Construct a custom serving container using Flask.
- Upload the trained XGBoost model as a `Vertex AI Model` resource.
- Create a `Vertex AI Endpoint` resource.
- Deploy the `Vertex AI Model` resource to `Vertex AI Endpoint` resource.
- Make a prediction.
[Get started with Vertex AI TensorBoard](community/ml_ops/stage2/get_started_vertex_tensorboard.ipynb)
In this tutorial, you learn how to use `Vertex AI TensorBoard` when training with `Vertex AI`.
```
The steps performed include:
- `MirroredStrategy`: Train on a single VM with multiple GPUs.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with automatic setup of replicas.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with fine grain control of replicas.
- `ReductionServer`: Train on multiple VMS and sync updates across VMS with `Vertex AI Reduction Server`.
- `TPUTraining`: Train with multiple Cloud TPUs.
```
[Get started with Vertex AI Training for scikit-learn](get_started_vertex_training_sklearn.ipynb)
- Create a TensorBoard callback when training a model.
- Using TensorBoard with locally trained model.
- Using Vertex AI TensorBoard with Vertex AI Training.
[Get started with Vertex AI Training for R using R Kernel](community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb)
In this tutorial, you learn how to use `Vertex AI`, using an R kernel, for training and deploying an R custom model.
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Experiments](get_started_vertex_experiments.ipynb)
- Create a custom R training script
- Create a custom R serving script
- Create a custom R deployment (serving) container.
- Train the model using `Vertex AI` custom training.
- Create an `Endpoint` resouce.
- Deploy the `Model` resource (trained R model) to the `Endpoint` resource.
- Make an online prediction.
[Get started Vision API test preprocessing and AutoML text model generation](community/ml_ops/stage2/get_started_with_visionapi_and_automl.ipynb)
In this tutorial, you create an `AutoML` text entity extraction model pre-existing extracted data by generating a custom import file. You deploy this mode for online prediction from a Python script using the `BigQuery`, `Vision AI`, Cloud Storage and `Vertex AI SDK` for Python.
```
The steps performed include:
- Preprocess training files using `Vision AI` APIs to extract the text from PDF files.
- Create a custom import file that includes annotation data based on the sample `BigQuery` dataset.
- Create a `Vertex AI Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Vertex AI Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
[Get started with Vertex AI Experiments](community/ml_ops/stage2/get_started_vertex_experiments.ipynb)
In this tutorial, you learn how to use `Vertex AI Experiments` when training with `Vertex AI`.
The steps performed include:
- Local (notebook) Training
- Create an experiment
- Create a first run in the experiment
@@ -142,23 +214,23 @@ The steps performed include:
- Create a `Vertex AI Training` custom job
- Execute the custom job
- Visualize the experiment results
```
[Get started with Vertex AI Hyperparameter Tuning for XGBoost](get_started_vertex_hpt_xgboost.ipynb)
[AutoML Image Classfication Training with Customer Managed Encryption Keys (CMEK)](community/ml_ops/stage2/get_started_with_cmek_training.ipynb)
In this tutorial, you learn how to use a customer managed encryption key (CMEK) for `Vertex AI AutoML` training.
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
- Creating a customer managed encryption key.
- Creating an image dataset with CMEK encryption.
- Train an AutoML model with CMEK encryption.
[Get started with Vertex AI Feature Store](get_started_vertex_feature_store.ipynb)
[Get started with Vertex AI Feature Store](community/ml_ops/stage2/get_started_vertex_feature_store.ipynb)
In this tutorial, you learn how to use `Vertex AI Feature Store` when training and predicting with `Vertex AI`.
```
The steps performed include:
- Creating a Vertex AI `Featurestore` resource.
- Creating `EntityType` resources for the `Featurestore` resource.
- Creating `Feature` resources for each `EntityType` resource.
@@ -167,96 +239,26 @@ The steps performed include:
- From a pandas DataFrame.
- Perform online serving from a `Featurestore` resource.
- Perform batch serving from a `Featurestore` resource.
```
[Get started with Vertex AI Training for R](get_started_vertex_training_r.ipynb)
[Get started with AutoML Training](community/ml_ops/stage2/get_started_automl_training.ipynb)
In this tutorial, you learn how to use `AutoML` for training with `Vertex AI`.
```
The steps performed include:
- Locally train an R model in a notebook using %%R magic commands
- Create a deployment image with trained R model and serving functions.
- Test the deployment image locally.
- Create a `Vertex AI Model` resource for the deployment image with embedded R model.
- Deploy the deployment image with embedded R model to a `Vertex AI Endpoint` resource.
- Test the deployment image with embedded R model.
- Create a R-to-Python training package.
- Create a training image for training the model.
- Train a R model using `Vertex AI Trainingh` service with the R-to-Python training package.
```
[Get started with logging](get_started_with_logging.ipynb)
```
The steps performed include:
- Use Python logging to log training configuration/results locally.
- Use Google Cloud Logging to log training configuration/results in cloud storage.
```
[Get started with Vertex AI Training for R using R Kernel](get_started_vertex_training_r_using_r_kernel.ipynb)
```
The steps performed include:
- Create a custom R training script
- Create a custom R serving script
- Create a custom R deployment (serving) container.
- Train the model using `Vertex AI` custom training.
- Create an `Endpoint` resouce.
- Deploy the `Model` resource (trained R model) to the `Endpoint` resource.
- Make an online prediction.
```
[Get started with BigQuery ML training](get_started_bqml_training.ipynb)
```
The steps performed include:
- Create a local BigQuery table in your project
- Train a BQML model
- Evaluate the BQML model
- Export the BQML model as a cloud model
- Upload the exported model as a `Vertex AI Model` resource
- Hyperparameter tune a BQML model with `Vertex AI Vizier`
- Automatically register a BQML model to `Vertex AI Model Registry`
```
[Get started with AutoML training](get_started_automl_training.ipynb)
```
The steps performed include:
- Train an image model
- Export the image model as an edge model
- Train a tabular model
- Export the tabular model as a cloud model
- Train a text model
- Train a video model
```
[Get started with Vertex AI Training for XGBoost](get_started_vertex_training_xgboost.ipynb)
[Get started with Vertex AI Training for LightGBM](community/ml_ops/stage2/get_started_vertex_training_lightgbm.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a LightGBM custom model.
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Training](get_started_vertex_training.ipynb)
```
The steps performed include:
- Training using a single Python script.
- Training using a Python package.
- Training using a custom training image.
- Laying out a training package.
```
[Get started with Vertex AI Training for LightGBM](get_started_vertex_training_lightgbm.ipynb)
```
The steps performed include:
- Training using a Python package.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Construct a FastAPI prediction server.
@@ -264,21 +266,51 @@ The steps performed include:
- Test the deployment image locally.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Training for Scikit-Learn](community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb)
[Get started Vision API test preprocessing and AutoML text model generation](get_started_with_visionapi_and_automl.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a Scikit-Learn custom model.
```
The steps performed include:
- Preprocess training files using `Vision AI` APIs to extract the text from PDF files.
- Create a custom import file that includes annotation data based on the sample `BigQuery` dataset.
- Create a `Vertex AI Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Vertex AI Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
```
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
[Get started with Vertex AI Training](community/ml_ops/stage2/get_started_vertex_training.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for custom models when training with `Vertex AI`.
The steps performed include:
- Training using a single Python script.
- Training using a Python package.
- Training using a custom training image.
- Laying out a training package.
[Get started with Vertex AI Training for Pytorch](community/ml_ops/stage2/get_started_vertex_training_pytorch.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a Pytorch custom model.
The steps performed include:
- Single node training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
[Get started with Vertex AI Distributed Training](community/ml_ops/stage2/get_started_vertex_distributed_training.ipynb)
In this tutorial, you learn how to use `Vertex AI Distributed Training` for when training with `Vertex AI`.
The steps performed include:
- `MirroredStrategy`: Train on a single VM with multiple GPUs.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with automatic setup of replicas.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with fine grain control of replicas.
- `ReductionServer`: Train on multiple VMS and sync updates across VMS with `Vertex AI Reduction Server`.
- `TPUTraining`: Train with multiple Cloud TPUs.
### E2E Stage Example
File diff suppressed because it is too large Load Diff
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `BigQueryML` (BQML) for training with `Vertex AI`.\n",
"In this tutorial, you learn how to use `BigQueryML` for training with `Vertex AI`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -84,12 +84,12 @@
"The steps performed include:\n",
"\n",
"- Create a local BigQuery table in your project\n",
"- Train a BQML model\n",
"- Evaluate the BQML model\n",
"- Export the BQML model as a cloud model\n",
"- Train a BigQuery ML model\n",
"- Evaluate the BigQuery ML model\n",
"- Export the BigQuery ML model as a cloud model\n",
"- Upload the exported model as a `Vertex AI Model` resource\n",
"- Hyperparameter tune a BQML model with `Vertex AI Vizier`\n",
"- Automatically register a BQML model to `Vertex AI Model Registry`"
"- Hyperparameter tune a BigQuery ML model with `Vertex AI Vizier`\n",
"- Automatically register a BigQuery ML model to `Vertex AI Model Registry`"
]
},
{
@@ -749,9 +749,9 @@
"id": "bqml_create_model"
},
"source": [
"### Train BQML model\n",
"### Train BigQuery ML model\n",
"\n",
"Next, you create and train a BQML tabular classification model from the public dataset penguins and store the model in your project using the `CREATE MODEL` statement. The model configuration is specified in the `OPTIONS` statement as follows:\n",
"Next, you create and train a BigQuery ML tabular classification model from the public dataset penguins and store the model in your project using the `CREATE MODEL` statement. The model configuration is specified in the `OPTIONS` statement as follows:\n",
"\n",
"- `model_type`: The type and archictecture of tabular model to train, e.g., DNN classification.\n",
"- `labels`: The column which are the labels.\n",
@@ -800,9 +800,9 @@
"id": "bqml_eval_model"
},
"source": [
"### Evaluate the trained BQML model\n",
"### Evaluate the trained BigQuery ML model\n",
"\n",
"Next, retrieve the model evaluation for the trained BQML model.\n",
"Next, retrieve the model evaluation for the trained BigQuery ML model.\n",
"\n",
"Learn more about [The ML.EVALUATE function](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-evaluate)."
]
@@ -833,9 +833,9 @@
"id": "bqml_export_model"
},
"source": [
"### Export the model from BQML\n",
"### Export the model from BigQuery ML\n",
"\n",
"The model you trained in BQML is a TensorFlow model. Next, you export the TensorFlow model artifacts in TF.SavedModel format."
"The model you trained in BigQuery ML is a TensorFlow model. Next, you export the TensorFlow model artifacts in TF.SavedModel format."
]
},
{
@@ -1028,9 +1028,9 @@
"id": "bqml_create_model:vizier"
},
"source": [
"### Hyperparameter Tune and train a BQML model\n",
"### Hyperparameter Tune and train a BigQuery ML model\n",
"\n",
"Next, you train a BQML tabular classification model with hyperparameter tuning using the `Vertex AI Vizier` service. The hyperparameter settings are specified in the `OPTIONS` statement as follows:\n",
"Next, you train a BigQuery ML tabular classification model with hyperparameter tuning using the `Vertex AI Vizier` service. The hyperparameter settings are specified in the `OPTIONS` statement as follows:\n",
"\n",
"- `HPARAM_TUNING_ALGORITHM`: The algorithm for selecting the next trial parameters.\n",
"- `num_trials`: The number of trials.\n",
@@ -1083,9 +1083,9 @@
"id": "bqml_eval_model"
},
"source": [
"### Evaluate the BQML trained model\n",
"### Evaluate the BigQuery ML trained model\n",
"\n",
"Next, retrieve the model evaluation results for the trained BQML model.\n",
"Next, retrieve the model evaluation results for the trained BigQuery ML model.\n",
"\n",
"Learn more about [The ML.EVALUATE function](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-evaluate)."
]
@@ -1142,9 +1142,9 @@
"id": "bqml_create_model:xai"
},
"source": [
"### Train a BQML model with Explainability\n",
"### Train a BigQuery ML model with Explainability\n",
"\n",
"Next, you train the same BQML model, but this time you enable Vertex AI Explainability on the model predictions by adding the option:\n",
"Next, you train the same BigQuery ML model, but this time you enable Vertex AI Explainability on the model predictions by adding the option:\n",
"\n",
"- `ENABLE_GLOBAL_EXPLAIN`"
]
@@ -87,7 +87,7 @@
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `Vertex AI Experiments`\n",
"- `Vertex AI ML Metadata`\n",
"- `Vertex ML Metadata`\n",
"- `Vertex AI Training`\n",
"\n",
"The steps performed include:\n",
File diff suppressed because it is too large Load Diff
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/notebook_template.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_tensorboard.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -48,7 +48,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_lightgbm.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_lightgbm.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for Pytorch\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for PyTorch\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/notebook_template.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_pytorch.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -62,7 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for Pytorch."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for PyTorch."
]
},
{
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `Vertex AI Training` for training a Pytorch custom model.\n",
"In this tutorial, you learn how to use `Vertex AI Training` for training a PyTorch custom model.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -97,7 +97,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [CIFAR10 dataset](https://pytorch.org/vision/stable/datasets.html#cifar) from [Pytorch Datasets](https://pytorch.org/vision/stable/datasets.html). The version of the dataset is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, or truck."
"The dataset used for this tutorial is the [CIFAR10 dataset](https://pytorch.org/vision/stable/datasets.html#cifar) from [PyTorch Datasets](https://pytorch.org/vision/stable/datasets.html). The version of the dataset is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, or truck."
]
},
{
@@ -672,17 +672,17 @@
"id": "pytorch_intro"
},
"source": [
"## Introduction to Pytorch training\n",
"## Introduction to PyTorch training\n",
"\n",
"The Pytorch package supports both single node and distributed model training.\n",
"The PyTorch package supports both single node and distributed model training.\n",
"\n",
"Once you have trained a Pytorch model, you will want to save it at a Cloud Storage location, so it can subsequently be uploaded to a `Vertex AI Model` resource.\n",
"The Pytorch package does not have support to save the model to a Cloud Storage location. Instead, you will do the following steps to save to a Cloud Storage location.\n",
"Once you have trained a PyTorch model, you will want to save it at a Cloud Storage location, so it can subsequently be uploaded to a `Vertex AI Model` resource.\n",
"The PyTorch package does not have support to save the model to a Cloud Storage location. Instead, you will do the following steps to save to a Cloud Storage location.\n",
"\n",
"1. Save the in-memory model to the local filesystem (e.g., model.pth).\n",
"2. Use gsutil to copy the local copy to the specified Cloud Storage location.\n",
"\n",
"*Note*: You can do hyperparameter tuning with a Pytorch model."
"*Note*: You can do hyperparameter tuning with a PyTorch model."
]
},
{
@@ -1069,9 +1069,9 @@
"id": "docker_write,prediction,pytorch"
},
"source": [
"### Make Pytorch container for prediction\n",
"### Make PyTorch container for prediction\n",
"\n",
"Currently, Vertex AI does not have a predefined container for making predictions with a deployed Pytorch model. No problem, you can assemble your own custom container. Typically, one would base the container on the `Torch Server`. For demonstration purpose, you build a placeholder container (not complete) that includes the latest `Torch Server` image, and push it to the `Container Registry`."
"Currently, Vertex AI does not have a predefined container for making predictions with a deployed PyTorch model. No problem, you can assemble your own custom container. Typically, one would base the container on the `Torch Server`. For demonstration purpose, you build a placeholder container (not complete) that includes the latest `Torch Server` image, and push it to the `Container Registry`."
]
},
{
@@ -43,7 +43,7 @@
"<table align=\"left\">\n",
"\n",
" <td>\n",
" <a href=\"https://colab.sandbox.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
@@ -109,7 +109,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is [California Housing Dataset](https://www.dcc.fc.up.pt/~ltorgo/Regression/cal_housing.html). The data contains information from the 1990 California census. The data set is publicly available from Google Cloud Storage at `gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv`. The dataset is used to train a Random Forest regressor to predict a median housing price, given a longitude and lattitude along with data from the corresponding census block group. A block group is the smallest geographical unit for which the U.S. Census Bureau publishes sample data (a block group typically has a population of 600 to 3,000 people).\n"
"The dataset used for this tutorial is [California Housing Dataset](https://www.dcc.fc.up.pt/~ltorgo/Regression/cal_housing.html). The data contains information from the 1990 California census. The data set is publicly available from Cloud Storage at `gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv`. The dataset is used to train a Random Forest regressor to predict a median housing price, given a longitude and lattitude along with data from the corresponding census block group. A block group is the smallest geographical unit for which the U.S. Census Bureau publishes sample data (a block group typically has a population of 600 to 3,000 people).\n"
]
},
{
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
"Open in Vertex AI Workbench\n",
" </a>\n",
@@ -297,25 +297,32 @@
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
"id": "06571eb4063b"
},
"source": [
"#### Timestamp\n",
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "JYtXOocrox9Q"
"id": "4e166d927e36"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import random\n",
"import string\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
@@ -362,12 +369,11 @@
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
@@ -402,7 +408,8 @@
},
"outputs": [],
"source": [
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -413,8 +420,9 @@
},
"outputs": [],
"source": [
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -749,6 +757,7 @@
"import hypertune\n",
"import argparse\n",
"import logging\n",
"import numpy as np\n",
"\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.metrics import accuracy_score\n",
@@ -790,16 +799,23 @@
"def train_model(dtrain):\n",
" logging.info(\"Start training ...\")\n",
" # Train XGBoost model\n",
" model = xgb.train({}, dtrain, num_boost_round=args.boost_rounds)\n",
" params = {\n",
" 'objective': 'multi:softprob',\n",
" 'num_class': 3\n",
" }\n",
" model = xgb.train(params, dtrain, num_boost_round=args.boost_rounds)\n",
" logging.info(\"Training completed\")\n",
" return model\n",
"\n",
"def evaluate_model(model, test_data, test_labels):\n",
" dtest = xgb.DMatrix(test_data)\n",
" pred = model.predict(dtest)\n",
" predictions = [round(value) for value in pred]\n",
" predictions = [np.around(value) for value in pred]\n",
" # evaluate predictions\n",
" accuracy = accuracy_score(test_labels, predictions)\n",
" try:\n",
" accuracy = accuracy_score(test_labels, predictions)\n",
" except:\n",
" accuracy = 0.0\n",
" logging.info(f\"Evaluation completed with model accuracy: {accuracy}\")\n",
"\n",
" # report metric for hyperparameter tuning\n",
@@ -893,7 +909,7 @@
},
"outputs": [],
"source": [
"DISPLAY_NAME = \"iris_\" + TIMESTAMP\n",
"DISPLAY_NAME = \"iris_\" + UUID\n",
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
@@ -932,7 +948,7 @@
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, UUID)\n",
"DATASET_DIR = \"gs://cloud-samples-data/ai-platform/iris\"\n",
"\n",
"ROUNDS = 20\n",
@@ -983,7 +999,7 @@
"source": [
"if TRAIN_GPU:\n",
" model = job.run(\n",
" model_display_name=\"iris_\" + TIMESTAMP,\n",
" model_display_name=\"iris_\" + UUID,\n",
" args=CMDARGS,\n",
" replica_count=1,\n",
" machine_type=TRAIN_COMPUTE,\n",
@@ -994,7 +1010,7 @@
" )\n",
"else:\n",
" model = job.run(\n",
" model_display_name=\"iris_\" + TIMESTAMP,\n",
" model_display_name=\"iris_\" + UUID,\n",
" args=CMDARGS,\n",
" replica_count=1,\n",
" machine_type=TRAIN_COMPUTE,\n",
@@ -1095,7 +1111,7 @@
},
"outputs": [],
"source": [
"delete_bucket = False\n",
"delete_bucket = True\n",
"\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use Python and Cloud logging awhen training with `Vertex AI`.\n",
"In this tutorial, you learn how to use Python and Cloud logging when training with `Vertex AI`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -116,7 +116,7 @@
"\n",
"The dataset used for this tutorial is the [Patent PDF Samples with Extracted Structured Data](https://console.cloud.google.com/marketplace/product/global-patents/labeled-patents) from Google Public Data Sets. \n",
"\n",
"This dataset includes data extracted from over 300 patent documents issued in the US and EU. The dataset includes links to Google Cloud Storage blobs for the first page of each patent, in addition to a number of extracted entities. \n",
"This dataset includes data extracted from over 300 patent documents issued in the US and EU. The dataset includes links to Cloud Storage blobs for the first page of each patent, in addition to a number of extracted entities. \n",
"\n",
"The data is published as a [public dataset](https://cloud.google.com/bigquery/public-data) on `BigQuery`."
]
+160 -147
View File
@@ -33,10 +33,144 @@ The third stage in MLOps is formalization to develop an automated pipeline proce
### Get Started
[Get started with AutoML Tabular Pipeline Workflows](get_started_with_automl_tabular_pipeline_workflow.ipynb)
```
[Get started with Vertex AI Model Registry](community/ml_ops/stage3/get_started_with_model_registry.ipynb)
In this tutorial, you learn how to use `Vertex AI Model Registry` to create and register multiple versions of a model.
The steps performed include:
- Create and register a first version of a model to `Vertex AI Model Registry`.
- Create and register a second version of a model to `Vertex AI Model Registry`.
- Updating the model version which is the default (blessed).
- Deleting a model version.
- Retraining the next model version.
[Get started with Dataflow pipeline components](community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataflow`.
The steps performed include:
- Build an Apache Beam data pipeline.
- Encapsulate the Apache Beam data pipeline with a Dataflow component in a Vertex AI pipeline.
- Execute a Vertex AI pipeline.
[Get started with Apache Airflow and Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_airflow_and_vertex_pipelines.ipynb)
In this tutorial, you learn how to use Apache Airflow with `Vertex AI Pipelines`.
The steps performed include:
- Create Cloud Composer environment.
- Upload Airflow DAG to Composer environment that performs data processing -- i.e., creates a BigQuery table from a CSV file.
- Create a `Vertex AI Pipeline` that triggers the Airflow DAG.
- Execute the `Vertex AI Pipeline`.
[Get started with Kubeflow Pipelines](community/ml_ops/stage3/get_started_with_kubeflow_pipelines.ipynb)
In this tutorial, you learn how to use `Kubeflow Pipelines`(KFP).
The steps performed include:
- Building KFP lightweight Python function components.
- Assembling and compiling KFP components into a pipeline.
- Executing a KFP pipeline using Vertex AI Pipelines.
- Loading component and pipeline definitions from a source code repository.
- Building sequential, parallel, multiple output components.
- Building control flow into pipelines.
[Get started with Vertex AI custom training pipeline components](community/ml_ops/stage3/get_started_with_custom_training_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Training`.
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI custom trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
- Construct a pipeline for:
- Construct a custom training component.
- Convert custom training component to CustomTrainingJobOp.
- Training a Vertex AI custom trained model using the converted component.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
[Get started with Dataproc Serverless pipeline components](community/ml_ops/stage3/get_started_with_dataproc_serverless_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataproc Serverless` service.
The steps performed include:
- `DataprocPySparkBatchOp` for running PySpark batch workloads.
- `DataprocSparkBatchOp` for running Spark batch workloads.
- `DataprocSparkSqlBatchOp` for running Spark SQL batch workloads.
- `DataprocSparkRBatchOp` for running SparkR batch workloads.
[Get started with Vertex AI Hyperparameter Tuning pipeline components](community/ml_ops/stage3/get_started_with_hpt_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Hyperparameter Tuning`.
The steps performed include:
- Construct a pipeline for:
- Hyperparameter tune/train a custom model.
- Retrieve the tuned hyperparameter values and metrics to optimize.
- If the metrics exceed a specified threshold.
- Get the location of the model artifacts for the best tuned model.
- Upload the model artifacts to a `Vertex AI Model` resource.
- Execute a Vertex AI pipeline.
[Get started with machine management for Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_machine_management.ipynb)
In this tutorial, you convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:
- The training job and artifacts are trackable.
- Set machine resources, such as machine-type, cpu/gpu, memory, disk, etc.
The steps performed in this tutorial include:
- Create a custom component with a self-contained training job.
- Execute pipeline using component-level settings for machine resources
- Convert the self-contained training component into a `Vertex AI CustomJob`.
- Execute pipeline using customjob-level settings for machine resources
[Get started with TFX pipelines](community/ml_ops/stage3/get_started_with_tfx_pipeline.ipynb)
In this tutorial, you learn how to use TensorFlow Extended (TFX) with `Vertex AI Pipelines`.
The steps performed include:
- Create a TFX e2e pipeline.
- Execute the pipeline locally.
- Execute the pipeline on Google Cloud using `Vertex AI Training`
- Execute the pipeline using `Vertex AI Pipelines`.
[Get started with BigQuery ML pipeline components](community/ml_ops/stage3/get_started_with_bqml_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `BigQuery ML`.
The steps performed include:
- Construct a pipeline for:
- Training BigQuery ML model.
- Evaluating the BigQuery ML model.
- Exporting the BigQuery ML model.
- Importing the BigQuery ML model to a Vertex AI model.
- Deploy the Vertex AI model.
- Execute a Vertex AI pipeline.
- Make a prediction with the deployed Vertex AI model.
[Get started with AutoML tabular pipeline workflows](community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb)
In this tutorial, you learn how to use `AutoML Tabular Pipeline Template` for training, exporting and tuning an AutoML tabular model.
The steps performed include:
- Define training specification.
- Dataset specification
- Hyperparameter overide specification
@@ -49,162 +183,41 @@ The steps performed include:
- Deploy exported OSS TF model.
- Make a prediction.
```
[Get started with rapid prototyping with AutoML and BigQuery ML](community/ml_ops/stage3/get_started_with_rapid_prototyping_bqml_automl.ipynb)
[Get started with Vertex AI Model Registry](get_started_with_model_registry.ipynb)
In this tutorial, you learn how to use `Vertex AI Predictions` for rapid prototyping a model.
```
The steps performed include:
- Create and register a first version of a model to `Vertex AI Model Registry`.
- Create and register a second version of a model to `Vertex AI Model Registry`.
- Updating the model version which is the default (blessed).
- Deleting a model version.
- Retraining the next model version.
```
[Get started with Dataproc serverless pipeline components](get_started_with_dataproc_serverless_pipeline_components.ipynb)
```
The steps performed include:
- `DataprocPySparkBatchOp` for running PySpark batch workloads.
- `DataprocSparkBatchOp` for running Spark batch workloads.
- `DataprocSparkSqlBatchOp` for running Spark SQL batch workloads.
- `DataprocSparkRBatchOp` for running SparkR batch workloads.
```
[Get started with TFX pipelines](get_started_with_tfx_pipeline.ipynb)
```
The steps performed include:
- Create a TFX e2e pipeline.
- Execute the pipeline locally.
- Execute the pipeline on Google Cloud using `Vertex AI Training`
- Execute the pipeline using `Vertex AI Pipelines`.
```
[Get started with Vertex AI Hyperparameter Tuning pipeline components](get_started_with_hpt_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Hyperparameter tune/train a custom model.
- Retrieve the tuned hyperparameter values and metrics to optimize.
- If the metrics exceed a specified threshold.
- Get the location of the model artifacts for the best tuned model.
- Upload the model artifacts to a `Vertex AI Model` resource.
- Execute a Vertex AI pipeline.
```
[Get started with Apache Airflow and Vertex AI Pipelines](get_started_with_airflow_and_vertex_pipelines.ipynb)
```
The steps performed include:
- Create Cloud Composer environment.
- Upload Airflow DAG to Composer environment that performs data processing -- i.e., creates a BigQuery table from a CSV file.
- Create a `Vertex AI Pipeline` that triggers the Airflow DAG.
- Execute the `Vertex AI Pipeline`.
```
[Get started with Vertex AI custom training pipeline components](get_started_with_custom_training_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI custom trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
- Construct a pipeline for:
- Construct a custom training component.
- Convert custom training component to CustomTrainingJobOp.
- Training a Vertex AI custom trained model using the converted component.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
```
[Get started with AutoML pipeline components](get_started_with_automl_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI AutoML trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI AutoML trained model.
- Execute a Vertex AI pipeline.
```
[Get started with Kubeflow pipelines](get_started_with_kubeflow_pipelines.ipynb)
```
The steps performed include:
- Building KFP lightweight Python function components.
- Assembling and compiling KFP components into a pipeline.
- Executing a KFP pipeline using Vertex AI Pipelines.
- Loading component and pipeline definitions from a source code repository.
- Building sequential, parallel, multiple output components.
- Building control flow into pipelines.
```
[Get started with machine management for Vertex AI Pipelines](get_started_with_machine_management.ipynb)
```
The steps performed in this tutorial include:
- Create a custom component with a self-contained training job.
- Execute pipeline using component-level settings for machine resources
- Convert the self-contained training component into a `Vertex AI CustomJob`.
- Execute pipeline using customjob-level settings for machine resources
```
[Get started with BigQuery and TFDV pipeline components](get_started_with_bq_tfdv_pipeline_components.ipynb)
```
The steps performed include:
- Build and execute a pipeline component for creating a Vertex AI Tabular Dataset from a BigQuery table.
- Build and execute a pipeline component for generating TFDV statistics and schema from a Vertex AI Tabular Dataset.
- Execute a Vertex AI pipeline.
```
[Get started with Dataflow pipeline components](get_started_with_dataflow_pipeline_components.ipynb)
```
The steps performed include:
- Build an Apache Beam data pipeline.
- Encapsulate the Apache Beam data pipeline with a Dataflow component in a Vertex AI pipeline.
- Execute a Vertex AI pipeline.
```
[Get started with BigQuery ML pipeline components](get_started_with_bqml_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Training BigQuery ML model.
- Evaluating the BigQuery ML model.
- Exporting the BigQuery ML model.
- Importing the BigQuery ML model to a Vertex AI model.
- Deploy the Vertex AI model.
- Execute a Vertex AI pipeline.
- Make a prediction with the deployed Vertex AI model.
```
[Get started with rapid prototyping with AutoML and BigQuery ML](get_started_with_rapid_prototyping_bqml_automl.ipynb)
```
The steps performed include:
- Creating a BigQuery and Vertex AI training dataset.
- Training a BigQuery ML and AutoML model.
- Extracting evaluation metrics from the BigQueryML and AutoML models.
- Selecting the best trained model.
- Deploying the best trained model.
- Testing the deployed model infrastructure.
```
[Get started with AutoML pipeline components](community/ml_ops/stage3/get_started_with_automl_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI AutoML`.
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI AutoML trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI AutoML trained model.
- Execute a Vertex AI pipeline.
[Get started with BigQuery and TFDV pipeline components](community/ml_ops/stage3/get_started_with_bq_tfdv_pipeline_components.ipynb)
In this tutorial, you learn how to use build lightweight Python components for BigQuery and TensorFlow Data Validation.
The steps performed include:
- Build and execute a pipeline component for creating a Vertex AI Tabular Dataset from a BigQuery table.
- Build and execute a pipeline component for generating TFDV statistics and schema from a Vertex AI Tabular Dataset.
- Execute a Vertex AI pipeline.
### E2E Stage Example
@@ -568,7 +568,6 @@
},
"outputs": [],
"source": [
"import kfp\n",
"from google.cloud import aiplatform\n",
"from kfp import dsl\n",
"from kfp.v2 import compiler\n",
@@ -1000,11 +999,7 @@
" from google.auth.transport.requests import Request\n",
" from google.oauth2 import id_token\n",
"\n",
" IAM_SCOPE = \"https://www.googleapis.com/auth/iam\"\n",
" OAUTH_TOKEN_URI = \"https://www.googleapis.com/oauth2/v4/token\"\n",
"\n",
" data = '{\"replace_microseconds\":\"false\"}'\n",
" context = None\n",
"\n",
" \"\"\"Makes a POST request to the Composer DAG Trigger API\n",
"\n",
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -39,9 +39,9 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb\">\n",
"<img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> \n",
" Colab logo Run in Colab\n",
" Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
@@ -81,7 +81,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:\n",
"In this tutorial, you learn how to convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:\n",
"\n",
" - The training job and artifacts are trackable.\n",
" - Set machine resources, such as machine-type, cpu/gpu, memory, disk, etc.\n",
@@ -569,7 +569,6 @@
"source": [
"import json\n",
"\n",
"import numpy as np\n",
"from google.cloud import aiplatform\n",
"from google_cloud_pipeline_components.v1.custom_job import \\\n",
" create_custom_training_job_from_component\n",
@@ -797,7 +796,6 @@
" epochs: int,\n",
") -> str:\n",
" import numpy as np\n",
" import tensorflow as tf\n",
"\n",
" def get_data():\n",
" from tensorflow.keras.datasets import mnist\n",
@@ -904,7 +902,7 @@
" },\n",
" ).after(training_job_task)\n",
"\n",
" model_upload = ModelUploadOp(\n",
" _ = ModelUploadOp(\n",
" project=project,\n",
" display_name=\"mnist_model\",\n",
" unmanaged_container_model=import_unmanaged_model_task.outputs[\"artifact\"],\n",
@@ -1180,7 +1178,7 @@
" },\n",
" ).after(training_job_task)\n",
"\n",
" model_upload = ModelUploadOp(\n",
" _ = ModelUploadOp(\n",
" project=project,\n",
" display_name=\"mnist_model\",\n",
" unmanaged_container_model=import_unmanaged_model_task.outputs[\"artifact\"],\n",
@@ -60,7 +60,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI Pipelines to rapid prototype a model using both AutoML and BQML, do an evaluation comparison, for a baseline, before progressing to a custom model.\n",
"This tutorial demonstrates how to use Vertex AI Pipelines to rapid prototype a model using both AutoML and BigQuery ML, do an evaluation comparison, for a baseline, before progressing to a custom model.\n",
"\n",
"<img src=\"https://storage.googleapis.com/rafacarv-public-bucket-do-not-delete/abalone/automl_and_bqml.png\" />"
]
@@ -834,7 +834,7 @@
"source": [
"### Create component: Split the dataset into train, test and eval\n",
"\n",
"For this pipeline, you set aside a portion of the dataset for test evaluation. While both AutoML and BQML will automatically split then datasets, in this example you will explicitly split the datasets into:\n",
"For this pipeline, you set aside a portion of the dataset for test evaluation. While both AutoML and BigQuery ML will automatically split then datasets, in this example you will explicitly split the datasets into:\n",
"\n",
"- TRAIN\n",
"- EVALUATE\n",
@@ -1000,11 +1000,11 @@
"- Construct the CREATE MODEL query using a static Python function `_create_model_query()`, which runs in the context of the pipeline.\n",
"- Call the prebuilt component `BigQueryCreateModelOp`, with the constructed query, to train the BigQuery ML model.\n",
"\n",
"For this tutorial, you use a simple linear regression model on BQML. \n",
"For this tutorial, you use a simple linear regression model on BigQuery ML. \n",
"\n",
"For a full list of models supported by BQML, look here: [End-to-end user journey for each model](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-e2e-journey).\n",
"For a full list of models supported by BigQuery ML, look here: [End-to-end user journey for each model](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-e2e-journey).\n",
"\n",
"As pointed out before, BQML and AutoML use different split terminologies, so we do an adaptation of the <i>split_col</i> column directly on the SELECT portion of the CREATE model query:\n",
"As pointed out before, BigQuery ML and AutoML use different split terminologies, so we do an adaptation of the <i>split_col</i> column directly on the SELECT portion of the CREATE model query:\n",
"\n",
"> When the value of DATA_SPLIT_METHOD is 'CUSTOM', the corresponding column should be of type BOOL. The rows with TRUE or NULL values are used as evaluation data. Rows with FALSE values are used as training data."
]
File diff suppressed because it is too large Load Diff
@@ -658,8 +658,6 @@
},
"outputs": [],
"source": [
"from typing import NamedTuple\n",
"\n",
"from kfp import dsl\n",
"from kfp.v2 import compiler\n",
"from kfp.v2.dsl import component"
@@ -1866,7 +1864,7 @@
" exported_tfrec_prefix=exported_tfrec_prefix,\n",
" ).after(dataflow_wait_op)\n",
"\n",
" dataset_op = gcc_aip.TabularDatasetCreateOp(\n",
" _ = gcc_aip.TabularDatasetCreateOp(\n",
" project=project,\n",
" display_name=display_name,\n",
" bq_source=bq_table,\n",
@@ -2285,7 +2283,7 @@
" },\n",
" ).after(model_build_op)\n",
"\n",
" model_upload = ModelUploadOp(\n",
" _ = ModelUploadOp(\n",
" project=project,\n",
" display_name=display_name,\n",
" unmanaged_container_model=import_unmanaged_model_task.outputs[\"artifact\"],\n",
@@ -3205,7 +3203,7 @@
"\n",
" with dsl.Condition(warmup == \"True\", name=\"warmup-model\"):\n",
"\n",
" warmup_op = gcc_aip.CustomPythonPackageTrainingJobRunOp(\n",
" _ = gcc_aip.CustomPythonPackageTrainingJobRunOp(\n",
" project=project,\n",
" display_name=display_name,\n",
" # Warmup Training\n",
@@ -3249,7 +3247,7 @@
" display_name=display_name,\n",
" ).after(training_op)\n",
"\n",
" deploy_op = ModelDeployOp(\n",
" _ = ModelDeployOp(\n",
" model=training_op.outputs[\"model\"],\n",
" endpoint=endpoint_op.outputs[\"endpoint\"],\n",
" dedicated_resources_min_replica_count=1,\n",
+171 -83
View File
@@ -42,104 +42,192 @@ This stage may be done entirely by MLOps. We recommend:
### Get Started
[Get started with Vertex Explainable AI](get_started_with_vertex_xai.ipynb)
```
[Get started with Vertex AI Model Registry](community/ml_ops/stage3/get_started_with_model_registry.ipynb)
In this tutorial, you learn how to use `Vertex AI Model Registry` to create and register multiple versions of a model.
The steps performed include:
- Train an AutoML tabular model.
- Do a batch prediction with explanations.
- Do an online prediction with explanations.
- Train an custom TensorFlow tabular model.
- Manually set configuration metadata.
- Do a batch prediction with explanations.
- Do an online prediction with explanations.
- Automatically set configuration metadata.
- Train an custom TensorFlow image model.
- Manually set configuration metadata.
- Do a batch prediction with explanations.
- Do an online prediction with explanations.
- Train an custom XGBoost tabular model.
- Manually set configuration metadata.
- Do an online prediction with explanations.
- Train an custom scikit-learn tabular model.
- Manually set configuration metadata.
- Do an online prediction with explanations.
```
- Create and register a first version of a model to `Vertex AI Model Registry`.
- Create and register a second version of a model to `Vertex AI Model Registry`.
- Updating the model version which is the default (blessed).
- Deleting a model version.
- Retraining the next model version.
[Get started with Google Artifact Registry](get_started_with_google_artifact_registry.ipynb)
[Get started with Dataflow pipeline components](community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataflow`.
```
The steps performed include:
- Creating a private Docker repository.
- Tagging a container image, specific to the private Docker repository.
- Pushing a container image to the private Docker repository.
- Pulling a container image from the private Docker repository.
- Deleting a private Docker repository.
```
[Get started with AutoML training and ML Metadata](get_started_with_vertex_ml_metadata_and_automl.ipynb)
- Build an Apache Beam data pipeline.
- Encapsulate the Apache Beam data pipeline with a Dataflow component in a Vertex AI pipeline.
- Execute a Vertex AI pipeline.
[Get started with Apache Airflow and Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_airflow_and_vertex_pipelines.ipynb)
In this tutorial, you learn how to use Apache Airflow with `Vertex AI Pipelines`.
```
The steps performed include:
- Create a `Dataset` resource.
- Create a corresponding `google.VertexDataset` artifact.
- Train a model using `AutoML`.
- Create a corresponding `google.VertexModel` artifact.
- Create an `Endpoint` resource.
- Create a corresponding `google.Endpoint` artifact.
- Deploy the train model to the `Endpoint`.
- Create an execution and context for the `AutoML` training job and deployment.
- Add the corresponding artifacts and context to the execution.
- Add artifact links (event) to the execution.
- Display the execution graph.
```
[Get started with Vertex AI ML Metadata](get_started_with_vertex_ml_metadata.ipynb)
- Create Cloud Composer environment.
- Upload Airflow DAG to Composer environment that performs data processing -- i.e., creates a BigQuery table from a CSV file.
- Create a `Vertex AI Pipeline` that triggers the Airflow DAG.
- Execute the `Vertex AI Pipeline`.
[Get started with Kubeflow Pipelines](community/ml_ops/stage3/get_started_with_kubeflow_pipelines.ipynb)
In this tutorial, you learn how to use `Kubeflow Pipelines`(KFP).
```
The steps performed include:
- Create a `Metadatastore` resource.
- Create (record)/List an `Artifact`, with artifacts and metadata.
- Create (record)/List an `Execution`.
- Create (record)/List a `Context`.
- Add `Artifact` to `Execution` as events.
- Add `Execution` and `Artifact` into the `Context`
- Delete `Artifact`, `Execution` and `Context`.
- Create and run a `Vertex AI Pipeline` ML workflow to train and deploy a scikit-learn model.
- Create custom pipeline components that generate artifacts and metadata.
- Compare Vertex AI Pipelines runs.
- Trace the lineage for pipeline-generated artifacts.
- Query your pipeline run metadata.
```
[Get started with Vertex AI Model Evaluation](get_started_with_model_evaluation.ipynb)
- Building KFP lightweight Python function components.
- Assembling and compiling KFP components into a pipeline.
- Executing a KFP pipeline using Vertex AI Pipelines.
- Loading component and pipeline definitions from a source code repository.
- Building sequential, parallel, multiple output components.
- Building control flow into pipelines.
[Get started with Vertex AI custom training pipeline components](community/ml_ops/stage3/get_started_with_custom_training_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Training`.
```
The steps performed include:
- Evaluate an `AutoML` model.
- Train an `AutoML` image classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a BigQuery ML model.
- Train a `BigQuery ML` tabular classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a custom model.
- Do a batch evaluation for a custom evaluation slice.
- Add an evaluation to the `Model Registry` for the `Model` resource.
- Evaluate an `AutoML` model.
- Train an `AutoML` image classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a BigQuery ML model.
- Train a `BigQuery ML` tabular classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a custom model.
- Do a batch evaluation for a custom evaluation slice.
- Add an evaluation to the `Model Registry` for the `Model` resource.
```
- Construct a pipeline for:
- Training a Vertex AI custom trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
- Construct a pipeline for:
- Construct a custom training component.
- Convert custom training component to CustomTrainingJobOp.
- Training a Vertex AI custom trained model using the converted component.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
[Get started with Dataproc Serverless pipeline components](community/ml_ops/stage3/get_started_with_dataproc_serverless_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataproc Serverless` service.
The steps performed include:
- `DataprocPySparkBatchOp` for running PySpark batch workloads.
- `DataprocSparkBatchOp` for running Spark batch workloads.
- `DataprocSparkSqlBatchOp` for running Spark SQL batch workloads.
- `DataprocSparkRBatchOp` for running SparkR batch workloads.
[Get started with Vertex AI Hyperparameter Tuning pipeline components](community/ml_ops/stage3/get_started_with_hpt_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Hyperparameter Tuning`.
The steps performed include:
- Construct a pipeline for:
- Hyperparameter tune/train a custom model.
- Retrieve the tuned hyperparameter values and metrics to optimize.
- If the metrics exceed a specified threshold.
- Get the location of the model artifacts for the best tuned model.
- Upload the model artifacts to a `Vertex AI Model` resource.
- Execute a Vertex AI pipeline.
[Get started with machine management for Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_machine_management.ipynb)
In this tutorial, you convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:
- The training job and artifacts are trackable.
- Set machine resources, such as machine-type, cpu/gpu, memory, disk, etc.
The steps performed in this tutorial include:
- Create a custom component with a self-contained training job.
- Execute pipeline using component-level settings for machine resources
- Convert the self-contained training component into a `Vertex AI CustomJob`.
- Execute pipeline using customjob-level settings for machine resources
[Get started with TFX pipelines](community/ml_ops/stage3/get_started_with_tfx_pipeline.ipynb)
In this tutorial, you learn how to use TensorFlow Extended (TFX) with `Vertex AI Pipelines`.
The steps performed include:
- Create a TFX e2e pipeline.
- Execute the pipeline locally.
- Execute the pipeline on Google Cloud using `Vertex AI Training`
- Execute the pipeline using `Vertex AI Pipelines`.
[Get started with BigQuery ML pipeline components](community/ml_ops/stage3/get_started_with_bqml_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `BigQuery ML`.
The steps performed include:
- Construct a pipeline for:
- Training BigQuery ML model.
- Evaluating the BigQuery ML model.
- Exporting the BigQuery ML model.
- Importing the BigQuery ML model to a Vertex AI model.
- Deploy the Vertex AI model.
- Execute a Vertex AI pipeline.
- Make a prediction with the deployed Vertex AI model.
[Get started with AutoML tabular pipeline workflows](community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb)
In this tutorial, you learn how to use `AutoML Tabular Pipeline Template` for training, exporting and tuning an AutoML tabular model.
The steps performed include:
- Define training specification.
- Dataset specification
- Hyperparameter overide specification
- machine specifications
- Construct tabular workflow pipeline.
- Compile and execute pipeline.
- View evaluation metrics artifact.
- Export AutoML model as an OSS TF model.
- Create `Endpoint` resource.
- Deploy exported OSS TF model.
- Make a prediction.
[Get started with rapid prototyping with AutoML and BigQuery ML](community/ml_ops/stage3/get_started_with_rapid_prototyping_bqml_automl.ipynb)
In this tutorial, you learn how to use `Vertex AI Predictions` for rapid prototyping a model.
The steps performed include:
- Creating a BigQuery and Vertex AI training dataset.
- Training a BigQuery ML and AutoML model.
- Extracting evaluation metrics from the BigQueryML and AutoML models.
- Selecting the best trained model.
- Deploying the best trained model.
- Testing the deployed model infrastructure.
[Get started with AutoML pipeline components](community/ml_ops/stage3/get_started_with_automl_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI AutoML`.
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI AutoML trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI AutoML trained model.
- Execute a Vertex AI pipeline.
[Get started with BigQuery and TFDV pipeline components](community/ml_ops/stage3/get_started_with_bq_tfdv_pipeline_components.ipynb)
In this tutorial, you learn how to use build lightweight Python components for BigQuery and TensorFlow Data Validation.
The steps performed include:
- Build and execute a pipeline component for creating a Vertex AI Tabular Dataset from a BigQuery table.
- Build and execute a pipeline component for generating TFDV statistics and schema from a Vertex AI Tabular Dataset.
- Execute a Vertex AI pipeline.
### E2E Stage Example
Stage 4: Evaluation
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 4 : formalization: get started with Vertex AI ML Metadata\n",
"# E2E ML on GCP: MLOps stage 4 : formalization: get started with Vertex ML Metadata\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -62,7 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 4 : formalization: get started with Vertex AI ML Metadata."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 4 : formalization: get started with Vertex ML Metadata."
]
},
{
@@ -73,11 +73,11 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `Vertex AI ML Metadata`.\n",
"In this tutorial, you learn how to use `Vertex ML Metadata`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `Vertex AI ML Metadata`\n",
"- `Vertex ML Metadata`\n",
"- `Vertex AI Pipelines`\n",
"\n",
"The steps performed include:\n",
@@ -657,7 +657,7 @@
"source": [
"## Introduction to Vertex AI Metadata\n",
"\n",
"The `Vertex AI ML Metadata` service provides you with the ability to record, and subsequently search and analyze, the artifacts and corresponding metadata produced by your ML workflows. For example, during experimentation one might desire to record the location of the model artifacts, as artifacts, and the training hyperparameters and evaluation metrics as the corresponding metadata.\n",
"The `Vertex ML Metadata` service provides you with the ability to record, and subsequently search and analyze, the artifacts and corresponding metadata produced by your ML workflows. For example, during experimentation one might desire to record the location of the model artifacts, as artifacts, and the training hyperparameters and evaluation metrics as the corresponding metadata.\n",
"\n",
"The service supports recording ML metadata both manually and automatically, with the later occurring when you use Vertex AI Pipelines.\n",
"\n",
@@ -675,9 +675,9 @@
"\n",
"### ML artifact lineage\n",
"\n",
"Vertex AI ML Metadata provides the ability to understand changes in the performance of your machine ML system, and analyze the metadata produced by your ML workflow and the lineage of its artifacts. An artifact's lineage includes all the factors that contributed to its creation, as well as artifacts and metadata that descend from this artifact.\n",
"Vertex ML Metadata provides the ability to understand changes in the performance of your machine ML system, and analyze the metadata produced by your ML workflow and the lineage of its artifacts. An artifact's lineage includes all the factors that contributed to its creation, as well as artifacts and metadata that descend from this artifact.\n",
"\n",
"Learn more about [Introduction to Vertex AI ML Metadata ](https://cloud.google.com/vertex-ai/docs/ml-metadata/introduction)"
"Learn more about [Introduction to Vertex ML Metadata ](https://cloud.google.com/vertex-ai/docs/ml-metadata/introduction)"
]
},
{
+40 -32
View File
@@ -25,10 +25,12 @@ The fifth stage in MLOps is deployment to production of the blessed model, which
### Get Started
[Get started with Vertex AI Endpoints](get_started_with_vertex_endpoints.ipynb)
[Get started with Vertex AI Endpoints](community/ml_ops/stage5/get_started_with_vertex_endpoints.ipynb)
In this tutorial, you learn how to use `Vertex AI Endpoint` resources.
```
The steps performed include:
- Creating an `Endpoint` resource.
- List all `Endpoint` resources.
- List `Endpoint` resources by query filter.
@@ -43,39 +45,13 @@ The steps performed include:
- Delete an `Endpoint` resource.
- In pipeline: Create an `Endpoint` resource and deploy an existing `Model` resource to the `Endpoint` resource.
- In pipeline: Deploy an existing `Model` resource to an existing `Endpoint` resource.
```
[Get started with configuring autoscaling for Vertex AI Endpoint deployment](get_started_with_autoscaling.ipynb)
[Get started with Vertex AI Endpoint and shared VM](community/ml_ops/stage5/get_started_with_vertex_endpoint_and_shared_vm.ipynb)
In this tutorial, you learn how to use deployment resource pools for deploying models. A deployment resouce pool provides one with the ability to co-host more than one model on the same (shared) VM.
```
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Upload the pretrained model as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy `Model` resource for no-scaling (single node).
- Deploy `Model` resource for manual scaling.
- Deploy `Model` resource for auto-scaling.
- Fine-tune scaling thresholds for CPU utilization.
- Fine-tune scaling thresholds for GPU utilization.
- Deploy mix of CPU and GPU model instances with auto-scaling to an `Endpoint` resource.
```
[Get started with Vertex AI Private Endpoints](get_started_with_vertex_private_endpoints.ipynb)
```
The steps performed include:
- Creating a `Private Endpoint` resource.
- Configure a VPC peering connection.
- Configuring the serving binary of a `Model` resource for deployment to a `Private Endpoint` resource.
- Deploying a `Model` resource to a `Private Endpoint` resource.
- Send a prediction request to a `Private Endpoint`
```
[Get started with Vertex AI Endpoint and shared VM](get_started_with_vertex_endpoint_and_shared_vm.ipynb)
```
The steps performed include:
- Upload a pre-trained image classification model as a `Model` resource (model A).
- Upload a pre-trained text sentence encoder model as a `Model` resource (model B).
- Create a shared VM deployment resource pool.
@@ -85,4 +61,36 @@ The steps performed include:
- Deploy second model (model B) to second `Endpoint` resource using deployment resource pool.
- Make a prediction request with first deployed model (model A).
- Make a prediction request with second deployed model (model B).
```
[Get started with configuring autoscaling for Vertex AI Endpoint deployment](community/ml_ops/stage5/get_started_with_autoscaling.ipynb)
In this tutorial, you learn how to use fine-tune control auto-scaling configuration when deploying a `Model` resource to an `Endpoint` resource.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Upload the pretrained model as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy `Model` resource for no-scaling (single node).
- Deploy `Model` resource for manual scaling.
- Deploy `Model` resource for auto-scaling.
- Fine-tune scaling thresholds for CPU utilization.
- Fine-tune scaling thresholds for GPU utilization.
- Deploy mix of CPU and GPU model instances with auto-scaling to an `Endpoint` resource.
[Get started with Vertex AI Private Endpoints](community/ml_ops/stage5/get_started_with_vertex_private_endpoints.ipynb)
In this tutorial, you learn how to use `Vertex AI Private Endpoint` resources.
The steps performed include:
- Creating a `Private Endpoint` resource.
- Configure a VPC peering connection.
- Configuring the serving binary of a `Model` resource for deployment to a `Private Endpoint` resource.
- Deploying a `Model` resource to a `Private Endpoint` resource.
- Send a prediction request to a `Private Endpoint`
- Enable two additional APIs: Service Networking and Cloud DNS.
- Add Compute Admin Network role to your (default) service account.
- Issue two gcloud commands to setup the VPC peering for your service account.
- There is *currently* no SDK support yet, so private endpoint is created with GAPIC client and has an extra argument for the peering network.
- To send a request, you can't use SDK/GAPIC since they do a HTTP internet request. Instead, you use curl to send a peer-to-peer request.
+242 -123
View File
@@ -30,48 +30,232 @@ This stage may be done entirely by MLOps. We recommend:
### Get Started
[Get started with TensorFlow serving functions with Vertex AI Prediction](get_started_with_tf_serving_function.ipynb)
[Get started with Vertex AI Batch Prediction for AutoML image models](community/ml_ops/stage6/get_started_with_automl_image_model_batch.ipynb)
In this tutorial, you create an AutoML image classification model from a Python script, and then do a batch prediction using the Vertex AI SDK.
```
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` image classification model.
- Make a batch prediction with JSONL input.
[Get started with Vertex AI Matching Engine and Swivel builtin algorithm](community/ml_ops/stage6/get_started_with_matching_engine_swivel.ipynb)
In this notebook, you learn how to train custom embeddings using Vertex AI Pipelines and subsequently train and deploy a matching engine index using the embeddings.
The steps performed include:
1. Train the `Swivel` algorithm to generate embeddings (encoder) for the dataset.
2. Make example predictions (embeddings) from then trained encoder.
3. Generate embeddings using the trained `Swivel` builtin algorithm.
4. Store embeddings to format supported by `Matching Engine`.
5. Create a `Matching Engine Index` for the embeddings.
6. Deploy the `Matching Engine Index` to a `Index Endpoint`.
7. Make a matching engine prediction request.
[Get started with Vertex AI Matching Engine](community/ml_ops/stage6/get_started_with_matching_engine.ipynb)
In this notebook, you learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes.
The steps performed include:
- Create ANN Index.
- Create an IndexEndpoint with VPC Network
- Deploy ANN Index
- Perform online query
- Deploy brute force Index.
- Perform calibration between ANN and brute force index.
[Get started with Vertex AI Matching Engine and Two Towers builtin algorithm](community/ml_ops/stage6/get_started_with_matching_engine_twotowers.ipynb)
In this notebook, you learn how to use the `Two-Tower` builtin algorithms for generating embeddings for a dataset, for use with generating an `Matching Engine Index`, with the `Vertex AI Matching Engine` service.
The steps performed include:
1. Train the `Two-Tower` algorithm to generate embeddings (encoder) for the dataset.
2. Hyperparameter tune the trained `Two-Tower` encoder.
3. Make example predictions (embeddings) from then trained encoder.
4. Generate embeddings using the trained `Two-Tower` builtin algorithm.
5. Store embeddings to format supported by `Matching Engine`.
6. Create a `Matching Engine Index` for the embeddings.
7. Deploy the `Matching Engine Index` to a `Index Endpoint`.
8. Make a matching engine prediction request.
[Get started with Vertex AI Batch Prediction for custom tabular models](community/ml_ops/stage6/get_started_with_custom_tabular_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a custom tabular model.
The steps performed include:
- Upload a pretrained tabular model as a `Vertex AI Model` resource.
- Make batch prediction to the `Model` resource, in JSONL format.
- Make batch prediction to the `Model` resource, in CSV format.
- Make batch prediction to the `Model` resource, in BigQuery format.
[Get started with Optimized TensorFlow Enterprise container with Vertex AI Prediction / text models](community/ml_ops/stage6/get_started_with_optimized_tfe_bert.ipynb)
In this tutorial, you learn how to use `TensorFlow Enterprise Optimized` container for TensorFlow models deployed to a `Vertex AI Endpoint` resource.
The steps performed include:
- Download a pretrained BERT model from TensorFlow Hub.
- Fine-tune (transfer learning) the BERT model as a binary classifier.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with standard TensorFlow serving container.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with TensorFlow Enterprise Optimized container
- Create two `Endpoint` resources.
- Deploying both `Model` resources to separate `Endpoint` resources.
- Make the same online prediction requests to both `Model` resource instances deployed to the `Endpoint` resources.
- Compare the prediction accuracy between the two deployed `Model` resources.
- Configuring container settings for fine-tune control of optimizations.
- Create a `Private Endpoint` resource.
- Deploy the `Model` resoure with then `TensorFlow Enterprise Optimized` to the `Private Endpoint` resource.
- Make an online prediction request to the `Private Endpoint` resource.
[Get started with Vertex AI Batch Prediction and Explainable AI for AutoML tabular models](community/ml_ops/stage6/get_started_with_automl_tabular_model_batch.ipynb)
In this tutorial, you create an AutoML tabular binary classification model from a Python script, and then do a batch prediction with Explainable AI using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` tabular model.
- Make a batch prediction with CSV input.
- Make a batch prediction with JSONL objects input.
- Make a batch prediction with JSONL list input.
- Make a batch prediction with BigQuery table input.
- Make a batch prediction with explanations.
[Get started with re-importing AutoML tabular models](community/ml_ops/stage6/get_started_with_automl_tabular_exported_deploy.ipynb)
In this tutorial, you learn how to use `AutoML Tabular` for re-importing exported model artifacts as a `Model` resource. This is useful for example, if one wants to move the exported model across projects.
The steps performed include:
- Importing a pretrained AutoML tabular exported model artifacts, as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Make a prediction.
[Get started with Vertex AI Batch Prediction for AutoML text models](community/ml_ops/stage6/get_started_with_automl_text_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a `AutoML` text model.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` model.
- Make a batch prediction with JSONL input
[Get started with Vertex AI Prediction for AutoML text models](community/ml_ops/stage6/get_started_with_automl_text_model_online.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` with a `AutoML` text model.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` model.
- Deploy the model to an `Endpoint` resource.
- Make an online prediction.
[Get started with TensorFlow serving functions with Vertex AI Raw Prediction](community/ml_ops/stage6/get_started_with_raw_predict.ipynb)
In this tutorial, you learn how to use `Vertex AI Raw Prediction` on a `Vertex AI Endpoint` resource.
The steps performed include:
- Download a pretrained tabular classification model artifacts for a TensorFlow 1.x estimator.
- Upload the TensorFlow estimator model as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource.
- Make an online raw prediction to the `Model` resource instance deployed to the `Endpoint` resource.
[Get started with TensorFlow serving functions with Vertex AI Prediction](community/ml_ops/stage6/get_started_with_tf_serving_function.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` on a `Vertex AI Endpoint` resource with a serving function.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
[Get started with FastAPI with Vertex AI Prediction](get_started_with_fastapi.ipynb)
[Get started with Vertex Explainable AI using custom deployment container](community/ml_ops/stage6/get_started_with_xai_and_custom_server.ipynb)
In this tutorial, you learn to build a custom container to serve a PyTorch model on `Vertex AI Endpoint`.
```
The steps performed include:
- Locally train a Pytorch tabular classifier.
- Locally test the trained model.
- Build a HTTP server using FastAPI.
- Create a custom serving container with the trained model and FastAPI server.
- Locally test the custom serving container.
- Push the custom serving container to the Artifact Registry.
- Upload the custom serving container as a `Model` resource.
- Deploy the `Model` resource to an `Endpoint` resource.
- Make a prediction request to the deployed custom serving container.
- Make an explanation request to the deployed custom serving container.
[Get started with Vertex AI Online Prediction for AutoML image models](community/ml_ops/stage6/get_started_with_automl_image_model_online.ipynb)
In this tutorial, you create an AutoML image classification model from a Python script, and then do an online prediction using the Vertex AI SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` image classification model.
- Make an online prediction.
[Get started with FastAPI with Vertex AI Prediction](community/ml_ops/stage6/get_started_with_fastapi.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` on a `Vertex AI Endpoint` with a custom serving binary using `FastAPI`.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `FastAPI` custom serving binary.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
[Get started with Nvidia Triton server](get_started_with_nvidia_triton_serving.ipynb)
[Get started with Vertex AI Online Prediction for AutoML tabular models](community/ml_ops/stage6/get_started_with_automl_tabular_model_online.ipynb)
```
The steps performed in this tutorial include:
- Download the model artifacts from TensorFlow Hub.
- Create Triton serving configuration file for the model.
- Construct a custom container, with Triton serving image, for model deployment.
- Upload the model as a `Vertex AI Model` resource.
- Deploy the `Vertex AI Model` resource to a `Vertex AI Endpoint` resource.
- Make a prediction request
- Undeploy the `Model` resource and delete the `Endpoint`
In this tutorial, you create an AutoML tabular binary classification model from a Python script, and then do an online prediction using the Vertex AI SDK.
```
[Get started with Custom Prediction Routine (CPR)](get_started_with_cpr.ipynb)
```
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` tabular model.
- Deploy the model to an `Endpoint` resource.
- Make an online prediction.
- Make an online prediction with explanations.
[Get started with TensorFlow Serving with Vertex AI Prediction](community/ml_ops/stage6/get_started_with_tf_serving.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` on a `Vertex AI Endpoint` resource with `TensorFlow Serving` serving binary.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `TensorFlow Serving` serving binary.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
- Make a batch prediction to the `Model` resource instance.
[Get started with Custom Prediction Routine (CPR)](community/ml_ops/stage6/get_started_with_cpr.ipynb)
In this tutorial, you learn how to use Custom Prediction Routine (CPR) for `Vertex AI Predictions`.
The steps performed include:
- Write a custom data preprocessor.
- Train the model.
- Build a custom scikit-learn serving container with custom data preprocessing using the Custom Prediction Routine model server.
@@ -93,115 +277,50 @@ The steps performed include:
- Test the model serving container locally.
- Upload and deploy the model serving container to Vertex AI Endpoint.
- Make a prediction request.
```
[Get started with re-importing AutoML tabular models](get_started_automl_tabular_exported_deploy.ipynb)
[Get started with Vertex AI Batch Prediction for custom text models](community/ml_ops/stage6/get_started_with_custom_text_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a custom text model.
```
The steps performed include:
- Importing a pretrained AutoML tabular exported model artifacts, as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Make a prediction.
```
[Get started with Vertex Explainable AI using custom deployment container](get_started_with_xai_and_custom_server.ipynb)
- Download a pretrained TensorFlow RNN model.
- Upload the pretrained model as a `Vertex AI Model` resource.
- Make batch prediction to the `Model` resource, in JSONL format.
[Get started with NVIDIA Triton server](community/ml_ops/stage6/get_started_with_nvidia_triton_serving.ipynb)
In this tutorial, you deploy a container running Nvidia Triton Server with a `Vertex AI Model` resource to a `Vertex AI Endpoint` for making online predictions.
The steps performed in this tutorial include:
- Download the model artifacts from TensorFlow Hub.
- Create Triton serving configuration file for the model.
- Construct a custom container, with Triton serving image, for model deployment.
- Upload the model as a `Vertex AI Model` resource.
- Deploy the `Vertex AI Model` resource to a `Vertex AI Endpoint` resource.
- Make a prediction request
- Undeploy the `Model` resource and delete the `Endpoint`
[Get started with Vertex AI Batch Prediction for custom image models](community/ml_ops/stage6/get_started_with_custom_image_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a custom image model.
```
The steps performed include:
- Locally train a Pytorch tabular classifier.
- Locally test the trained model.
- Build a HTTP server using FastAPI.
- Create a custom serving container with the trained model and FastAPI server.
- Locally test the custom serving container.
- Push the custom serving container to the Artifact Registry.
- Upload the custom serving container as a `Model` resource.
- Deploy the `Model` resource to an `Endpoint` resource.
- Make a prediction request to the deployed custom serving container.
- Make an explanation request to the deployed custom serving container.
```
[Get started with TensorFlow serving functions with Vertex AI Raw Prediction](get_started_with_raw_predict.ipynb)
```
The steps performed include:
- Download a pretrained tabular classification model artifacts for a TensorFlow 1.x estimator.
- Upload the TensorFlow estimator model as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource.
- Make an online raw prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
[Get started with Vertex AI Matching Engine and Two Towers builtin algorithm](get_started_with_matching_engine_twotowers.ipynb)
```
The steps performed include:
1. Train the `Two-Tower` algorithm to generate embeddings (encoder) for the dataset.
2. Hyperparameter tune the trained `Two-Tower` encoder.
3. Make example predictions (embeddings) from then trained encoder.
4. Generate embeddings using the trained `Two-Tower` builtin algorithm.
5. Store embeddings to format supported by `Matching Engine`.
6. Create a `Matching Engine Index` for the embeddings.
7. Deploy the `Matching Engine Index` to a `Index Endpoint`.
8. Make a matching engine prediction request.
```
[Get started with Optimized TensorFlow Enterprise container with Vertex AI Prediction / text models](get_started_with_optimized_tfe_bert.ipynb)
```
The steps performed include:
- Download a pretrained BERT model from TensorFlow Hub.
- Fine-tune (transfer learning) the BERT model as a binary classifier.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with standard TensorFlow serving container.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with TensorFlow Enterprise Optimized container
- Create two `Endpoint` resources.
- Deploying both `Model` resources to separate `Endpoint` resources.
- Make the same online prediction requests to both `Model` resource instances deployed to the `Endpoint` resources.
- Compare the prediction accuracy between the two deployed `Model` resources.
- Configuring container settings for fine-tune control of optimizations.
- Create a `Private Endpoint` resource.
- Deploy the `Model` resoure with then `TensorFlow Enterprise Optimized` to the `Private Endpoint` resource.
- Make an online prediction request to the `Private Endpoint` resource.
```
[Get started with Vertex AI Matching Engine](get_started_with_matching_engine.ipynb)
```
The steps performed include:
- Create ANN Index.
- Create an IndexEndpoint with VPC Network
- Deploy ANN Index
- Perform online query
- Deploy brute force Index.
- Perform calibration between ANN and brute force index.
```
[Get started with Vertex AI Matching Engine and Swivel builtin algorithm](get_started_with_matching_engine_swivel.ipynb)
```
The steps performed include:
1. Train the `Swivel` algorithm to generate embeddings (encoder) for the dataset.
2. Make example predictions (embeddings) from then trained encoder.
3. Generate embeddings using the trained `Swivel` builtin algorithm.
4. Store embeddings to format supported by `Matching Engine`.
5. Create a `Matching Engine Index` for the embeddings.
6. Deploy the `Matching Engine Index` to a `Index Endpoint`.
7. Make a matching engine prediction request.
```
[Get started with TensorFlow serving with Vertex AI Prediction](get_started_with_tf_serving.ipynb)
```
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource.
- Make batch prediction with raw (uncompressed) image data to the `Model` resource, in JSONL format.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `TensorFlow Serving` serving binary.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
- Make batch prediction with compressed image data to the `Model` resource, in File-List format.
[Get started with Vertex AI Batch Prediction for AutoML video models](community/ml_ops/stage6/get_started_with_automl_video_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a `AutoML` video model.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` model.
- Make a batch prediction with JSONL input.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -29,7 +29,7 @@
"id": "title"
},
"source": [
"## E2E ML on GCP: MLOps stage 6 : Get started with Vertex AI Batch Prediction for AutoML video models\n",
"# E2E ML on GCP: MLOps stage 6 : Get started with Vertex AI Batch Prediction for AutoML video models\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -103,7 +103,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Human Motion dataset](https://TODO) from [MIT](http://cbcl.mit.edu/publications/ps/Kuehne_etal_iccv11.pdf). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket."
"The dataset used for this tutorial is the [Human Motion dataset](https://TODO) from [MIT](http://cbcl.mit.edu/publications/ps/Kuehne_etal_iccv11.pdf). The version of the dataset you use in this tutorial is stored in a public Cloud Storage bucket."
]
},
{
@@ -244,7 +244,7 @@
"\n",
"3. [Enable the following APIs: Vertex AI APIs, Compute Engine APIs, and Cloud Storage.](https://console.cloud.google.com/flows/enableapi?apiid=ml.googleapis.com,compute_component,storage-component.googleapis.com)\n",
"\n",
"4. If you are running this notebook locally, you will need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"4. If you are running this notebook locally, you need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"\n",
"5. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
@@ -252,6 +252,17 @@
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$`."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "project_id"
},
"source": [
"#### Set your project ID\n",
"\n",
"**If you don't know your project ID**, you may be able to get your project ID using `gcloud`."
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -580,7 +591,7 @@
"source": [
"#### Quick peek at your data\n",
"\n",
"You will use a version of the MIT Human Motion dataset that is stored in a public Cloud Storage bucket, using a CSV index file.\n",
"You use a version of the MIT Human Motion dataset that is stored in a public Cloud Storage bucket, using a CSV index file.\n",
"\n",
"Start by doing a quick peek at the data. You count the number of examples by counting the number of rows in the CSV index file (`wc -l`) and then peek at the first few rows."
]
@@ -828,7 +839,7 @@
"source": [
"### Get test item(s)\n",
"\n",
"Now do a batch prediction to your Vertex AI model. You will use arbitrary examples out of the dataset as a test items."
"Now do a batch prediction to your Vertex AI model. You use arbitrary examples out of the dataset as a test items."
]
},
{
@@ -861,7 +872,7 @@
"source": [
"### Make a batch input file\n",
"\n",
"Now make a batch input file, which you will store in your local Cloud Storage bucket. The batch input file can only be in JSONL format. For JSONL file, you make one dictionary entry per line for each data item (instance). The dictionary contains the key/value pairs:\n",
"Now make a batch input file, which you store in your local Cloud Storage bucket. The batch input file can only be in JSONL format. For JSONL file, you make one dictionary entry per line for each data item (instance). The dictionary contains the key/value pairs:\n",
"\n",
"- `content`: The Cloud Storage path to the video.\n",
"- `mimeType`: The content type. In our example, it is an `avi` file.\n",
@@ -1051,7 +1062,7 @@
],
"metadata": {
"colab": {
"name": "get_started_with_automl_video_model.ipynb",
"name": "get_started_with_automl_video_model_batch.ipynb",
"toc_visible": true
},
"kernelspec": {
@@ -81,7 +81,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you deploy a container running Nvidia Triton Server with a `Vertex AI Model` resource to a `Vertex AI Endpoint` for making online predictions.\n",
"In this tutorial, you learn how to deploy a container running Nvidia Triton Server with a `Vertex AI Model` resource to a `Vertex AI Endpoint` for making online predictions.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -1054,36 +1054,17 @@
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "get_started_with_tf_serving_function.ipynb",
"toc_visible": true
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "get_started_with_tf_serving_function.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"environment": {
"kernel": "python3",
"name": "tf2-gpu.2-6.m91",
"type": "gcloud",
"uri": "gcr.io/deeplearning-platform-release/tf2-gpu.2-6:m91"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
"nbformat": 4,
"nbformat_minor": 0
}
@@ -85,7 +85,7 @@
"\n",
"The steps performed include:\n",
"\n",
"- Locally train a Pytorch tabular classifier.\n",
"- Locally train a PyTorch tabular classifier.\n",
"- Locally test the trained model.\n",
"- Build a HTTP server using FastAPI.\n",
"- Create a custom serving container with the trained model and FastAPI server.\n",
File diff suppressed because it is too large Load Diff
@@ -34,3 +34,69 @@ This stage may be done entirely by MLOps. We recommend:
## Notebooks
### Get Started
[Vertex AI Model Monitoring for custom tabular models with TensorFlow Serving container](community/ml_ops/stage7/get_started_with_model_monitoring_custom_tf_serving.ipynb)
In this notebook, you learn to use the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests, for custom tabular models, using a custom deployment container.
The steps performed include:
- Download a pre-trained custom tabular model.
- Upload the pre-trained model as a `Model` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `TensorFlow Serving` serving binary.
- Configure the `Endpoint` resource for model monitoring.
- Generate synthetic prediction requests for skew.
- Wait for email alert notification.
- Generate synthetic prediction requests for drift.
- Wait for email alert notification.
[Vertex AI Model Monitoring for AutoML tabular models](community/ml_ops/stage7/get_started_with_model_monitoring_automl.ipynb)
In this notebook, you learn to use the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests, for AutoML tabular models.
The steps performed include:
- Train an `AutoML` model.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Generate synthetic prediction requests for skew.
- Wait for email alert notification.
- Generate synthetic prediction requests for drift.
- Wait for email alert notification.
[Vertex AI Model Monitoring for custom tabular models](community/ml_ops/stage7/get_started_with_model_monitoring_custom.ipynb)
In this notebook, you learn to use the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests, for custom tabular models.
The steps performed include:
- Download a pre-trained custom tabular model.
- Upload the pre-trained model as a `Model` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Generate synthetic prediction requests for skew.
- Wait for email alert notification.
- Generate synthetic prediction requests for drift.
- Wait for email alert notification.
[Vertex AI Model Monitoring for setup for tabular models](community/ml_ops/stage7/get_started_with_model_monitoring_setup.ipynb)
In this notebook, you learn to setup the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests.
The steps performed include:
- Download a pre-trained custom tabular model.
- Upload the pre-trained model as a `Model` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Skew and drift detection for feature inputs.
- Skew and drift detection for feature attributions.
- Automatic generation of the `input schema` by sending 1000 prediction request.
- List, pause, resume and delete monitoring jobs.
- Restart monitoring job with predefined `input schema`.
- View logged monitored data.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a PyTorch model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a PyTorch model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to locally test [NVIDIA Triton inference server](https://developer.nvidia.com/nvidia-triton-inference-server) to serve a PyTorch model and deploy it to Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to locally test [NVIDIA Triton inference server](https://developer.nvidia.com/nvidia-triton-inference-server) to serve a PyTorch model and deploy it to Vertex AI Predictions.\n",
"\n",
"\n",
"### Dataset\n",
@@ -0,0 +1,619 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "7fPc-KWUi2Xd"
},
"outputs": [],
"source": [
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eoXf8TfQoVth"
},
"source": [
"# Convert between Vertex AI Vizier and Open Source Vizier\n",
"\n",
"<table align=\"left\">\n",
"\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/vizier/conversions_vertex_vizier_and_open_source_vizier.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/vizier/conversions_vertex_vizier_and_open_source_vizier.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/vizier/conversions_vertex_vizier_and_open_source_vizier.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "b397c59391b1"
},
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to migrate code between [Vertex AI Vizier](https://cloud.google.com/vertex-ai/docs/vizier/overview) and [Open Source(OSS) Vizier](https://oss-vizier.readthedocs.io/). OSS Vizier is a Python-based service for blackbox optimization and research. It allows you to setup an OSS Vizier Server that can host blackbox optimization algorithms for tuning objective functions and defining abstractions and utilities for implementing new optimization algorithms.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "AksIKBzZ-nre"
},
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `Vertex AI Vizier` to optimize a multi-objective study and convert the code to OSS Vizier.\n",
"\n",
"The goal is to __`minimize`__ the objective metric:\n",
" ```\n",
" y1 = r*sin(theta)\n",
" ```\n",
"\n",
"and simultaneously __`maximize`__ the objective metric:\n",
" ```\n",
" y2 = r*cos(theta)\n",
" ```\n",
"\n",
"so that you will evaluate over the parameter space:\n",
"\n",
" - __`r`__ in [0,1],\n",
"\n",
" - __`theta`__ in [0, pi/2]\n",
"\n",
"### Costs\n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "iMHz63rPbq6P"
},
"source": [
"## Installation\n",
"\n",
"Install the packages required for executing this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "b6f3dc43494b"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"# Configure the environment for the Vertex AI Workbench notebook.\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install google-vizier==0.0.4\n",
"! pip3 install --upgrade google-cloud-aiplatform {USER_FLAG} -q"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "64d24b4fab2c"
},
"source": [
"### Restart the kernel\n",
"\n",
"Once you've installed the additional packages, you need to restart the notebook kernel so it can find the packages."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "O8AIwN0abq6U"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
" # Restart the kernel after pip installs\n",
" import IPython\n",
"\n",
" app = IPython.Application.instance()\n",
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "before_you_begin:nogpu"
},
"source": [
"## Before you begin\n",
"\n",
"### GPU runtime\n",
"\n",
"This tutorial does not require a GPU runtime.\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"2. [Make sure that billing is enabled for your project.](https://cloud.google.com/billing/docs/how-to/modify-project)\n",
"\n",
"3. [Enable the Vertex AI APIs, Compute Engine APIs, and Cloud Storage.](https://console.cloud.google.com/flows/enableapi?apiid=ml.googleapis.com,compute_component,storage-component.googleapis.com)\n",
"\n",
"4. [The Google Cloud SDK](https://cloud.google.com/sdk) is already installed in Google Cloud Notebook.\n",
"\n",
"5. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_project_id"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_project_id"
},
"outputs": [],
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n",
" # Get your Google Cloud project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_gcloud_project_id"
},
"outputs": [],
"source": [
"! gcloud config set project $PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "region"
},
"source": [
"#### Region\n",
"\n",
"You can also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
"\n",
"- Americas: `us-central1`\n",
"- Europe: `europe-west4`\n",
"- Asia Pacific: `asia-east1`\n",
"\n",
"You may not use a multi-regional bucket for training with Vertex AI. Not all regions provide support for all Vertex AI services.\n",
"\n",
"Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "04933ed28eef"
},
"outputs": [],
"source": [
"REGION = \"[your-region]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "jvNx3KyF2Ou0"
},
"outputs": [],
"source": [
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "h0SMyUsC-mzi"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebook**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions\n",
"when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"1. In the Cloud Console, go to the [**Create service account key**\n",
" page](https://console.cloud.google.com/apis/credentials/serviceaccountkey).\n",
"\n",
"2. Click **Create service account**.\n",
"\n",
"3. In the **Service account name** field, enter a name, and\n",
" click **Create**.\n",
"\n",
"4. In the **Grant this service account access to project** section, click the **Role** drop-down list. Type \"Vertex AI\"\n",
"into the filter box, and select\n",
" **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"5. Click *Create*. A JSON file that contains your key downloads to your\n",
"local environment.\n",
"\n",
"6. Enter the path to your service account key as the\n",
"`GOOGLE_APPLICATION_CREDENTIALS` variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "iTQY9g4mRo6r"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your Google Cloud account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your Google Cloud\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Dax2zrpTi2Xy"
},
"source": [
"### Import libraries and define constants"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "xD60d6Q0i2X0"
},
"outputs": [],
"source": [
"import datetime\n",
"import math"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "CWuu4wmki2X3"
},
"source": [
"## Tutorial\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "KyEjqIdnad0w"
},
"source": [
"This section defines some parameters to create the study and optimize the objective function.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8HCgeF8had77"
},
"outputs": [],
"source": [
"# These will be automatically filled in.\n",
"STUDY_DISPLAY_NAME = \"{}_study_{}\".format(\n",
" PROJECT_ID.replace(\"-\", \"\"), datetime.datetime.now().strftime(\"%Y%m%d_%H%M%S\")\n",
")\n",
"\n",
"print(\"REGION: {}\".format(REGION))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8NBduXsEaRKr"
},
"source": [
"### Define the parameters\n",
"\n",
"The following is a sample study configuration, built as a hierarchical python dictionary. It is already filled out. Run the cell to configure the study.\n",
"\n",
"__`USE_VERTEX_VIZIER`__: Uses Vertex Vizier SDK to do the optimization if True. Use OSS Vizier otherwise.\n",
"\n",
"__`SUGGESTION_COUNT`__: The number of suggestions (trials) requested in a single request.\n",
"\n",
"__`MAX_NUM_ITERATIONS`__: The number of iterations to explore before stopping. It is set to 4 to shorten the time to run the code, so don't expect convergence. For convergence, it would likely need to be about 20.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "E1VNJ4YBznhR"
},
"outputs": [],
"source": [
"USE_VERTEX_VIZIER = True # @param {type:\"boolean\"}\n",
"\n",
"MAX_NUM_ITERATIONS = 4 # @param {type:\"integer\"}\n",
"\n",
"SUGGESTION_COUNT = 2 # @param {type:\"integer\"}\n",
"\n",
"OWNER = \"owner\" # @param {type:\"string\"}\n",
"\n",
"SERVICE_ENDPOINT = \"127.0.0.1:8888\" # @param {type:\"string\"}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4_Yvt-7Z8_re"
},
"source": [
"### Import the package and define `create_study` for different sources\n",
"\n",
"In Vertex Vizier, `project` and `location` are already specified and `Study.create_or_load` is called to create a study. You need to input the owner of your study and the server address in the format [ip:port]. To bring up the OSS Vizier server, please follow the [instructions](https://oss-vizier.readthedocs.io/) on the OSS Vizier website."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0sAHZn1406VR"
},
"outputs": [],
"source": [
"if USE_VERTEX_VIZIER:\n",
" from google.cloud import aiplatform\n",
" from google.cloud.aiplatform.vizier import Study, pyvizier\n",
"\n",
" def create_study(project, location, display_name, problem):\n",
" aiplatform.init(project=project, location=location)\n",
" study = Study.create_or_load(display_name=display_name, problem=problem)\n",
" return study\n",
"\n",
"else:\n",
" from vizier.service import clients, pyvizier\n",
"\n",
" def create_study(project, location, display_name, problem):\n",
" clients.environment_variables.service_endpoint = SERVICE_ENDPOINT\n",
" study = clients.Study.from_study_config(\n",
" problem, owner=OWNER, study_id=STUDY_DISPLAY_NAME\n",
" )\n",
" return study"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "guvkcQe_-zQf"
},
"source": [
"### Metric evaluation functions\n",
"\n",
"Next, define some functions to evaluate the two objective metrics.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Fjfk5_c900Oz"
},
"outputs": [],
"source": [
"# r * sin(theta)\n",
"def Metric1Evaluation(r, theta):\n",
" \"\"\"Evaluate the first metric on the trial.\"\"\"\n",
" return r * math.sin(theta)\n",
"\n",
"\n",
"# r * cos(theta)\n",
"def Metric2Evaluation(r, theta):\n",
" \"\"\"Evaluate the second metric on the trial.\"\"\"\n",
" return r * math.cos(theta)\n",
"\n",
"\n",
"def CreateMetrics(r, theta):\n",
" # Evaluate both objective metrics for this trial\n",
" y1 = Metric1Evaluation(r, theta)\n",
" y2 = Metric2Evaluation(r, theta)\n",
" print(\n",
" \"[r = {}, theta = {}] => y1 = r*sin(theta) = {}, y2 = r*cos(theta) = {}\".format(\n",
" r, theta, y1, y2\n",
" )\n",
" )\n",
" measurement = pyvizier.Measurement()\n",
" measurement.metrics[\"y1\"] = y1\n",
" measurement.metrics[\"y2\"] = y2\n",
"\n",
" # Return the results for this trial\n",
" return measurement"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2DgUIEpZ-_fJ"
},
"source": [
"### Optimization\n",
"\n",
"The following code defines a study with parameters and metrics, evaluates the metric information based on the suggestions from Vizier, and reports the metrics value back. After a few rounds of iteration, you can get optimal trials by calling `optimal_trials()`. The code is adapt to both Vertex Vizier and OSS Vizier."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "s-AHfPOASXXW"
},
"outputs": [],
"source": [
"problem = pyvizier.StudyConfig()\n",
"problem.algorithm = pyvizier.Algorithm.RANDOM_SEARCH\n",
"\n",
"# Objective Metrics\n",
"problem.metric_information.append(\n",
" pyvizier.MetricInformation(name=\"y1\", goal=pyvizier.ObjectiveMetricGoal.MINIMIZE)\n",
")\n",
"problem.metric_information.append(\n",
" pyvizier.MetricInformation(name=\"y2\", goal=pyvizier.ObjectiveMetricGoal.MAXIMIZE)\n",
")\n",
"\n",
"# Defines the parameters configuration.\n",
"root = problem.search_space.select_root()\n",
"root.add_float_param(\"r\", 0, 1.0, scale_type=pyvizier.ScaleType.LINEAR)\n",
"root.add_float_param(\"theta\", 0, 1.57, scale_type=pyvizier.ScaleType.LINEAR)\n",
"\n",
"study = create_study(\n",
" project=PROJECT_ID,\n",
" location=REGION,\n",
" display_name=STUDY_DISPLAY_NAME,\n",
" problem=problem,\n",
")\n",
"\n",
"for _ in range(MAX_NUM_ITERATIONS):\n",
" trials = study.suggest(count=SUGGESTION_COUNT)\n",
" for trial in trials:\n",
" materialize_trial = trial.materialize()\n",
" measurement = CreateMetrics(\n",
" materialize_trial.parameters.get_value(\"r\"),\n",
" materialize_trial.parameters.get_value(\"theta\"),\n",
" )\n",
" trial.add_measurement(measurement=measurement)\n",
" trial.complete(measurement=measurement)\n",
"\n",
"optimal_trials = study.optimal_trials()\n",
"print(\"optimal_trials: {}\".format(optimal_trials))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "KAxfq9Fri2YV"
},
"source": [
"## Cleaning up\n",
"\n",
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial. You can also manually delete resources that you created by running the following code."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "zQlLDfvlzYde"
},
"outputs": [],
"source": [
"study.delete()"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "conversions_vertex_vizier_and_open_source_vizier.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
+34 -32
View File
@@ -1,32 +1,34 @@
tag,notebook
AutoML,official/automl/automl-text-classification.ipynb
AutoML,official/automl/sdk_automl_tabular_forecasting_batch.ipynb
Tabular Data,official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb
Tabular Data,official/automl/automl_tabular_on_vertex_pipelines.ipynb
Custom Training,official/custom/sdk-custom-image-classification-batch.ipynb
Custom Training,official/custom/sdk-custom-image-classification-online.ipynb
Vertex Explainable AI,official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb
Vertex Explainable AI,official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb
Vertex Explainable AI,official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb
Vertex Explainable AI,official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb
Vertex Explainable AI,official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb
Vertex Explainable AI,official/explainable_ai/sdk_custom_tabular_regression_online_explain.ipynb
Vertex AI Experiments,official/experiments/comparing_pipeline_runs.ipynb
Vertex AI Experiments,official/experiments/build_model_experimentation_lineage_with_prebuild_code.ipynb
Vertex AI Experiments,official/experiments/comparing_local_trained_models.ipynb
Vertex AI Feature Store,official/feature_store/sdk-feature-store.ipynb
Matching Engine,official/matching_engine/sdk_matching_engine_for_indexing.ipynb
BigQuery ML and Vertex AI Model Registry,official/model-registry/bqml-vertexai-model-registry.ipynb
Vertex ML Metadata,official/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb
Model Monitoring,official/model_monitoring/model_monitoring.ipynb
Vertex AI Pipelines,official/pipelines/lightweight_functions_component_io_kfp.ipynb
Vertex AI Pipelines,official/pipelines/google_cloud_pipeline_components_automl_images.ipynb
Vertex AI Pipelines,official/pipelines/automl_tabular_classification_beans.ipynb
Vertex AI Pipelines,official/pipelines/google_cloud_pipeline_components_automl_tabular.ipynb
Vertex AI Pipelines,official/pipelines/google_cloud_pipeline_components_automl_text.ipynb
Vertex AI Pipelines,official/pipelines/custom_model_training_and_batch_prediction.ipynb
Vertex AI Pipelines,official/pipelines/google_cloud_pipeline_components_model_train_upload_deploy.ipynb
Vertex AI Pipelines,official/pipelines/control_flow_kfp.ipynb
Vertex AI Pipelines,official/pipelines/metrics_viz_run_compare_kfp.ipynb
Vertex AI Pipelines,official/pipelines/pipelines_intro_kfp.ipynb
Vertex AI Vizier,official/vizier/gapic-vizier-multi-objective-optimization.ipynb
tag,notebook,doc
"AutoML, Text data",official/automl/automl-text-classification.ipynb,vertex-ai/docs/text-data/classification/train-model
"AutoML, Tabular data",official/automl/sdk_automl_tabular_forecasting_batch.ipynb,vertex-ai/docs/tabular-data/forecasting/tutorials-samples
"BigQuery, Vertex AI Workbench",official/workbench/exploratory_data_analysis/explore_data_in_bigquery_with_workbench.ipynb,
"BigQuery ML, Vertex AI Model Registry, Batch prediction",official/model-registry/bqml-vertexai-model-registry.ipynb,
"BigQuery ML, Vertex AI Model Registry, Online prediction",official/bigquery_ml/bqml-online-prediction.ipynb,
Custom Training,official/custom/sdk-custom-image-classification-batch.ipynb,
Custom Training,official/custom/sdk-custom-image-classification-online.ipynb,
Tabular Data,official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb,vertex-ai/docs/tabular-data/forecasting-arima/overview
"AutoML, Tabular Data",official/automl/automl_tabular_on_vertex_pipelines.ipynb,vertex-ai/docs/tabular-data/tabular-workflows/e2e-automl
Vertex AI Experiments,official/experiments/comparing_pipeline_runs.ipynb,
Vertex AI Experiments,official/experiments/build_model_experimentation_lineage_with_prebuild_code.ipynb,
Vertex AI Experiments,official/experiments/comparing_local_trained_models.ipynb,
Vertex AI Feature Store,official/feature_store/sdk-feature-store.ipynb,
Matching Engine,official/matching_engine/sdk_matching_engine_for_indexing.ipynb,
Model Monitoring,official/model_monitoring/model_monitoring.ipynb,
Vertex AI Pipelines,official/pipelines/lightweight_functions_component_io_kfp.ipynb,
"Vertex AI Pipelines Image data",official/pipelines/google_cloud_pipeline_components_automl_images.ipynb,
"Vertex AI Pipelines, Tabular data",official/pipelines/automl_tabular_classification_beans.ipynb,
"Vertex AI Pipelines, Tabular data",official/pipelines/google_cloud_pipeline_components_automl_tabular.ipynb,
"Vertex AI Pipelines, Text data",official/pipelines/google_cloud_pipeline_components_automl_text.ipynb,
Vertex AI Pipelines,official/pipelines/custom_model_training_and_batch_prediction.ipynb,
Vertex AI Pipelines,official/pipelines/google_cloud_pipeline_components_model_train_upload_deploy.ipynb,
Vertex AI Pipelines,official/pipelines/control_flow_kfp.ipynb,
Vertex AI Pipelines,official/pipelines/metrics_viz_run_compare_kfp.ipynb,
Vertex AI Pipelines,official/pipelines/pipelines_intro_kfp.ipynb,
Vertex AI Vizier,official/vizier/gapic-vizier-multi-objective-optimization.ipynb,vertex-ai/docs/vizier/using-vizier
"Vertex Explainable AI, Tabular data",official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb,vertex-ai/docs/explainable-ai/overview
"Vertex Explainable AI, Tabular data",official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb,vertex-ai/docs/explainable-ai/overview
"Vertex Explainable AI, Image data",official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb,vertex-ai/docs/explainable-ai/overview
"Vertex Explainable AI, Image data",official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb,vertex-ai/docs/explainable-ai/overview
"Vertex Explainable AI, Tabular data",official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb,vertex-ai/docs/explainable-ai/overview
"Vertex Explainable AI, Tabular data",official/explainable_ai/sdk_custom_tabular_regression_online_explain.ipynb,vertex-ai/docs/explainable-ai/overview
Vertex ML Metadata,official/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb,
1 tag notebook doc
2 AutoML AutoML, Text data official/automl/automl-text-classification.ipynb vertex-ai/docs/text-data/classification/train-model
3 AutoML AutoML, Tabular data official/automl/sdk_automl_tabular_forecasting_batch.ipynb vertex-ai/docs/tabular-data/forecasting/tutorials-samples
4 Tabular Data BigQuery, Vertex AI Workbench official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb official/workbench/exploratory_data_analysis/explore_data_in_bigquery_with_workbench.ipynb
5 Tabular Data BigQuery ML, Vertex AI Model Registry, Batch prediction official/automl/automl_tabular_on_vertex_pipelines.ipynb official/model-registry/bqml-vertexai-model-registry.ipynb
6 Custom Training BigQuery ML, Vertex AI Model Registry, Online prediction official/custom/sdk-custom-image-classification-batch.ipynb official/bigquery_ml/bqml-online-prediction.ipynb
7 Custom Training official/custom/sdk-custom-image-classification-online.ipynb official/custom/sdk-custom-image-classification-batch.ipynb
8 Vertex Explainable AI Custom Training official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb official/custom/sdk-custom-image-classification-online.ipynb
9 Vertex Explainable AI Tabular Data official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb vertex-ai/docs/tabular-data/forecasting-arima/overview
10 Vertex Explainable AI AutoML, Tabular Data official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb official/automl/automl_tabular_on_vertex_pipelines.ipynb vertex-ai/docs/tabular-data/tabular-workflows/e2e-automl
11 Vertex Explainable AI Vertex AI Experiments official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb official/experiments/comparing_pipeline_runs.ipynb
12 Vertex Explainable AI Vertex AI Experiments official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb official/experiments/build_model_experimentation_lineage_with_prebuild_code.ipynb
13 Vertex Explainable AI Vertex AI Experiments official/explainable_ai/sdk_custom_tabular_regression_online_explain.ipynb official/experiments/comparing_local_trained_models.ipynb
14 Vertex AI Experiments Vertex AI Feature Store official/experiments/comparing_pipeline_runs.ipynb official/feature_store/sdk-feature-store.ipynb
15 Vertex AI Experiments Matching Engine official/experiments/build_model_experimentation_lineage_with_prebuild_code.ipynb official/matching_engine/sdk_matching_engine_for_indexing.ipynb
16 Vertex AI Experiments Model Monitoring official/experiments/comparing_local_trained_models.ipynb official/model_monitoring/model_monitoring.ipynb
17 Vertex AI Feature Store Vertex AI Pipelines official/feature_store/sdk-feature-store.ipynb official/pipelines/lightweight_functions_component_io_kfp.ipynb
18 Matching Engine Vertex AI Pipelines Image data official/matching_engine/sdk_matching_engine_for_indexing.ipynb official/pipelines/google_cloud_pipeline_components_automl_images.ipynb
19 BigQuery ML and Vertex AI Model Registry Vertex AI Pipelines, Tabular data official/model-registry/bqml-vertexai-model-registry.ipynb official/pipelines/automl_tabular_classification_beans.ipynb
20 Vertex ML Metadata Vertex AI Pipelines, Tabular data official/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb official/pipelines/google_cloud_pipeline_components_automl_tabular.ipynb
21 Model Monitoring Vertex AI Pipelines, Text data official/model_monitoring/model_monitoring.ipynb official/pipelines/google_cloud_pipeline_components_automl_text.ipynb
22 Vertex AI Pipelines official/pipelines/lightweight_functions_component_io_kfp.ipynb official/pipelines/custom_model_training_and_batch_prediction.ipynb
23 Vertex AI Pipelines official/pipelines/google_cloud_pipeline_components_automl_images.ipynb official/pipelines/google_cloud_pipeline_components_model_train_upload_deploy.ipynb
24 Vertex AI Pipelines official/pipelines/automl_tabular_classification_beans.ipynb official/pipelines/control_flow_kfp.ipynb
25 Vertex AI Pipelines official/pipelines/google_cloud_pipeline_components_automl_tabular.ipynb official/pipelines/metrics_viz_run_compare_kfp.ipynb
26 Vertex AI Pipelines official/pipelines/google_cloud_pipeline_components_automl_text.ipynb official/pipelines/pipelines_intro_kfp.ipynb
27 Vertex AI Pipelines Vertex AI Vizier official/pipelines/custom_model_training_and_batch_prediction.ipynb official/vizier/gapic-vizier-multi-objective-optimization.ipynb vertex-ai/docs/vizier/using-vizier
28 Vertex AI Pipelines Vertex Explainable AI, Tabular data official/pipelines/google_cloud_pipeline_components_model_train_upload_deploy.ipynb official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb vertex-ai/docs/explainable-ai/overview
29 Vertex AI Pipelines Vertex Explainable AI, Tabular data official/pipelines/control_flow_kfp.ipynb official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb vertex-ai/docs/explainable-ai/overview
30 Vertex AI Pipelines Vertex Explainable AI, Image data official/pipelines/metrics_viz_run_compare_kfp.ipynb official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb vertex-ai/docs/explainable-ai/overview
31 Vertex AI Pipelines Vertex Explainable AI, Image data official/pipelines/pipelines_intro_kfp.ipynb official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb vertex-ai/docs/explainable-ai/overview
32 Vertex AI Vizier Vertex Explainable AI, Tabular data official/vizier/gapic-vizier-multi-objective-optimization.ipynb official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb vertex-ai/docs/explainable-ai/overview
33 Vertex Explainable AI, Tabular data official/explainable_ai/sdk_custom_tabular_regression_online_explain.ipynb vertex-ai/docs/explainable-ai/overview
34 Vertex ML Metadata official/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -17,11 +17,12 @@
/tensorboard @zbl94
/bigquery_ml/bqml-online-prediction.ipynb @polong-lin
/model_monitoring/model_monitoring.ipynb @mco-gh
/model_monitoring/model_monitoring.ipynb @andrewferlitsch
/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb @jialuzh
/ml_metadata/sdk-metric-parameter-tracking-for-locally-trained-models.ipynb @jialuzh
/ml_metadata/vertex-pipelines-ml-metadata.ipynb @sararob
/vizier/gapic-vizier-multi-objective-optimization.ipynb @halio-g
/training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb @halio-g
/feature_store/gapic-feature-store.ipynb @diemtvu
/managed_notebooks @GoogleCloudPlatform/notebooks-team
/pipelines/google_cloud_pipeline_components_bqml_text.ipynb @inardini
@@ -31,7 +32,9 @@
/custom/custom_training_tensorboard_profiler.ipynb @itseric
/workbench/spark/spark_sample_notebook.ipynb @bradmiro
/workbench/spark/spark_ml.ipynb @bradmiro
/model-registry/bqml-vertexai-model-registry.ipynb @soheilazangeneh
/model_registry/bqml_vertexai_model_registry.ipynb @soheilazangeneh
/workbench/exploratory_data_analysis/explore_data_in_bigquery_with_workbench.ipynb @alokpattani
/model_evaluation/automl_tabular_classification_model_evaluation.ipynb @soheilazangeneh
/model_evaluation/automl_tabular_regression_model_evaluation.ipynb @soheilazangeneh
/tabular_workflows/tabnet_on_vertex_pipelines.ipynb @sakagarwal
/tabular_workflows/wide_and_deep_on_vertex_pipelines.ipynb @sakagarwal
+275 -344
View File
@@ -6,39 +6,29 @@ The official notebooks are organized by Google Cloud Vertex AI services.
## Manifest of Curated Notebooks
### AutoML
### AutoML Text data
[AutoML text classification model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl-text-classification.ipynb)
<blockquote>
In this tutorial, you learn how to use `AutoML` to train a text classification model.
[Create, train, and deploy an AutoML text classification model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl-text-classification.ipynb)
This tutorial uses the following Google Cloud ML services:
- `AutoML Training`
- `Vertex AI Model resource`
Learn how to use `AutoML` to train a text classification model.
The steps performed include:
- Create a `Vertex AI Dataset`
- Train an `AutoML` text classification `Model` resource.
- Obtain the evaluation metrics for the `Model` resource.
- Create an `Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Make an online prediction.
- Make a batch prediction.
</blockquote>
* Create a `Vertex AI Dataset`.
* Train an `AutoML` text classification `Model` resource.
* Obtain the evaluation metrics for the `Model` resource.
* Create an `Endpoint` resource.
* Deploy the `Model` resource to the `Endpoint` resource.
* Make an online prediction
* Make a batch prediction
[AutoML tabular forecasting model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_tabular_forecasting_batch.ipynb)
### AutoML Tabular data
<blockquote>
In this tutorial, you create an `AutoML` tabular forecasting model from a Python script, and then do a batch prediction using the Vertex AI SDK.
This tutorial uses the following Google Cloud ML services:
[AutoML tabular forecasting model for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_tabular_forecasting_batch.ipynb)
- `AutoML Training`
- `Vertex AI Batch Prediction`
- `Vertex AI Model` resource
Learn how to create an `AutoML` tabular forecasting model from a Python script, and then do a batch prediction using the Vertex AI SDK.
The steps performed include:
@@ -46,199 +36,130 @@ The steps performed include:
- Train an `AutoML` tabular forecasting `Model` resource.
- Obtain the evaluation metrics for the `Model` resource.
- Make a batch prediction.
</blockquote>
### Vertex AI Training
### BigQuery ML Vertex AI Model Registry Batch prediction
[Custom image classification model training and batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-batch.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Training` to create a custom trained model and use `Vertex AI Batch Prediction` to do a batch prediction on the trained model.
[Deploy BiqQuery ML Model on Vertex AI Model Registry and make predictions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model-registry/bqml-vertexai-model-registry.ipynb)
This tutorial uses the following Google Cloud ML services:
Learn how to use `Vertex AI Model Registry` with `BigQuery ML` and make batch predictions:
- `Vertex AI Training`
- `Vertex AI Batch Prediction`
- `Vertex AI Model` resource
The steps performed include:
- Train a model with `BigQuery ML`
- Upload the model to `Vertex AI Model Registry`
- Create a `Vertex AI Endpoint` resource
- Deploy the `Model` resource to the `Endpoint` resource
- Make `prediction` requests to the model endpoint
- Run `batch prediction` job on the `Model` resource
### BigQuery ML Vertex AI Model Registry Online prediction
[Online prediction with BigQuery ML](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb)
Learn how to train and deploy a churn prediction model for real-time inference, with the data in BigQuery and model trained using BigQuery ML, registered to Vertex AI Model Registry, and deployed to an endpoint on Vertex AI for online predictions.
The steps performed include:
- Using Python & SQL to query the public data in BigQuery
- Preparing the data for modeling
- Training a classification model using BigQuery ML and registering it to Vertex AI Model Registry
- Inspecting the model on Vertex AI Model Registry
- Deploying the model to an endpoint on Vertex AI
- Making sample online predictions to the model endpoint
### Custom Training
[Custom training and batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-batch.ipynb)
Learn to use `Vertex AI Training` to create a custom trained model and use `Vertex AI Batch Prediction` to do a batch prediction on the trained model.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- Upload the trained model artifacts as a `Model` resource.
- Make a batch prediction.
</blockquote>
[Custom image classification model training and online prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-online.ipynb)
[Custom training and online prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-online.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Training` to create a custom-trained model from a Python script in a Docker container, and learn to use `Vertex AI Prediction` to do a prediction on the deployed model by sending data.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Training`
- `Vertex AI Prediction`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
Learn to use `Vertex AI Training` to create a custom-trained model from a Python script in a Docker container, and learn to use `Vertex AI Prediction` to do a prediction on the deployed model by sending data.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- Upload the trained model artifacts to a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the Model resource to a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model` resource.
</blockquote>
### Vertex Explainable AI
### Tabular Data
[AutoML tabular binary classification model with batch explanations](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb)
<blockquote>
In this tutorial, you learn to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Batch Prediction` to make predictions with explanations.
[Compare Vertex AI Forecasting and BigQuery ML ARIMA_PLUS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb)
This tutorial uses the following Google Cloud ML services:
Learn how to create an BQML ARIMA_PLUS model using a training [Vertex AI Pipeline](https://cloud.
- `Vertex AI AutoML`
- `Vertex AI Batch Prediction`
- `Vertex Explainable AI`
- `Vertex AI Model` resource
The steps performed are:
- Train the BQML ARIMA_PLUS model.
- View BQML model evaluation.
- Make a batch prediction with the BQML model.
- Create a Vertex AI `Dataset` resource.
- Train the Vertex AI Forecasting model.
- View the Model evaluation.
- Make a batch prediction with the Model.
### AutoML Tabular Data
[AutoML Tabular Pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_tabular_on_vertex_pipelines.ipynb)
Learn how to create two regression models using [Vertex Pipelines](https://cloud.
The steps performed are:
- Create a training pipeline that reduces the search space from the default to save time.
- Create a training pipeline that reuses the architecture search results from the previous pipeline to save time.
### Vertex AI Experiments
[Compare pipeline runs with Vertex AI Experiments](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/comparing_pipeline_runs.ipynb)
Learn how to use `Vertex AI Experiments` to log a pipeline job and compare different pipeline jobs.
[Build Vertex AI Experiment lineage for custom training](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/build_model_experimentation_lineage_with_prebuild_code.ipynb)
Learn how to integrate preprocessing code in a Vertex AI experiments.
[Track parameters and metrics for locally trained models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/comparing_local_trained_models.ipynb)
Learn how to use Vertex AI Experiments to compare and evaluate model experiments.
The steps performed include:
- Create a `Vertex Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Make a batch prediction request with explainability.
</blockquote>
- log the model parameters
- log the loss and metrics on every epoch to TensorBoard
- log the evaluation metrics
[AutoML tabular binary classification model with online explanations](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb)
<blockquote>
In this tutorial, you learn to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Online Prediction` to make online predictions with explanations.
### Vertex AI Feature Store
This tutorial uses the following Google Cloud ML services:
- `Vertex AI AutoML`
- `Vertex AI Prediction`
- `Vertex Explainable AI`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
[Online and Batch predictions using Vertex AI Feature Store](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/sdk-feature-store.ipynb)
The steps performed include:
Learn how to use `Vertex AI Feature Store` to import feature data, and to access the feature data for both online serving and offline tasks, such as training.
- Create a `Vertex AI Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make an online prediction request with explainability.
- Undeploy the `Model` resource.
</blockquote>
[Custom tabular regression model with batch explanations](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Training` and `Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Training`
- `Vertex AI Batch Prediction`
- `Vertex Explainable AI`
- `Vertex AI Mode`l resource
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Make a batch prediction with explanations.
</blockquote>
[Custom tabular regression model with online explanations](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_tabular_regression_online_explain.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Training` and `Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Training`
- `Vertex AI Prediction`
- `Vertex Explainable AI`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction with explanation.
- Undeploy the `Model` resource.
</blockquote>
[Custom image classification model with batch explanations](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Training`
- `Vertex AI Batch Prediction`
- `Vertex Explainable AI`
- `Vertex AI Model` resource
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanation parameters as a `Model` resource.
- Make a batch prediction with explanations.
</blockquote>
[Custom image classification model with online explanations](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Training`
- `Vertex AI Online Prediction`
- `Vertex Explainable AI`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction with explanation.
- Undeploy the `Model` resource.
</blockquote>
### Vertex Feature Store
[Managing features in a feature store](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/gapic-feature-store.ipynb)
<blockquote>
In this notebook, you will learn how to use `Vertex AI Feature Store` to import feature data, and to access the feature data for both online serving and offline tasks, such as training.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Feature Store`
The steps performed include:
- Create featurestore, entity type, and feature resources.
@@ -246,21 +167,28 @@ The steps performed include:
- Serve online prediction requests using the imported features.
- Access imported features in offline jobs, such as training jobs.
</blockquote>
### Matching Engine
### Vertex Model Monitoring
[Monitoring drift detection in online serving](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_monitoring/model_monitoring.ipynb)
[Create Vertex AI Matching Engine index](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb)
<blockquote>
In this notebook, you learn to use the `Vertex AI Model Monitoring` service to detect drift and anomalies in prediction requests from a deployed `Vertex AI Model` resource.
Learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes, and validate the performance of the index.
This tutorial uses the following Google Cloud ML services:
The steps performed include:
- `Vertex AI Model Monitoring`
- `Vertex AI Prediction`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
* Create ANN Index and Brute Force Index
* Create an IndexEndpoint with VPC Network
* Deploy ANN Index and Brute Force Index
* Perform online query
* Compute recall
### Model Monitoring
[Vertex AI Model Monitoring with Explainable AI Feature Attributions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/model_monitoring/model_monitoring.ipynb)
Learn to use the `Vertex AI Model Monitoring` service to detect drift and anomalies in prediction requests from a deployed `Vertex AI Model` resource.
The steps performed include:
@@ -268,149 +196,86 @@ The steps performed include:
- Create an `Vertex AI Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Initialize the baseline distribution for model monitoring.
- Generate synthetic prediction requests.
- Understand how to interpret the statistics, visualizations, other data reported by the model monitoring feature.
</blockquote>
### Vertex ML Metadata
[Tracking hyperparameters and metrics in custom training job](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb)
### Vertex AI Pipelines
<blockquote>
In this notebook, you learn how to use `Vertex ML Metadata` to track training parameters and evaluation metrics.
This tutorial uses the following Google Cloud ML services:
[Lightweight Python function-based components, and component I/O](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb)
- `Vertex ML Metadata`
- `Vertex AI Experiments`
The steps performed include:
- Track parameters and metrics for a `Vertex AI` custom trained model.
- Extract and perform analysis for all parameters and metrics within an Experiment.
</blockquote>
[Tracking hyperparameters and metrics in locally trained job](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/ml_metadata/sdk-metric-parameter-tracking-for-locally-trained-models.ipynb)
<blockquote>
In this notebook, you learn how to use `Vertex ML Metadata` to track training parameters and evaluation metrics.
This tutorial uses the following Google Cloud ML services:
- `Vertex ML Metadata`
- `Vertex AI Experiments`
The steps performed include:
- Track parameters and metrics for a locally trained model.
- Extract and perform analysis for all parameters and metrics within an Experiment.
</blockquote>
### Vertex AI Pipelines
[Creating Python function KFP components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb)
<blockquote>
In this tutorial, you learn to use the KFP SDK to build lightweight Python function-based components, and then you learn to use `Vertex AI Pipelines` to execute the pipeline.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Pipelines`
Learn to use the KFP SDK to build lightweight Python function-based components, and then you learn to use `Vertex AI Pipelines` to execute the pipeline.
The steps performed include:
- Build Python function-based KFP components.
- Construct a KFP pipeline.
- Pass Artifacts and parameters between components, both by path reference and by value.
- Use the kfp.dsl.importer method.
- Pass *Artifacts* and *parameters* between components, both by path reference and by value.
- Use the `kfp.dsl.importer` method.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
</blockquote>
[AutoML image classification model pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_images.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` image classification model.
### Vertex AI Pipelines Image data
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Pipelines`
- `Google Cloud Pipeline Components`
- `Vertex AutoML`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
[AutoML image classification pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_images.ipynb)
The steps performed include:
- Create a KFP pipeline:
- Create a `Vertex AI Dataset` resource.
- Train an `AutoML` image classification `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
</blockquote>
[AutoML tabular classification model pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/automl_tabular_classification_beans.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an AutoML tabular classification model.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Pipelines`
- `Google Cloud Pipeline Components`
- `Vertex AutoML`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
Learn how to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` image classification model.
The steps performed include:
- Create a KFP pipeline:
- Create a `Dataset` resource.
- Train an `AutoML` tabular classification `Model` resource.
- Train an AutoML image classification `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
</blockquote>
[AutoML tabular regression model pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_tabular.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` tabular regression model.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Pipelines`
- `Google Cloud Pipeline Components`
- `Vertex AutoML`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
### Vertex AI Pipelines Tabular data
[AutoML Tabular pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/automl_tabular_classification_beans.ipynb)
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` tabular classification model.
The steps performed include:
- Create a KFP pipeline:
- Create a `Dataset` resource.
- Train an `AutoML` tabular regression `Model` resource.
- Train an AutoML tabular classification `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
</blockquote>
[AutoML text classification model pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_text.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` text classification model.
This tutorial uses the following Google Cloud ML services:
[AutoML tabular regression pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_tabular.ipynb)
- `Vertex AI Pipelines`
- `Google Cloud Pipeline Components`
- `Vertex AutoML`
- `Vertex AI Model` resource
"- `Vertex AI Endpoint` resource
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` tabular regression model.
The steps performed include:
- Create a KFP pipeline:
- Create a `Dataset` resource.
- Train an AutoML tabular regression `Model` resource.
- Create an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
### Vertex AI Pipelines Text data
[AutoML text classification pipelines using google-cloud-pipeline-components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_automl_text.ipynb)
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build an `AutoML` text classification model.
The steps performed include:
@@ -421,20 +286,15 @@ The steps performed include:
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
</blockquote>
[Custom training and batch prediction using prebuilt components pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/custom_model_training_and_batch_prediction.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build a custom model.
This tutorial uses the following Google Cloud ML services:
### Vertex AI Pipelines
- `Vertex AI Pipelines`
- `Google Cloud Pipeline Components`
- `Vertex AI Training`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
[Custom training with pre-built Google Cloud Pipeline Components](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/custom_model_training_and_batch_prediction.ipynb)
Learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build a custom model.
The steps performed include:
@@ -442,42 +302,14 @@ The steps performed include:
- Train a custom model.
- Upload the trained model as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Make a batch prediction request.
</blockquote>
- Deploy the `Model` resource to the `Endpoint` resource.
- Make a batch prediction request.
[Custom training using prebuilt and custom components pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/google_cloud_pipeline_components_model_train_upload_deploy.ipynb)
<blockquote>
In this tutorial, you learn to use `Vertex AI Pipelines` and `Google Cloud Pipeline Components` to build and deploy a custom model.
This tutorial uses the following Google Cloud ML services:
[Pipeline control structures using the KFP SDK](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/control_flow_kfp.ipynb)
- `Vertex AI Pipelines`
- `Google Cloud Pipeline Components`
- `Vertex AI Training`
- `Vertex AI Model` resource
- `Vertex AI Endpoint` resource
The steps performed include:
- Create a KFP pipeline:
- Train a custom model.
- Uploads the trained model as a `Model` resource.
- Creates an `Endpoint` resource.
- Deploys the `Model` resource to the `Endpoint` resource.
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
</blockquote>
[Introduction to control flow in pipelines](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/control_flow_kfp.ipynb)
<blockquote>
In this tutorial, you use the KFP SDK to build pipelines that use loops and conditionals, including nested examples.
This tutorial uses the following Google Cloud ML services:
- `Vertex AI Pipelines`
Learn how to use the KFP SDK to build pipelines that use loops and conditionals, including nested examples.
The steps performed include:
@@ -485,27 +317,126 @@ The steps performed include:
- Use control flow components
- Compile the KFP pipeline.
- Execute the KFP pipeline using `Vertex AI Pipelines`
</blockquote>
[Introduction to KFP components and pipelines](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/pipelines_intro_kfp.ipynb)
[Metrics visualization and run comparison using the KFP SDK](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/metrics_viz_run_compare_kfp.ipynb)
<blockquote>
In this tutorial, you use the KFP SDK to build pipelines.
Learn how to use the KFP SDK to build pipelines that generate evaluation metrics.
This tutorial uses the following Google Cloud ML services:
The steps performed include:
- `Vertex AI Pipelines`
- Create KFP components:
- Generate ROC curve and confusion matrix visualizations for classification results
- Write metrics
- Create KFP pipelines.
- Execute KFP pipelines
- Compare metrics across pipeline runs
[Pipelines introduction for KFP](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/pipelines/pipelines_intro_kfp.ipynb)
Learn how to use the KFP SDK to build pipelines that generate evaluation metrics.
The steps performed include:
- Define and compile a `Vertex AI` pipeline.
- Schedule a recurring pipeline run.
- Specify which service account to use for a pipeline run.
</blockquote>
### Vertex AI Vizier
### Vertex AI Vizier
[Using Vizier for multi-objective study](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/vizier/gapic-vizier-multi-objective-optimization.ipynb)
[Optimizing multiple objectives with Vertex AI Vizier](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/vizier/gapic-vizier-multi-objective-optimization.ipynb)
Learn how to use `Vertex AI Vizier` to optimize a multi-objective study.
### Vertex Explainable AI Tabular data
[AutoML training tabular binary classification model for batch explanation](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb)
Learn to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Batch Prediction` to make predictions with explanations.
The steps performed include:
- Create a `Vertex Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Make a batch prediction request with explainability.
* Prediction Service: Does an on-demand prediction for the entire set of instances (i.e., one or more data items) and returns the results in real-time.
* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready.
[AutoML training tabular classification model for online explanation](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb)
Learn how to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Online Prediction` to make online predictions with explanations.
The steps performed include:
- Create a `Vertex Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make an online prediction request with explainability.
- Undeploy the `Model` resource.
### Vertex Explainable AI Image data
[Custom training image classification model for batch prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb)
Learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanation parameters as a `Model` resource.
- Make a batch prediction with explanations.
[Custom training image classification model for online prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb)
Learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction with explanation.
- Undeploy the `Model` resource.
### Vertex Explainable AI Tabular data
[Custom training tabular regression model for batch prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb)
Learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Make a batch prediction with explanations.
### Vertex ML Metadata
[Track parameters and metrics for custom training jobs](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/ml_metadata/sdk-metric-parameter-tracking-for-custom-jobs.ipynb)
Learn how to use Vertex AI SDK for Python to:
The steps performed include:
- Track training parameters and prediction metrics for a custom training job.
- Extract and perform analysis for all parameters and metrics within an Experiment.
+177
View File
@@ -0,0 +1,177 @@
[AutoML Tabular Training and Prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl-tabular-classification.ipynb)
Learn how to train and make predictions on an AutoML model based on a tabular dataset.
The steps performed include the following:
- Create a Vertex AI model training job.
- Train an AutoML Tabular model.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction by sending data.
- Undeploy the `Model` resource.
[Create, train, and deploy an AutoML text classification model](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl-text-classification.ipynb)
Learn how to use `AutoML` to train a text classification model.
The steps performed include:
* Create a `Vertex AI Dataset`.
* Train an `AutoML` text classification `Model` resource.
* Obtain the evaluation metrics for the `Model` resource.
* Create an `Endpoint` resource.
* Deploy the `Model` resource to the `Endpoint` resource.
* Make an online prediction
* Make a batch prediction
[AutoML training video classification model for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_video_classification_batch.ipynb)
Learn how to create an AutoML video classification model from a Python script, and then do a batch prediction using the Vertex AI SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train the model.
- View the model evaluation.
- Make a batch prediction.
* Prediction Service: Does an on-demand prediction for the entire set of instances (i.e., one or more data items) and returns the results in real-time.
* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready.
[AutoML training text entity extraction model for online prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_text_entity_extraction_online.ipynb)
Learn how to create an AutoML text entity extraction model and deploy for online prediction from a Python script using the Vertex SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
[AutoML tabular forecasting model for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_tabular_forecasting_batch.ipynb)
Learn how to create an `AutoML` tabular forecasting model from a Python script, and then do a batch prediction using the Vertex AI SDK.
The steps performed include:
- Create a `Vertex AI Dataset` resource.
- Train an `AutoML` tabular forecasting `Model` resource.
- Obtain the evaluation metrics for the `Model` resource.
- Make a batch prediction.
[AutoML training image object detection model for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_image_object_detection_batch.ipynb)
Learn how to create an AutoML image object detection model from a Python script, and then do a batch prediction using the Vertex AI SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train the model.
- View the model evaluation.
- Make a batch prediction.
* Prediction Service: Does an on-demand prediction for the entire set of instances (i.e., one or more data items) and returns the results in real-time.
* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready.
[AutoML training video action recognition model for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_video_action_recognition_batch.ipynb)
Learn how to create an AutoML video action recognition model from a Python script, and then do a batch prediction using the Vertex AI SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train the model.
- View the model evaluation.
- Make a batch prediction.
* Prediction Service: Does an on-demand prediction for the entire set of instances (i.e., one or more data items) and returns the results in real-time.
* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready.
[AutoML Tabular Pipeline](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_tabular_on_vertex_pipelines.ipynb)
Learn how to create two regression models using [Vertex Pipelines](https://cloud.
The steps performed are:
- Create a training pipeline that reduces the search space from the default to save time.
- Create a training pipeline that reuses the architecture search results from the previous pipeline to save time.
[AutoML training text sentiment analysis model for online prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_text_sentiment_analysis_online.ipynb)
Learn how to create an AutoML text sentiment analysis model and deploy for online prediction from a Python script using the Vertex SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Create a training job for the model.
- View the model evaluation.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
[Compare Vertex AI Forecasting and BigQuery ML ARIMA_PLUS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl_forecasting_bqml_arima_plus_comparison.ipynb)
Learn how to create an BQML ARIMA_PLUS model using a training [Vertex AI Pipeline](https://cloud.
The steps performed are:
- Train the BQML ARIMA_PLUS model.
- View BQML model evaluation.
- Make a batch prediction with the BQML model.
- Create a Vertex AI `Dataset` resource.
- Train the Vertex AI Forecasting model.
- View the Model evaluation.
- Make a batch prediction with the Model.
[AutoML training tabular regression model for online prediction using BigQuery](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/master/notebooks/official/automl/sdk_automl_tabular_regression_online_bq.ipynb)
Learn how to create an AutoML tabular regression model and deploy for online prediction from a Python script using the Vertex AI SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
[AutoML training video object tracking model for batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_video_object_tracking_batch.ipynb)
Learn how to create an AutoML video object tracking model from a Python script, and then do a batch prediction using the Vertex SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train the model.
- View the model evaluation.
- Make a batch prediction.
* Prediction Service: Does an on-demand prediction for the entire set of instances (i.e., one or more data items) and returns the results in real-time.
* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready.
[AutoML training tabular regression model for batch prediction using BigQuery](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_tabular_regression_batch_bq.ipynb)
Learn how to create an AutoML tabular regression model and deploy it for batch prediction using the Vertex AI SDK for Python.
The steps performed include:
- Create a Vertex AI `Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
@@ -29,20 +29,41 @@
"id": "JAPoU8Sm5E6e"
},
"source": [
"<table align=\"left\">\n",
"# Vertex AI SDK for Python: AutoML Tabular Training and Prediction\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/automl/automl-tabular-classification.ipynb\"\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl-tabular-classification.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/automl/automl-tabular-classification.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/automl-tabular-classification.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
"</table>"
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/automl/automl-tabular-classification.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
"<br/><br/><br/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "411c6c769293"
},
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use the Vertex AI Python client library to train and deploy a tabular classification model for online prediction.\n",
"\n",
"**Note**: you may incur charges for training, prediction, storage, or usage of other GCP products in connection with testing this SDK."
]
},
{
@@ -51,24 +72,9 @@
"id": "tvgnzT1CKxrO"
},
"source": [
"# Vertex AI SDK for Python: AutoML Tabular Training and Prediction\n",
"\n",
"To use this Colaboratory notebook, you copy the notebook to your own Google Drive and open it with Colaboratory (or Colab). You can run each step, or cell, and see its results. To run a cell, use Shift+Enter. Colab automatically displays the return value of the last line in each cell. For more information about running notebooks in Colab, see the Colab welcome page.\n",
"\n",
"\n",
"## Overview\n",
"\n",
"This tutorial demonstrates how to use the Vertex AI Python client library to train and deploy a tabular classification model for online prediction.\n",
"\n",
"**Note**: you may incur charges for training, prediction, storage, or usage of other GCP products in connection with testing this SDK.\n",
"\n",
"### Dataset\n",
"\n",
"The dataset we are using is the PetFinder Dataset, available locally in Colab. To learn more about this dataset, visit https://www.kaggle.com/c/petfinder-adoption-prediction.\n",
"\n",
"### Objective\n",
"\n",
"This notebook demonstrates, using the Vertex AI Python client library, how to train and make predictions on an AutoML model based on a tabular dataset. Alternatively, you can train and make predictions on models by using the `gcloud` command-line tool or by using the online Cloud Console.\n",
"In this tutorial, you learn how to train and make predictions on an AutoML model based on a tabular dataset. Alternatively, you can train and make predictions on models by using the `gcloud` command-line tool or by using the online Cloud Console.\n",
"\n",
"The steps performed include the following:\n",
"\n",
@@ -76,8 +82,26 @@
"- Train an AutoML Tabular model.\n",
"- Deploy the `Model` resource to a serving `Endpoint` resource.\n",
"- Make a prediction by sending data.\n",
"- Undeploy the `Model` resource.\n",
"- Undeploy the `Model` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "d87e05416046"
},
"source": [
"### Dataset\n",
"\n",
"The dataset we are using is the PetFinder Dataset, available locally in Colab. To learn more about this dataset, visit https://www.kaggle.com/c/petfinder-adoption-prediction."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5e2eba58ad71"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
@@ -61,7 +61,7 @@
"source": [
"## Overview\n",
"\n",
"In this tutorial, you take on the role of a store planner who must determine how much inventory they will need to order for each of their products and stores for November 2019. You will accomplish this by training forecasting models using historical sales data. You will start with a baseline model using BigQuery ML (BQML) [ARIMA_PLUS](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create-time-series) and then compare it against a [Vertex AI Forecasting](https://cloud.google.com/vertex-ai/docs/tabular-data/forecasting/overview) model."
"In this tutorial, you take on the role of a store planner who must determine how much inventory they will need to order for each of their products and stores for November 2019. You accomplish this by training forecasting models using historical sales data. You start with a baseline model using BigQuery ML (BQML) [ARIMA_PLUS](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create-time-series) and then compare it against a [Vertex AI Forecasting](https://cloud.google.com/vertex-ai/docs/tabular-data/forecasting/overview) model."
]
},
{
@@ -72,13 +72,18 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an BQML ARIMA_PLUS model using a training [Vertex AI Pipeline](https://cloud.google.com/vertex-ai/docs/pipelines/introduction) from [Google Cloud Pipeline Components](https://cloud.google.com/vertex-ai/docs/pipelines/components-introduction) (GCPC), and then do a batch prediction using the corresponding prediction pipeline. You then train a Vertex AI Forecasting model using the same data and compare the evaluation metrics.\n",
"In this tutorial, you learn how to create an BigQuery ML ARIMA_PLUS model using a training [Vertex AI Pipeline](https://cloud.google.com/vertex-ai/docs/pipelines/introduction) from [Google Cloud Pipeline Components](https://cloud.google.com/vertex-ai/docs/pipelines/components-introduction) (GCPC), and then do a batch prediction using the corresponding prediction pipeline. You then train a Vertex AI Forecasting model using the same data and compare the evaluation metrics.\n",
"\n",
"This tutorial uses the following Google Cloud ML services and resources:\n",
"\n",
"- BigQuery\n",
"- Vertex AI\n",
"\n",
"The steps performed are:\n",
"\n",
"- Train the BQML ARIMA_PLUS model.\n",
"- View BQML model evaluation.\n",
"- Make a batch prediction with the BQML model.\n",
"- Train the BigQuery ML ARIMA_PLUS model.\n",
"- View BigQuery ML model evaluation.\n",
"- Make a batch prediction with the BigQuery ML model.\n",
"- Create a Vertex AI `Dataset` resource.\n",
"- Train the Vertex AI Forecasting model.\n",
"- View the Model evaluation.\n",
@@ -93,7 +98,7 @@
"source": [
"### Dataset\n",
"\n",
"To demonstrate the tradeoffs between using BQML and Vertex AI Forecasting, this tutorial will use a synthetic dataset where product sales are dependent on a variety of factors such as advertisements, holidays, and locations. You will see how well a univariate model like ARIMA_PLUS can forecast future sales without knowing information about these factors explicitly, and how well a multivariate model like Vertex AI Forecasting can perform when these factors are known."
"To demonstrate the tradeoffs between using BigQuery ML and Vertex AI Forecasting, this tutorial will use a synthetic dataset where product sales are dependent on a variety of factors such as advertisements, holidays, and locations. You see how well a univariate model like ARIMA_PLUS can forecast future sales without knowing information about these factors explicitly, and how well a multivariate model like Vertex AI Forecasting can perform when these factors are known."
]
},
{
@@ -108,7 +113,7 @@
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"* BigQuery / BQML\n",
"* BigQuery / BigQuery ML\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing), [Cloud Storage\n",
@@ -241,7 +246,7 @@
"\n",
"3. [Enable the following APIs: Vertex AI APIs, Compute Engine APIs, and Cloud Storage.](https://console.cloud.google.com/flows/enableapi?apiid=ml.googleapis.com,compute_component,storage-component.googleapis.com)\n",
"\n",
"4. If you are running this notebook locally, you will need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"4. If you are running this notebook locally, you need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"\n",
"5. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
@@ -270,8 +275,7 @@
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}\n",
"SERVICE_ACCOUNT = \"\" # @param {type:\"string\"}"
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
]
},
{
@@ -286,8 +290,7 @@
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)\n",
"SERVICE_ACCOUNT = SERVICE_ACCOUNT or None"
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
@@ -308,7 +311,7 @@
},
"source": [
"#### Region\n",
"All BigQuery operations (`DATA_REGION`) are set to run in the `US` multi-region. This is required by the ARIMA pipeline because the data you will be using is stored in this region. All destination tables will also be stored in this region.\n",
"All BigQuery operations (`DATA_REGION`) are set to run in the `US` multi-region. This is required by the ARIMA pipeline because the data you use is stored in this region. All destination tables will also be stored in this region.\n",
"\n",
"You may change the `REGION` variable, which is used for Vertex AI Forecasting operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
@@ -451,30 +454,41 @@
},
"outputs": [],
"source": [
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4FxNxXwW3inJ"
},
"source": [
"Create the bucket if it doesn't already exist."
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_bucket"
"id": "4FxNxXwW3inJ"
},
"outputs": [],
"source": [
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + UUID\n",
"\n",
"! gsutil ls -b $BUCKET_URI || gsutil mb -l $REGION $BUCKET_URI"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "autoset_bucket"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "91c46850b49b"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URI"
]
},
{
@@ -497,15 +511,84 @@
"! gsutil ls -al $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "85c4ecfd133a"
},
"source": [
"#### Service Account \n",
"\n",
"You use a service account to create Vertex AI Pipeline jobs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "77b01a1fdbb4"
},
"outputs": [],
"source": [
"SERVICE_ACCOUNT = \"[your-service-account]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "f936bebda2d4"
},
"outputs": [],
"source": [
"if (\n",
" SERVICE_ACCOUNT == \"\"\n",
" or SERVICE_ACCOUNT is None\n",
" or SERVICE_ACCOUNT == \"[your-service-account]\"\n",
"):\n",
" # Get your service account from gcloud\n",
" if not IS_COLAB:\n",
" shell_output = !gcloud auth list 2>/dev/null\n",
" SERVICE_ACCOUNT = shell_output[2].replace(\"*\", \"\").strip()\n",
"\n",
" else: # IS_COLAB:\n",
" shell_output = ! gcloud projects describe $PROJECT_ID\n",
" project_number = shell_output[-1].split(\":\")[1].strip().replace(\"'\", \"\")\n",
" SERVICE_ACCOUNT = f\"{project_number}-compute@developer.gserviceaccount.com\"\n",
"\n",
" print(\"Service Account:\", SERVICE_ACCOUNT)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "40ef6967cad3"
},
"source": [
"#### Set service account access for Vertex AI Pipelines\n",
"\n",
"Run the following commands to grant your service account access to read and write pipeline artifacts in the bucket that you created in the previous step. You only need to run this step once per service account."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "f88cb0488c08"
},
"outputs": [],
"source": [
"! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectCreator $BUCKET_URI\n",
"\n",
"! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectViewer $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "setup_vars"
},
"source": [
"### Set up variables\n",
"\n",
"Next, set up some variables used throughout the tutorial.\n",
"### Import libraries and define constants"
]
},
@@ -565,7 +648,7 @@
"source": [
"### Location of BigQuery destination table.\n",
"\n",
"Create two datasets, one for each model you will train. To make things simpler, create the datasets in the same region as the training data."
"#### Create two datasets, one for each model you train. To make things simpler, create the datasets in the same region as the training data."
]
},
{
@@ -606,7 +689,7 @@
"\n",
"Before training a model, you must first generate our dataset of store sales. This dataset will include multiple products and stores, and it will also simulate factors such as advertisements and holiday effects. The data will be split into `TRAIN`, `VALIDATE`, `TEST`, and `PREDICT` sets, where the last three sets are all 1 month in duration.\n",
"\n",
"Begin by defining the subqueries that will create this base sales data."
"#### Begin by defining the subqueries that will create this base sales data."
]
},
{
@@ -715,7 +798,7 @@
"id": "IdWrtxYtqdsh"
},
"source": [
"Next, convert this base sales data into a dataset you will use to train a model, and a dataset you will pass to a trained model at serving time. The training dataset will include the `TRAIN`, `VALIDATE`, and `TEST` splits, while the prediction dataset will include the `PREDICT` split and also the `TEST` split to provide context information."
"#### Next, convert this base sales data into a dataset you use to train a model, and a dataset you pass to a trained model at serving time. The training dataset will include the `TRAIN`, `VALIDATE`, and `TEST` splits, while the prediction dataset will include the `PREDICT` split and also the `TEST` split to provide context information."
]
},
{
@@ -764,7 +847,9 @@
"source": [
"You can take a look at the sales data that was generated. Later in this tutorial, we will visualize the time series along with our forecast.\n",
"\n",
"The model is trained with data from January 2017 to October 2019 inclusive."
"The model is trained with data from January 2017 to October 2019 inclusive.\n",
"\n",
"#### Look at the training data"
]
},
{
@@ -785,7 +870,9 @@
"id": "F00dL8oEqqVb"
},
"source": [
"The table used for prediction contains data from November 2019. It also includes actuals from October 2019 as context information."
"The table used for prediction contains data from November 2019. It also includes actuals from October 2019 as context information.\n",
"\n",
"#### Look at the prediction data"
]
},
{
@@ -806,17 +893,17 @@
"id": "tutorial_start:automl"
},
"source": [
"# Create a BQML ARIMA_PLUS model\n",
"# Create a BigQuery ML ARIMA_PLUS model\n",
"\n",
"Now you are ready to start creating your own BQML ARIMA_PLUS model.\n",
"Now you are ready to start creating your own BigQuery ML ARIMA_PLUS model.\n",
"\n",
"Like with Vertex AI Forecasting, the pipeline you will run will train evaluation models using the training and validation sets and use backtesting to create evaluation metrics on the test set. Finally, a serving model will be produced that uses all available data.\n",
"Like with Vertex AI Forecasting, the pipeline you run will train evaluation models using the training and validation sets and use backtesting to create evaluation metrics on the test set. Finally, a serving model will be produced that uses all available data.\n",
"\n",
"**How do you estimate the cost?**\n",
"\n",
"Backtesting involves training a single BQML model for each period in the test set, so the cost is a function of the length of the test set after any downsampling done by the windowing strategy. The cost is also multiplied by the number of candidate models trained, which is determined by `max_order`.\n",
"Backtesting involves training a single BigQuery ML model for each period in the test set, so the cost is a function of the length of the test set after any downsampling done by the windowing strategy. The cost is also multiplied by the number of candidate models trained, which is determined by `max_order`.\n",
"\n",
"According to [BQ pricing](https://cloud.google.com/bigquery-ml/pricing), BQML model creation costs $250 per TB. We'll use a max order of 3, which translates to 20 candidate models when there are multiple time series. Our demo dataset is 3 MB in size, and includes 31 test periods. We window with a stride length of 1, so all periods are used for evaluation.\n",
"According to [BQ pricing](https://cloud.google.com/bigquery-ml/pricing), BigQuery ML model creation costs $250 per TB. We'll use a max order of 3, which translates to 20 candidate models when there are multiple time series. Our demo dataset is 3 MB in size, and includes 31 test periods. We window with a stride length of 1, so all periods are used for evaluation.\n",
"\n",
"In this tutorial, the model create stage of the pipeline costs `3 MB * ($250 / 1024^2) * (31 / 1) periods * 20 candidates = $0.44`."
]
@@ -827,7 +914,7 @@
"id": "t04OJzrORmJ4"
},
"source": [
"## Create and run training job\n",
"## Create and run the training job\n",
"To train a model using the ARIMA pipeline, you perform two steps: \n",
"\n",
"1. download the training pipeline from GCPC.\n",
@@ -904,7 +991,7 @@
"source": [
"### Run the training pipeline\n",
"\n",
"Use the Vertex AI Python SDK to kick off a training pipeline run. Once the run has started, the following cell will output a link that will allow you to monitor the run. The link should look like this: \n",
"Use the Vertex AI Python SDK to kick off a training pipeline run. Once the run has started, the following cell outputs a link that will allow you to monitor the run. The link should look like this: \n",
"\n",
"`https://console.cloud.google.com/vertex-ai/locations/[REGION]/pipelines/runs/[DISPLAY_NAME]`"
]
@@ -939,7 +1026,7 @@
"## Review model evaluation scores\n",
"After your model has finished training, you can review the evaluation scores for it.\n",
"\n",
"Metrics are always reported via the `metrics` table in the destination dataset."
"#### Metrics are always reported via the `metrics` table in the destination dataset."
]
},
{
@@ -961,7 +1048,11 @@
"id": "jsRVi6AoiUIE"
},
"source": [
"You can also view the predictions used to calculate the evaluation metrics if you want to calculate your own. This table containing all these predictions is called `evaluated_examples`. In this table, each distinct `predicted_on_date` represents the starting period of a window of predictions. The backtesting metrics make use of all these windows."
"You can view the predictions used to calculate the evaluation metrics if you want to calculate your own. \n",
"\n",
"#### View predictions used to calculate the evaluation metrics\n",
"\n",
"This table containing all these predictions is called `evaluated_examples`. In this table, each distinct `predicted_on_date` represents the starting period of a window of predictions. The backtesting metrics make use of all these windows."
]
},
{
@@ -991,7 +1082,7 @@
"- `bigquery_destination_uri`: (optional) BigQuery Dataset URI. Used to export the metrics table and model. If not given, we will create one for the user.\n",
"- `data_source_csv_filenames` or `data_source_bigquery_table_path`: A URI for either a CSV stored in GCR or a BigQuery table, respectively.\n",
"- `generate_explanation`: If True, the predictions table will have some extra xAI columns.\n",
"- `model_name`: Name of an existing BQML ARIMA_PLUS model to use for predictions.\n",
"- `model_name`: Name of an existing BigQuery ML ARIMA_PLUS model to use for predictions.\n",
"\n",
"The execution of the prediction pipeline may take around **5 minutes**."
]
@@ -1004,7 +1095,7 @@
},
"outputs": [],
"source": [
"# Get the model name programmatically, you can also find this by looking at the\n",
"# Get the model name programmatically, you can find this by looking at the\n",
"# execution graph in Vertex AI Pipelines.\n",
"for task_detail in job.gca_resource.job_detail.task_details:\n",
" if task_detail.task_name == \"bigquery-create-model-job\":\n",
@@ -1034,7 +1125,7 @@
"source": [
"### Run the prediction pipeline\n",
"\n",
"Use the Vertex AI Python SDK to kick off a prediction pipeline run. Once the run has started, the following cell will output a link that will allow you to monitor the run. The link should look like this: \n",
"Use the Vertex AI Python SDK to kick off a prediction pipeline run. Once the run has started, the following cell outputs a link that will allow you to monitor the run. The link should look like this: \n",
"\n",
"`https://console.cloud.google.com/vertex-ai/locations/[REGION]/pipelines/runs/[DISPLAY_NAME]`"
]
@@ -1079,7 +1170,7 @@
},
"outputs": [],
"source": [
"# Get the prediction table programmatically, you can also find this by looking at the\n",
"# Get the prediction table programmatically, you can find this by looking at the\n",
"# execution graph in Vertex AI Pipelines.\n",
"for task_detail in job.gca_resource.job_detail.task_details:\n",
" if task_detail.task_name == \"bigquery-query-job\":\n",
@@ -1246,7 +1337,7 @@
"id": "create_automl_pipeline:tabular,forecast"
},
"source": [
"### Create and run training job\n",
"### Create and run the training job\n",
"\n",
"To train an AutoML model, you perform two steps: 1) create a training job, and 2) run the job.\n",
"\n",
@@ -1327,7 +1418,7 @@
"- `time_column`: Name of the column that identifies time order in the time series. This column must be available at forecast.\n",
"- `time_series_identifier_column`: Name of the column that identifies the time series.\n",
"\n",
"You can also specify the split with either\n",
"You can specify the split with either\n",
"- `training_fraction_split`: The percentage of the dataset to use for training.\n",
"- `validation_fraction_split`: The percentage of the dataset to use for validation.\n",
"- `test_fraction_split`: The percentage of the dataset to use for test (holdout data).\n",
@@ -1421,7 +1512,7 @@
"\n",
"Now that you have backtesting metrics from both models, you can compare the two side-by-side.\n",
"\n",
"Since the sales in this dataset were a function of covariates, we should expect the MAE, RMSE, and MAPE to be lower when using Vertex AI Forecasting. The BQML ARIMA_PLUS evaluation metrics show the relative impact of including these additional features in a model."
"Since the sales in this dataset were a function of covariates, we should expect the MAE, RMSE, and MAPE to be lower when using Vertex AI Forecasting. The BigQuery ML ARIMA_PLUS evaluation metrics show the relative impact of including these additional features in a model."
]
},
{
@@ -1620,8 +1711,9 @@
"for dataset_id in [arima_dataset_path, vertex_dataset_path]:\n",
" client.delete_dataset(dataset_id, delete_contents=True, not_found_ok=True)\n",
"\n",
"if os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
"delete_bucket = False\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil -m rm -r $BUCKET_URI"
]
}
],
@@ -64,17 +64,6 @@
"In this tutorial, you will use two Vertex AI Tabular Workflows pipelines to train AutoML models using different configurations. You will see how `get_automl_tabular_pipeline_and_parameters` gives you the ability to customize the default AutoML Tabular pipeline, and how `get_skip_architecture_search_pipeline_and_parameters` allows you to reduce the training time and cost for an AutoML model by using the tuning results from a previous pipeline run."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eac26958afe8"
},
"source": [
"### Dataset\n",
"\n",
"The dataset you will be using is the [Safe Driver Prediction](https://www.kaggle.com/competitions/porto-seguro-safe-driver-prediction/data?select=train.csv) dataset for predicting the probability of an auto insurance policy holder filing a claim for a given incident."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -83,7 +72,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create two regression models using [Vertex Pipelines](https://cloud.google.com/vertex-ai/docs/pipelines/introduction) downloaded from [Google Cloud Pipeline Components](https://cloud.google.com/vertex-ai/docs/pipelines/components-introduction) (GCPC). These pipelines will be Vertex AI Tabular Workflow pipelines which are maintained by Google. These pipelines will showcase different ways to customize the Vertex Tabular training process.\n",
"In this tutorial, you learn how to create two regression models using [Vertex Pipelines](https://cloud.google.com/vertex-ai/docs/pipelines/introduction) downloaded from [Google Cloud Pipeline Components](https://cloud.google.com/vertex-ai/docs/pipelines/components-introduction) (GCPC). These pipelines will be Vertex AI Tabular Workflow pipelines which are maintained by Google. These pipelines will showcase different ways to customize the Vertex Tabular training process.\n",
"\n",
"The steps performed are:\n",
"\n",
@@ -91,6 +80,18 @@
"- Create a training pipeline that reuses the architecture search results from the previous pipeline to save time."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eac26958afe8"
},
"source": [
"### Dataset\n",
"\n",
"The dataset you will be using is [Bank Marketing](https://archive.ics.uci.edu/ml/datasets/bank+marketing).\n",
"The data is for direct marketing campaigns (phone calls) of a Portuguese banking institution. The binary classification goal is to predict if a client will subscribe a term deposit. For this notebook, we randomly selected 90% of the rows in the original dataset and saved them in a train.csv file hosted on Cloud Storage. To download the file, click [here](https://storage.googleapis.com/cloud-samples-data/vertex-ai/tabular-workflows/datasets/bank-marketing/train.csv)."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -638,9 +639,9 @@
"root_dir = os.path.join(BUCKET_URI, \"automl_tabular_pipeline\")\n",
"prediction_type = \"classification\"\n",
"optimization_objective = \"minimize-log-loss\"\n",
"target_column = \"target\"\n",
"target_column = \"deposit\"\n",
"data_source_csv_filenames = (\n",
" \"gs://cloud-samples-data/vertex-ai/tabular-workflows/datasets/safe-driver/train.csv\"\n",
" \"gs://cloud-samples-data/vertex-ai/tabular-workflows/datasets/bank-marketing/train.csv\"\n",
")\n",
"data_source_bigquery_table_path = None # format: bq://bq_project.bq_dataset.bq_table\n",
"\n",
@@ -659,63 +660,22 @@
"weight_column = None\n",
"\n",
"features = [\n",
" \"ps_ind_01\",\n",
" \"ps_ind_02_cat\",\n",
" \"ps_ind_03\",\n",
" \"ps_ind_04_cat\",\n",
" \"ps_ind_05_cat\",\n",
" \"ps_ind_06_bin\",\n",
" \"ps_ind_07_bin\",\n",
" \"ps_ind_08_bin\",\n",
" \"ps_ind_09_bin\",\n",
" \"ps_ind_10_bin\",\n",
" \"ps_ind_11_bin\",\n",
" \"ps_ind_12_bin\",\n",
" \"ps_ind_13_bin\",\n",
" \"ps_ind_14\",\n",
" \"ps_ind_15\",\n",
" \"ps_ind_16_bin\",\n",
" \"ps_ind_17_bin\",\n",
" \"ps_ind_18_bin\",\n",
" \"ps_reg_01\",\n",
" \"ps_reg_02\",\n",
" \"ps_reg_03\",\n",
" \"ps_car_01_cat\",\n",
" \"ps_car_02_cat\",\n",
" \"ps_car_03_cat\",\n",
" \"ps_car_04_cat\",\n",
" \"ps_car_05_cat\",\n",
" \"ps_car_06_cat\",\n",
" \"ps_car_07_cat\",\n",
" \"ps_car_08_cat\",\n",
" \"ps_car_09_cat\",\n",
" \"ps_car_10_cat\",\n",
" \"ps_car_11_cat\",\n",
" \"ps_car_11\",\n",
" \"ps_car_12\",\n",
" \"ps_car_13\",\n",
" \"ps_car_14\",\n",
" \"ps_car_15\",\n",
" \"ps_calc_01\",\n",
" \"ps_calc_02\",\n",
" \"ps_calc_03\",\n",
" \"ps_calc_04\",\n",
" \"ps_calc_05\",\n",
" \"ps_calc_06\",\n",
" \"ps_calc_07\",\n",
" \"ps_calc_08\",\n",
" \"ps_calc_09\",\n",
" \"ps_calc_10\",\n",
" \"ps_calc_11\",\n",
" \"ps_calc_12\",\n",
" \"ps_calc_13\",\n",
" \"ps_calc_14\",\n",
" \"ps_calc_15_bin\",\n",
" \"ps_calc_16_bin\",\n",
" \"ps_calc_17_bin\",\n",
" \"ps_calc_18_bin\",\n",
" \"ps_calc_19_bin\",\n",
" \"ps_calc_20_bin\",\n",
" \"age\",\n",
" \"job\",\n",
" \"marital\",\n",
" \"education\",\n",
" \"default\",\n",
" \"balance\",\n",
" \"housing\",\n",
" \"loan\",\n",
" \"contact\",\n",
" \"day\",\n",
" \"month\",\n",
" \"duration\",\n",
" \"campaign\",\n",
" \"pdays\",\n",
" \"previous\",\n",
" \"poutcome\",\n",
"]\n",
"transformations = generate_auto_transformation(features)\n",
"transform_config_path = os.path.join(root_dir, f\"transform_config_{uuid.uuid4()}.json\")\n",
@@ -74,7 +74,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML image object detection model from a Python script, and then do a batch prediction using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to create an AutoML image object detection model from a Python script, and then do a batch prediction using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_tabular_forecasting_batch.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/automl/sdk_automl_tabular_forecasting_batch.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an `AutoML` tabular forecasting model from a Python script, and then do a batch prediction using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to create an `AutoML` tabular forecasting model from a Python script, and then do a batch prediction using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -64,17 +64,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK for Python to create tabular regression models and do batch prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [GSOD dataset](https://console.cloud.google.com/marketplace/product/noaa-public/gsod) from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). In this version of the dataset, you use the year, month, and day fields to predict the mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -83,7 +72,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML tabular regression model and deploy it for batch prediction using the Vertex AI SDK for Python. You can alternatively create and deploy models using the `gcloud` command-line tool or batch using the Cloud Console.\n",
"In this tutorial, you learn how to create an AutoML tabular regression model and deploy it for batch prediction using the Vertex AI SDK for Python. You can alternatively create and deploy models using the `gcloud` command-line tool or batch using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -95,6 +84,17 @@
"- Undeploy the `Model`."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [GSOD dataset](https://console.cloud.google.com/marketplace/product/noaa-public/gsod) from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). In this version of the dataset, you use the year, month, and day fields to predict the mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/master/notebooks/official/automl/sdk_automl_tabular_regression_online_bq.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/automl/sdk_automl_tabular_regression_online_bq.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK for Python to create tabular regression models and do online prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset you use only the fields year, month and day to predict the value of mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML tabular regression model and deploy for online prediction from a Python script using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to create an AutoML tabular regression model and deploy for online prediction from a Python script using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -96,6 +85,17 @@
"- Undeploy the `Model`."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset you use only the fields year, month and day to predict the value of mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK for Python to create text entity extraction models and do online prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:biomedical,ten"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [NCBI Disease Research Abstracts dataset](https://www.ncbi.nlm.nih.gov/CBBresearch/Dogan/DISEASE/) from [National Center for Biotechnology Information](https://www.ncbi.nlm.nih.gov/). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML text entity extraction model and deploy for online prediction from a Python script using the Vertex SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to create an AutoML text entity extraction model and deploy for online prediction from a Python script using the Vertex SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -96,6 +85,17 @@
"- Undeploy the `Model`."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:biomedical,ten"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [NCBI Disease Research Abstracts dataset](https://www.ncbi.nlm.nih.gov/CBBresearch/Dogan/DISEASE/) from [National Center for Biotechnology Information](https://www.ncbi.nlm.nih.gov/). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -44,8 +44,8 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_text_sentiment_analysis_online.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_text_sentiment_analysis_online.ipynb\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -61,7 +61,27 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use the Vertex SDK to create text sentiment analysis models and do online prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
"This tutorial demonstrates how to use the Vertex AI SDK to create text sentiment analysis models and do online prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "objective:automl,training,online_prediction"
},
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to create an AutoML text sentiment analysis model and deploy for online prediction from a Python script using the Vertex SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
"- Create a Vertex `Dataset` resource.\n",
"- Create a training job for the model.\n",
"- View the model evaluation.\n",
"- Deploy the `Model` resource to a serving `Endpoint` resource.\n",
"- Make a prediction.\n",
"- Undeploy the `Model`."
]
},
{
@@ -75,26 +95,6 @@
"The dataset used for this tutorial is the [Crowdflower Claritin-Twitter dataset](https://data.world/crowdflower/claritin-twitter) that consists of tweets tagged with sentiment, the author's gender, and whether or not they mention any of the top 10 adverse events reported to the FDA. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. In this tutorial, you will use the tweets' data to build an AutoML-text-sentiment-analysis model on Google Cloud platform."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "objective:automl,training,online_prediction"
},
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML text sentiment analysis model and deploy for online prediction from a Python script using the Vertex SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
"- Create a Vertex `Dataset` resource.\n",
"- Create a training job for the model.\n",
"- View the model evaluation.\n",
"- Deploy the `Model` resource to a serving `Endpoint` resource.\n",
"- Make a prediction.\n",
"- Undeploy the `Model`."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -44,8 +44,8 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_video_action_recognition_batch.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/automl/sdk_automl_video_action_recognition_batch.ipynb\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -61,18 +61,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use the Vertex SDK to create video action recognition models and do batch prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:golf,var"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the golf swing recognition portion of the [Human Motion dataset from MIT](http://cbcl.mit.edu/publications/ps/Kuehne_etal_iccv11.pdf). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. The trained model will predict the start frame where an action of golf swing begins."
"This tutorial demonstrates how to use the Vertex AI SDK to create video action recognition models and do batch prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
@@ -83,7 +72,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML video action recognition model from a Python script, and then do a batch prediction using the Vertex SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to create an AutoML video action recognition model from a Python script, and then do a batch prediction using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -99,6 +88,17 @@
"* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:golf,var"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the golf swing recognition portion of the [Human Motion dataset from MIT](http://cbcl.mit.edu/publications/ps/Kuehne_etal_iccv11.pdf). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. The trained model will predict the start frame where an action of golf swing begins."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -3,7 +3,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "91417fdd",
"metadata": {
"id": "copyright"
},
@@ -26,7 +25,6 @@
},
{
"cell_type": "markdown",
"id": "f2902dac",
"metadata": {
"id": "title"
},
@@ -57,7 +55,6 @@
},
{
"cell_type": "markdown",
"id": "42cfbec0",
"metadata": {
"id": "overview:automl"
},
@@ -70,14 +67,13 @@
},
{
"cell_type": "markdown",
"id": "90b9b726",
"metadata": {
"id": "objective:automl,training,batch_prediction"
},
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML video classification model from a Python script, and then do a batch prediction using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to create an AutoML video classification model from a Python script, and then do a batch prediction using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"This tutorial uses the following Google Cloud ML services and resources:\n",
"\n",
@@ -101,7 +97,6 @@
},
{
"cell_type": "markdown",
"id": "44940826",
"metadata": {
"id": "dataset:hmdb,vcn"
},
@@ -113,7 +108,6 @@
},
{
"cell_type": "markdown",
"id": "7183fc01",
"metadata": {
"id": "costs"
},
@@ -134,7 +128,6 @@
},
{
"cell_type": "markdown",
"id": "b88c255b-df72-4666-9403-0c96d7e657ca",
"metadata": {
"id": "384b53dfdb54"
},
@@ -147,7 +140,6 @@
},
{
"cell_type": "markdown",
"id": "8c1be8fc",
"metadata": {
"id": "setup_local"
},
@@ -185,7 +177,6 @@
},
{
"cell_type": "markdown",
"id": "e131fbee",
"metadata": {
"id": "install_aip:mbsdk"
},
@@ -198,7 +189,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "484dcd52-ef9e-4928-b0f2-7940001bbc2e",
"metadata": {
"id": "2abdd254e90f"
},
@@ -223,7 +213,6 @@
},
{
"cell_type": "markdown",
"id": "aa8cefcd",
"metadata": {
"id": "restart"
},
@@ -236,7 +225,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4f079854",
"metadata": {
"id": "restart"
},
@@ -254,7 +242,6 @@
},
{
"cell_type": "markdown",
"id": "e96a43b8",
"metadata": {
"id": "before_you_begin:nogpu"
},
@@ -285,7 +272,6 @@
},
{
"cell_type": "markdown",
"id": "305e7fa5-dcaf-477a-b20d-d9b69ecba381",
"metadata": {
"id": "1460fd744366"
},
@@ -298,7 +284,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ffd7caab-c2f8-41d3-a0e3-d2519f0bcf2c",
"metadata": {
"id": "cd85f5c794e5"
},
@@ -310,7 +295,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ffb8077b",
"metadata": {
"id": "set_project_id"
},
@@ -326,7 +310,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3c30f77a",
"metadata": {
"id": "set_gcloud_project_id"
},
@@ -337,7 +320,6 @@
},
{
"cell_type": "markdown",
"id": "61221789",
"metadata": {
"id": "region"
},
@@ -359,7 +341,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e05b6148",
"metadata": {
"id": "region"
},
@@ -373,7 +354,6 @@
},
{
"cell_type": "markdown",
"id": "dab6b689",
"metadata": {
"id": "timestamp"
},
@@ -386,7 +366,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6dac7084",
"metadata": {
"id": "timestamp"
},
@@ -406,7 +385,6 @@
},
{
"cell_type": "markdown",
"id": "1bd3f05b-f17f-4341-be85-0bdcef3e6f13",
"metadata": {
"id": "79055ac4078d"
},
@@ -419,7 +397,6 @@
},
{
"cell_type": "markdown",
"id": "c38fbff8",
"metadata": {
"id": "gcp_authenticate"
},
@@ -451,7 +428,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8bae9ca0",
"metadata": {
"id": "gcp_authenticate"
},
@@ -484,7 +460,6 @@
},
{
"cell_type": "markdown",
"id": "bbda1639",
"metadata": {
"id": "bucket:mbsdk"
},
@@ -502,7 +477,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "be69ad8c",
"metadata": {
"id": "bucket"
},
@@ -515,7 +489,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2d0d674c",
"metadata": {
"id": "autoset_bucket"
},
@@ -528,7 +501,6 @@
},
{
"cell_type": "markdown",
"id": "9307a615",
"metadata": {
"id": "create_bucket"
},
@@ -539,7 +511,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "709e7b95",
"metadata": {
"id": "create_bucket"
},
@@ -550,7 +521,6 @@
},
{
"cell_type": "markdown",
"id": "b52bb2e6",
"metadata": {
"id": "validate_bucket"
},
@@ -561,7 +531,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e86c8b22",
"metadata": {
"id": "validate_bucket"
},
@@ -572,7 +541,6 @@
},
{
"cell_type": "markdown",
"id": "cf0222d3",
"metadata": {
"id": "setup_vars"
},
@@ -583,7 +551,6 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "7534d1a5",
"metadata": {
"id": "import_aip:mbsdk"
},
@@ -594,7 +561,6 @@
},
{
"cell_type": "markdown",
"id": "15e5e61a",
"metadata": {
"id": "init_aip:mbsdk"
},
@@ -607,7 +573,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9df9b0b9",
"metadata": {
"id": "init_aip:mbsdk"
},
@@ -618,7 +583,6 @@
},
{
"cell_type": "markdown",
"id": "866ae45f",
"metadata": {
"id": "tutorial_start:automl"
},
@@ -630,7 +594,6 @@
},
{
"cell_type": "markdown",
"id": "0adbd455",
"metadata": {
"id": "import_file:u_dataset,csv"
},
@@ -643,7 +606,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ab42c2d4",
"metadata": {
"id": "import_file:hmdb,csv,vcn"
},
@@ -654,7 +616,6 @@
},
{
"cell_type": "markdown",
"id": "2f7757ea",
"metadata": {
"id": "quick_peek:csv"
},
@@ -669,7 +630,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ea7bac53",
"metadata": {
"id": "quick_peek:csv"
},
@@ -684,7 +644,6 @@
},
{
"cell_type": "markdown",
"id": "aeadee6e",
"metadata": {
"id": "create_dataset:video,vcn"
},
@@ -702,7 +661,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9c55581d",
"metadata": {
"id": "create_dataset:video,vcn"
},
@@ -719,7 +677,6 @@
},
{
"cell_type": "markdown",
"id": "26f09f81",
"metadata": {
"id": "create_automl_pipeline:video,vcn"
},
@@ -742,7 +699,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9f35d88f",
"metadata": {
"id": "create_automl_pipeline:video,vcn"
},
@@ -758,7 +714,6 @@
},
{
"cell_type": "markdown",
"id": "6bbaaf5f",
"metadata": {
"id": "run_automl_pipeline:video"
},
@@ -780,7 +735,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4b3f2c56",
"metadata": {
"id": "run_automl_pipeline:video"
},
@@ -796,7 +750,6 @@
},
{
"cell_type": "markdown",
"id": "6d9e9f29",
"metadata": {
"id": "evaluate_the_model:mbsdk"
},
@@ -812,7 +765,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "59a76fa5",
"metadata": {
"id": "evaluate_the_model:mbsdk"
},
@@ -835,7 +787,6 @@
},
{
"cell_type": "markdown",
"id": "060d3bae",
"metadata": {
"id": "make_prediction"
},
@@ -847,7 +798,6 @@
},
{
"cell_type": "markdown",
"id": "e614b9bf",
"metadata": {
"id": "get_test_items:batch_prediction"
},
@@ -860,7 +810,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bae97d10",
"metadata": {
"id": "get_test_items:automl,vcn,csv"
},
@@ -882,7 +831,6 @@
},
{
"cell_type": "markdown",
"id": "54138ea2",
"metadata": {
"id": "make_batch_file:automl,video"
},
@@ -900,7 +848,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ce7da5dd",
"metadata": {
"id": "make_batch_file:automl,video"
},
@@ -936,7 +883,6 @@
},
{
"cell_type": "markdown",
"id": "5bbefe4a-e05f-4ed7-acf8-a0588757c376",
"metadata": {
"id": "d56366168ec5"
},
@@ -948,7 +894,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a98d1c39-29f2-40c7-8267-91afebb8a440",
"metadata": {
"id": "378131e21a7e"
},
@@ -959,7 +904,6 @@
},
{
"cell_type": "markdown",
"id": "105f3bc5",
"metadata": {
"id": "batch_request:mbsdk"
},
@@ -977,7 +921,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5657e704",
"metadata": {
"id": "batch_request:mbsdk"
},
@@ -995,7 +938,6 @@
},
{
"cell_type": "markdown",
"id": "c86ec9ec",
"metadata": {
"id": "batch_request_wait:mbsdk"
},
@@ -1008,7 +950,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2f108cc8",
"metadata": {
"id": "batch_request_wait:mbsdk"
},
@@ -1019,7 +960,6 @@
},
{
"cell_type": "markdown",
"id": "63e33110",
"metadata": {
"id": "get_batch_prediction:mbsdk,vcn"
},
@@ -1042,7 +982,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a76f3f2c",
"metadata": {
"id": "get_batch_prediction:mbsdk,vcn"
},
@@ -1066,7 +1005,6 @@
},
{
"cell_type": "markdown",
"id": "000413e5",
"metadata": {
"id": "cleanup:mbsdk"
},
@@ -1088,7 +1026,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7761ab4d",
"metadata": {
"id": "cleanup:mbsdk"
},
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK for Python to create video object tracking models and do batch prediction using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:traffic,vot"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Traffic](https://storage.googleapis.com/automl-video-demo-data/traffic_videos/traffic_videos_labels.csv) dataset. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create an AutoML video object tracking model from a Python script, and then do a batch prediction using the Vertex SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to create an AutoML video object tracking model from a Python script, and then do a batch prediction using the Vertex SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -100,6 +89,17 @@
"* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:traffic,vot"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Traffic](https://storage.googleapis.com/automl-video-demo-data/traffic_videos/traffic_videos_labels.csv) dataset. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket."
]
},
{
"cell_type": "markdown",
"metadata": {
+14
View File
@@ -0,0 +1,14 @@
[Online prediction with BigQuery ML](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb)
Learn how to train and deploy a churn prediction model for real-time inference, with the data in BigQuery and model trained using BigQuery ML, registered to Vertex AI Model Registry, and deployed to an endpoint on Vertex AI for online predictions.
The steps performed include:
- Using Python & SQL to query the public data in BigQuery
- Preparing the data for modeling
- Training a classification model using BigQuery ML and registering it to Vertex AI Model Registry
- Inspecting the model on Vertex AI Model Registry
- Deploying the model to an endpoint on Vertex AI
- Making sample online predictions to the model endpoint
@@ -29,21 +29,23 @@
"id": "JAPoU8Sm5E6e"
},
"source": [
"# Online prediction with BigQuery ML\n",
"\n",
"<table align=\"left\">\n",
"\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/bigquery_ml/bqml-online-prediction.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -54,20 +56,23 @@
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
"id": "cfc112ddad4c"
},
"source": [
"## Overview\n",
"\n",
"This notebook is aimed at data analysts and data scientists who have data in BigQuery, want to train a model using BigQuery ML, register the model to Vertex AI Model Registry, and deploy it to an endpoint for real-time prediction. \n",
"\n",
"### Dataset\n",
"\n",
"The dataset, <a href=\"https://console.cloud.google.com/bigquery?project=bigquery-public-data&d=ga4_obfuscated_sample_ecommerce&p=bigquery-public-data&page=dataset\" target=\"_blank\">available publicly on BigQuery</a>, comes from obfuscated <a href=\"https://support.google.com/analytics/answer/10937659\" target=\"_blank\">Google Analytics 4 data</a> from the <a href=\"https://shop.googlemerchandisestore.com/\" target=\"_blank\">Google Merchandise Store</a>).\n",
"\n",
"This notebook is aimed at data analysts and data scientists who have data in BigQuery, want to train a model using BigQuery ML, register the model to Vertex AI Model Registry, and deploy it to an endpoint for real-time prediction. "
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
},
"source": [
"### Objective\n",
"\n",
"In this tutorial, you will learn how to train and deploy a churn prediction model for real-time inference, with the data in BigQuery and model trained using BigQuery ML, registered to Vertex AI Model Registry, and deployed to an endpoint on Vertex AI for online predictions.\n",
"In this tutorial, you learn how to train and deploy a churn prediction model for real-time inference, with the data in BigQuery and model trained using BigQuery ML, registered to Vertex AI Model Registry, and deployed to an endpoint on Vertex AI for online predictions.\n",
"\n",
"This tutorial uses the following Google Cloud data analytics and ML services:\n",
"\n",
@@ -84,8 +89,26 @@
"- Training a classification model using BigQuery ML and registering it to Vertex AI Model Registry\n",
"- Inspecting the model on Vertex AI Model Registry\n",
"- Deploying the model to an endpoint on Vertex AI\n",
"- Making sample online predictions to the model endpoint\n",
"- Making sample online predictions to the model endpoint\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c640527e06e6"
},
"source": [
"### Dataset\n",
"\n",
"The dataset, <a href=\"https://console.cloud.google.com/bigquery?project=bigquery-public-data&d=ga4_obfuscated_sample_ecommerce&p=bigquery-public-data&page=dataset\" target=\"_blank\">available publicly on BigQuery</a>, comes from obfuscated <a href=\"https://support.google.com/analytics/answer/10937659\" target=\"_blank\">Google Analytics 4 data</a> from the <a href=\"https://shop.googlemerchandisestore.com/\" target=\"_blank\">Google Merchandise Store</a>)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ff6017ac879f"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
+59
View File
@@ -0,0 +1,59 @@
[Custom training and batch prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-batch.ipynb)
Learn to use `Vertex AI Training` to create a custom trained model and use `Vertex AI Batch Prediction` to do a batch prediction on the trained model.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- Upload the trained model artifacts as a `Model` resource.
- Make a batch prediction.
[Profile model training performance using Profiler](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/custom_training_tensorboard_profiler.ipynb)
Learn how to enable Vertex AI TensorBoard Profiler for custom training jobs.
The steps performed include:
- Setup a service account and a Cloud Storage bucket
- Create a TensorBoard instance
- Create and run a custom training job
- View the TensorBoard Profiler dashboard
[Training a TensorFlow model on BigQuery data](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/custom-tabular-bq-managed-dataset.ipynb)
Learn how to create a custom-trained model from a Python script in a Docker container using the Vertex AI SDK for Python, and then get a prediction from the deployed model by sending data.
The steps performed include:
- Create a Vertex AI custom `TrainingPipeline` for training a model.
- Train a TensorFlow model.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model` resource.
[Custom training and online prediction](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/sdk-custom-image-classification-online.ipynb)
Learn to use `Vertex AI Training` to create a custom-trained model from a Python script in a Docker container, and learn to use `Vertex AI Prediction` to do a prediction on the deployed model by sending data.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- Upload the trained model artifacts to a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model` resource.
[Deploying Iris-detection model using FastAPI and Vertex AI custom container serving](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/SDK_Custom_Container_Prediction.ipynb)
Learn how to create, deploy and serve a custom classification model on Vertex AI.
The steps performed include:
- Train a model that uses flower's measurements as input to predict the class of iris.
- Save the model and its serialized pre-processor.
- Build a FastAPI server to handle predictions and health checks.
- Build a custom container with model artifacts.
- Upload and deploy custom container to Vertex AI Endpoints.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -45,7 +45,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/custom/custom_training_tensorboard_profiler.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/custom/custom_training_tensorboard_profiler.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -64,17 +64,6 @@
"This tutorial demonstrates how to enable Vertex AI TensorBoard Profiler so you can debug model training performance for your custom training jobs.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zfXf0r-K81Y-"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [mnist dataset](https://www.tensorflow.org/datasets/catalog/mnist) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview).\n"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -98,6 +87,17 @@
"- View the TensorBoard Profiler dashboard\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zfXf0r-K81Y-"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [mnist dataset](https://www.tensorflow.org/datasets/catalog/mnist) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview).\n"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/official/automl/automl-text-classification.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/custom/sdk-custom-image-classification-batch.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
+23
View File
@@ -0,0 +1,23 @@
[Compare pipeline runs with Vertex AI Experiments](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/comparing_pipeline_runs.ipynb)
Learn how to use `Vertex AI Experiments` to log a pipeline job and compare different pipeline jobs.
[Track parameters and metrics for locally trained models](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/comparing_local_trained_models.ipynb)
Learn how to use Vertex AI Experiments to compare and evaluate model experiments.
The steps performed include:
- log the model parameters
- log the loss and metrics on every epoch to TensorBoard
- log the evaluation metrics
[Build Vertex AI Experiment lineage for custom training](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/experiments/build_model_experimentation_lineage_with_prebuild_code.ipynb)
Learn how to integrate preprocessing code in a Vertex AI experiments.
@@ -689,6 +689,7 @@
"# Training\n",
"TRAIN_EXECUTION_NAME = \"train\"\n",
"TARGET = \"category\"\n",
"TARGET_LABELS = [\"b\", \"t\", \"e\", \"m\"]\n",
"FEATURES = \"title\"\n",
"TEST_SIZE = 0.2\n",
"SEED = 8\n",
@@ -974,7 +975,8 @@
"import joblib\n",
"import pandas as pd\n",
"from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer\n",
"from sklearn.metrics import accuracy_score, precision_score, recall_score\n",
"from sklearn.metrics import (accuracy_score, confusion_matrix, precision_score,\n",
" recall_score)\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.naive_bayes import MultinomialNB\n",
"from sklearn.pipeline import Pipeline\n",
@@ -1049,13 +1051,17 @@
" y_pred = model.predict(X_test)\n",
"\n",
" # Store evaluation metrics\n",
" # Store evaluation metrics\n",
" metrics = {\n",
" summary_metrics = {\n",
" \"accuracy\": round(accuracy_score(y_test, y_pred), 5),\n",
" \"precision\": round(precision_score(y_test, y_pred, average=\"weighted\"), 5),\n",
" \"recall\": round(recall_score(y_test, y_pred, average=\"weighted\"), 5),\n",
" }\n",
" return metrics\n",
" classification_metrics = {\n",
" \"matrix\": confusion_matrix(y_test, y_pred, labels=TARGET_LABELS).tolist(),\n",
" \"labels\": TARGET_LABELS,\n",
" }\n",
"\n",
" return summary_metrics, classification_metrics\n",
"\n",
"\n",
"def save_model(model: Pipeline, save_path: str) -> int:\n",
@@ -1138,13 +1144,20 @@
"\n",
" # Evaluate model\n",
" logging.info(\"Evaluate model.\")\n",
" model_metrics = evaluate_model(trained_pipeline, x_val, y_val)\n",
" summary_metrics, classification_metrics = evaluate_model(\n",
" trained_pipeline, x_val, y_val\n",
" )\n",
"\n",
" # Log training metrics and store model artifact ----------------------------\n",
"\n",
" # Log training metrics\n",
" logging.info(\"Log training metrics.\")\n",
" vertex_ai.log_metrics(model_metrics)\n",
" vertex_ai.log_metrics(summary_metrics)\n",
" vertex_ai.log_classification_metrics(\n",
" labels=classification_metrics[\"labels\"],\n",
" matrix=classification_metrics[\"matrix\"],\n",
" display_name=\"my-confusion-matrix\",\n",
" )\n",
"\n",
" # Generate first ten predictions\n",
" logging.info(\"Generate prediction sample.\")\n",
@@ -72,10 +72,7 @@
"source": [
"### Objective\n",
"\n",
"In this notebook, you will learn how to use Vertex AI Experiments to \n",
"\n",
"* Log Pipeline Job\n",
"* Compare different Pipeline Jobs\n",
"In this notebook, you learn how to use `Vertex AI Experiments` to log a pipeline job and compare different pipeline jobs.\n",
"\n",
"The steps covered include:\n",
"\n",
@@ -0,0 +1,85 @@
[Custom training tabular regression model for batch prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_tabular_regression_batch_explain.ipynb)
Learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Make a batch prediction with explanations.
[AutoML training tabular binary classification model for batch explanation](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_binary_classification_batch_explain.ipynb)
Learn to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Batch Prediction` to make predictions with explanations.
The steps performed include:
- Create a `Vertex Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Make a batch prediction request with explainability.
* Prediction Service: Does an on-demand prediction for the entire set of instances (i.e., one or more data items) and returns the results in real-time.
* Batch Prediction Service: Does a queued (batch) prediction for the entire set of instances in the background and stores the results in a Cloud Storage bucket when ready.
[AutoML training tabular classification model for online explanation](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_automl_tabular_classification_online_explain.ipynb)
Learn how to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Online Prediction` to make online predictions with explanations.
The steps performed include:
- Create a `Vertex Dataset` resource.
- Train an `AutoML` tabular binary classification model.
- View the model evaluation metrics for the trained model.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make an online prediction request with explainability.
- Undeploy the `Model` resource.
[Custom training image classification model for online prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_online_explain.ipynb)
Learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanations as a `Model` resource.
- Create a serving `Endpoint` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction with explanation.
- Undeploy the `Model` resource.
[Custom training tabular regression model for online prediction with explainabilty using get_metadata](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_tabular_regression_online_explain_get_metadata.ipynb)
Learn how to create a custom model from a Python script in a Google prebuilt Docker container using the Vertex SDK, and then do a prediction with explanations on the deployed model by sending data.
The steps performed include:
- Create a Vertex custom job for training a model.
- Train a TensorFlow model.
- Retrieve and load the model artifacts.
- View the model evaluation.
- Set explanation parameters.
- Upload the model as a Vertex `Model` resource.
- Deploy the `Model` resource to a serving `Endpoint` resource.
- Make a prediction with explanation.
- Undeploy the `Model` resource.
[Custom training image classification model for batch prediction with explainabilty](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/explainable_ai/sdk_custom_image_classification_batch_explain.ipynb)
Learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations.
The steps performed include:
- Create a `Vertex AI` custom job for training a TensorFlow model.
- View the model evaluation for the trained model.
- Set explanation parameters for when the model is deployed.
- Upload the trained model artifacts and explanation parameters as a `Model` resource.
- Make a batch prediction with explanations.
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK to create tabular classification models and do online prediction with explanation using a Google Cloud [AutoML](https://cloud.google.com/vertex-ai/docs/start/automl-users) model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:iris,lcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Iris dataset](https://www.tensorflow.org/datasets/catalog/iris) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). This dataset does not require any feature engineering. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of Iris flower species from a class of three species: setosa, virginica, or versicolor."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Online Prediction` to make online predictions with explanations. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"In this tutorial, you learn how to use `AutoML` to create a tabular binary classification model from a Python script, and then learn to use `Vertex AI Online Prediction` to make online predictions with explanations. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -105,6 +94,17 @@
"- Undeploy the `Model` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:iris,lcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Iris dataset](https://www.tensorflow.org/datasets/catalog/iris) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). This dataset does not require any feature engineering. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of Iris flower species from a class of three species: setosa, virginica, or versicolor."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK to train and deploy a custom image classification model for online prediction with explanation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,cifar10,icn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [CIFAR10 dataset](https://www.tensorflow.org/datasets/catalog/cifar10) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). The version of the dataset you will use is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"In this tutorial, you learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -106,6 +95,17 @@
"- Undeploy the `Model` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,cifar10,icn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [CIFAR10 dataset](https://www.tensorflow.org/datasets/catalog/cifar10) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). The version of the dataset you will use is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK to train and deploy a custom tabular regression model for batch prediction with explanation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"In this tutorial, you learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Batch Prediction` to make a batch prediction request with explanations. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -103,6 +92,17 @@
"- Make a batch prediction with explanations."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -188,9 +188,9 @@
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install {USER_FLAG} --upgrade google-cloud-storage -q\n",
"! pip3 install --upgrade tensorflow $USER_FLAG -q"
"! pip3 install --upgrade --quiet {USER_FLAG} google-cloud-aiplatform \\\n",
" google-cloud-storage \\\n",
" tensorflow==2.5"
]
},
{
@@ -317,7 +317,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -326,9 +329,9 @@
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
@@ -339,9 +342,16 @@
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import random\n",
"import string\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
"\n",
"# Generate a uuid of length 8\n",
"def generate_uuid():\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=8))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
@@ -353,7 +363,7 @@
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Workbench AI Notebooks**, your environment is already\n",
"authenticated. Skip this step.\n",
"authenticated. \n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions\n",
"when prompted to authenticate your account via oAuth.\n",
@@ -448,7 +458,7 @@
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
@@ -948,7 +958,7 @@
"outputs": [],
"source": [
"job = aip.CustomTrainingJob(\n",
" display_name=\"boston_\" + TIMESTAMP,\n",
" display_name=\"boston_\" + UUID,\n",
" script_path=\"custom/trainer/task.py\",\n",
" container_uri=TRAIN_IMAGE,\n",
" requirements=[\"gcsfs==0.7.1\", \"tensorflow-datasets==4.4\"],\n",
@@ -983,7 +993,7 @@
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, UUID)\n",
"\n",
"EPOCHS = 20\n",
"STEPS = 100\n",
@@ -1404,7 +1414,7 @@
"outputs": [],
"source": [
"model = aip.Model.upload(\n",
" display_name=\"boston_\" + TIMESTAMP,\n",
" display_name=\"boston_\" + UUID,\n",
" artifact_uri=MODEL_DIR,\n",
" serving_container_image_uri=DEPLOY_IMAGE,\n",
" explanation_parameters=parameters,\n",
@@ -1434,7 +1444,7 @@
"source": [
"### Make test items\n",
"\n",
"You will use synthetic data as a test data items. Don't be concerned that we are using synthetic data -- we just want to demonstrate how to make a prediction."
"You use a portion of the preprocessed evaluation data (x_test) for your batch request."
]
},
{
@@ -1460,14 +1470,16 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "make_batch_file:automl,tabular,alt"
"id": "622926573681"
},
"outputs": [],
"source": [
"! gsutil cat $IMPORT_FILE | head -n 1 > tmp.csv\n",
"! gsutil cat $IMPORT_FILE | tail -n 10 >> tmp.csv\n",
"\n",
"! cut -d, -f1-16 tmp.csv > batch.csv\n",
"with open(\"batch.csv\", \"w\") as f:\n",
" f.write(\"crim, zn, indus, chas, nox, rm, age, dis, rad, tax, ptratio, b, lstat\\n\")\n",
" f.write(str(x_test[0].tolist()).replace(\"[\", \"\").replace(\"]\", \"\"))\n",
" f.write(\"\\n\")\n",
" f.write(str(x_test[1].tolist()))\n",
" f.write(\"\\n\")\n",
"\n",
"gcs_input_uri = BUCKET_URI + \"/test.csv\"\n",
"\n",
@@ -1505,7 +1517,7 @@
"MAX_NODES = 1\n",
"\n",
"batch_predict_job = model.batch_predict(\n",
" job_display_name=\"boston_\" + TIMESTAMP,\n",
" job_display_name=\"boston_\" + UUID,\n",
" gcs_source=gcs_input_uri,\n",
" gcs_destination_prefix=BUCKET_URI,\n",
" instances_format=\"csv\",\n",
@@ -1539,8 +1551,7 @@
},
"outputs": [],
"source": [
"if not os.getenv(\"IS_TESTING\"):\n",
" batch_predict_job.wait()"
"batch_predict_job.wait()"
]
},
{
@@ -1567,22 +1578,19 @@
},
"outputs": [],
"source": [
"if not os.getenv(\"IS_TESTING\"):\n",
" import tensorflow as tf\n",
"bp_iter_outputs = batch_predict_job.iter_outputs()\n",
"\n",
" bp_iter_outputs = batch_predict_job.iter_outputs()\n",
"explanation_results = list()\n",
"for blob in bp_iter_outputs:\n",
" if blob.name.split(\"/\")[-1].startswith(\"explanation\"):\n",
" explanation_results.append(blob.name)\n",
"\n",
" explanation_results = list()\n",
" for blob in bp_iter_outputs:\n",
" if blob.name.split(\"/\")[-1].startswith(\"explanation\"):\n",
" explanation_results.append(blob.name)\n",
"\n",
" tags = list()\n",
" for explanation_result in explanation_results:\n",
" gfile_name = f\"gs://{bp_iter_outputs.bucket.name}/{explanation_result}\"\n",
" with tf.io.gfile.GFile(name=gfile_name, mode=\"r\") as gfile:\n",
" for line in gfile.readlines():\n",
" print(line)"
"tags = list()\n",
"for explanation_result in explanation_results:\n",
" gfile_name = f\"gs://{bp_iter_outputs.bucket.name}/{explanation_result}\"\n",
" with tf.io.gfile.GFile(name=gfile_name, mode=\"r\") as gfile:\n",
" for line in gfile.readlines():\n",
" print(line)"
]
},
{
@@ -1616,7 +1624,9 @@
" print(e)\n",
"\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
" ! gsutil rm -r $BUCKET_URI\n",
"\n",
"! rm -rf batch.csv custom.tar.gz custom"
]
}
],
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex AI SDK to train and deploy a custom tabular regression model for online prediction with explanation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"In this tutorial, you learn how to use `Vertex AI Training and Explainable AI` to create a custom image classification model with explanations, and then you learn to use `Vertex AI Prediction` to make an online prediction request with explanations. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -106,6 +95,17 @@
"- Undeploy the `Model` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -65,17 +65,6 @@
"This tutorial demonstrates how to use the Vertex SDK to train and deploy a custom tabular regression model for online prediction with explanation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you create a custom model from a Python script in a Google prebuilt Docker container using the Vertex SDK, and then do a prediction with explanations on the deployed model by sending data. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"In this tutorial, you learn how to create a custom model from a Python script in a Google prebuilt Docker container using the Vertex SDK, and then do a prediction with explanations on the deployed model by sending data. You can alternatively create custom models using `gcloud` command-line tool or online using Cloud Console.\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -99,6 +88,17 @@
"- Undeploy the `Model` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -0,0 +1,25 @@
[Using Vertex AI Feature Store with pandas DataFrame](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/sdk-feature-store-pandas.ipynb)
Learn how to use `Vertex AI Feature Store` with pandas DataFrame.
The steps performed include:
- Ingest Feature values from Pandas DataFrame into Feature Store's Entity types.
- Read Entity Feature values from Online Feature Store into Pandas DataFrame.
- Batch serve Feature values from your Feature Store into Pandas DataFrame.
- Online serving with updated feature values.
- Point-in-time correctness to fetch feature values for training.
[Online and Batch predictions using Vertex AI Feature Store](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/sdk-feature-store.ipynb)
Learn how to use `Vertex AI Feature Store` to import feature data, and to access the feature data for both online serving and offline tasks, such as training.
The steps performed include:
- Create featurestore, entity type, and feature resources.
- Import feature data into `Vertex AI Feature Store` resource.
- Serve online prediction requests using the imported features.
- Access imported features in offline jobs, such as training jobs.
@@ -29,6 +29,8 @@
"id": "JAPoU8Sm5E6e"
},
"source": [
"# Using Vertex AI Feature Store with pandas DataFrame\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/sdk-feature-store-pandas.ipynb\">\n",
@@ -44,7 +46,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/sdk-feature-store-pandas.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/feature_store/sdk-feature-store-pandas.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -63,17 +65,6 @@
"This notebook introduces Pandas support for Feature Store using Vertex AI SDK. For pre-requisites and introduction on Vertex AI SDK and Feature Store native support, please go through this [Colab notebook](https://colab.sandbox.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/feature_store/sdk-feature-store.ipynb). "
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c4ZNLaf6T0lN"
},
"source": [
"### Dataset\n",
"\n",
"This tutorial uses a movie recommendation dataset as an example throughout all the notebooks including this one. The original task is to train a model to predict if a user is going to watch a movie and serve the model online."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -82,7 +73,9 @@
"source": [
"### Objective\n",
"\n",
"In this notebook, you learn how to:\n",
"In this notebook, you learn how to use `Vertex AI Feature Store` with pandas DataFrame.\n",
"\n",
"The steps performed include:\n",
"\n",
"- Ingest Feature values from Pandas DataFrame into Feature Store's Entity types.\n",
"- Read Entity Feature values from Online Feature Store into Pandas DataFrame.\n",
@@ -94,6 +87,17 @@
"- Point-in-time correctness to fetch feature values for training."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c4ZNLaf6T0lN"
},
"source": [
"### Dataset\n",
"\n",
"This tutorial uses a movie recommendation dataset as an example throughout all the notebooks including this one. The original task is to train a model to predict if a user is going to watch a movie and serve the model online."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/feature_store/sdk-feature-store.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/feature_store/sdk-feature-store.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a> \n",
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this notebook, you will learn how to use `Vertex AI Feature Store` to import feature data, and to access the feature data for both online serving and offline tasks, such as training.\n",
"In this notebook, you learn how to use `Vertex AI Feature Store` to import feature data, and to access the feature data for both online serving and offline tasks, such as training.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -0,0 +1,39 @@
[Create Vertex AI Matching Engine index](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb)
Learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes, and validate the performance of the index.
The steps performed include:
* Create ANN Index and Brute Force Index
* Create an IndexEndpoint with VPC Network
* Deploy ANN Index and Brute Force Index
* Perform online query
* Compute recall
[Introduction to builtin Swivel embedding algorithm](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/intro-swivel.ipynb)
Learn how to train custom embeddings using Vertex AI Pipelines and deploy the model for serving.
The steps performed include:
1. **Setup**: Importing the required libraries and setting your global variables.
2. **Configure parameters**: Setting the appropriate parameter values for the pipeline job.
3. **Train on Vertex AI Pipelines**: Create a Swivel job to Vertex Pipelines using pipeline template.
4. **Deploy on Vertex AI Prediction**: Importing and deploying the trained model to a callable endpoint.
5. **Predict**: Calling the deployed endpoint using online prediction.
6. **Cleaning up**: Deleting resources created by this tutorial.
[Introduction to builtin Two-towers embedding algorithm](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/two-tower-model-introduction.ipynb)
Learn how to run the two-tower model.
The steps performed include:
1. **Setup**: Importing the required libraries and setting your global variables.
2. **Configure parameters**: Setting the appropriate parameter values for the training job.
3. **Train on Vertex AI Training**: Submitting a training job.
4. **Deploy on Vertex AI Prediction**: Importing and deploying the trained model to a callable endpoint.
5. **Predict**: Calling the deployed endpoint using online or batch prediction.
6. **Hyperparameter tuning**: Running a hyperparameter tuning job.
7. **Cleaning up**: Deleting resources created by this tutorial.
@@ -29,26 +29,33 @@
"id": "JAPoU8Sm5E6e"
},
"source": [
"<table align=\"left\">\n",
"# Introduction to builtin Swivel embedding algorithm\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/matching_engine/intro-swivel.ipynb\"\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/intro-swivel.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/matching_engine/intro-swivel.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/intro-swivel.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/matching_engine/intro-swivel.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
"id": "0f2a285ac113"
},
"source": [
"## Overview\n",
@@ -61,26 +68,49 @@
"\n",
"It will require you provide a bucket where the dataset will be stored.\n",
"\n",
"Note: you may incur charges for training, storage or usage of other GCP products (Dataflow) in connection with testing this SDK.\n",
"Note: you may incur charges for training, storage or usage of other GCP products (Dataflow) in connection with testing this SDK.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
},
"source": [
"### Objective\n",
"\n",
"In this notebook, you learn how to train custom embeddings using Vertex AI Pipelines and deploy the model for serving. \n",
"\n",
"The steps performed include:\n",
"\n",
"1. **Setup**: Importing the required libraries and setting your global variables.\n",
"2. **Configure parameters**: Setting the appropriate parameter values for the pipeline job.\n",
"3. **Train on Vertex AI Pipelines**: Create a Swivel job to Vertex Pipelines using pipeline template.\n",
"4. **Deploy on Vertex AI Prediction**: Importing and deploying the trained model to a callable endpoint.\n",
"5. **Predict**: Calling the deployed endpoint using online prediction.\n",
"6. **Cleaning up**: Deleting resources created by this tutorial."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "fdba765f512d"
},
"source": [
"### Dataset\n",
"\n",
"You will use the following sample datasets in the public bucket **gs://cloud-samples-data/vertex-ai/matching-engine/swivel**:\n",
"\n",
"1. **movielens_25m**: A [movie rating dataset](https://grouplens.org/datasets/movielens/25m/) for the items input type that you can use to create embeddings for movies. This dataset is processed so that each line contains the movies that have same rating by the same user. The directory also includes `movies.csv`, which maps the movie ids to their names.\n",
"2. **wikipedia**: A text corpus dataset created from a [Wikipedia dump](https://dumps.wikimedia.org/enwiki/) that you can use to create word embeddings.\n",
"\n",
"### Objective\n",
"\n",
"In this notebook, you will learn how to train custom embeddings using Vertex Pipelines and deploy the model for serving. The steps performed include:\n",
"\n",
"1. **Setup**: Importing the required libraries and setting your global variables.\n",
"2. **Configure parameters**: Setting the appropriate parameter values for the pipeline job.\n",
"3. **Train on Vertex Pipelines**: Create a Swivel job to Vertex Pipelines using pipeline template.\n",
"4. **Deploy on Vertex Prediction**: Importing and deploying the trained model to a callable endpoint.\n",
"5. **Predict**: Calling the deployed endpoint using online prediction.\n",
"6. **Cleaning up**: Deleting resources created by this tutorial.\n",
"\n",
"2. **wikipedia**: A text corpus dataset created from a [Wikipedia dump](https://dumps.wikimedia.org/enwiki/) that you can use to create word embeddings."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f0c48754d30e"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
@@ -71,7 +71,7 @@
"source": [
"### Objective\n",
"\n",
"In this notebook, you will learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes, and validate the performance of the index. \n",
"In this notebook, you learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes, and validate the performance of the index. \n",
"\n",
"The steps performed include:\n",
"\n",
@@ -29,51 +29,79 @@
"id": "JAPoU8Sm5E6e"
},
"source": [
"<table align=\"left\">\n",
"# Introduction to builtin Two-towers embedding algorithm\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/master/notebooks/official/matching_engine/two-tower-model-introduction.ipynb\"\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/two-tower-model-introduction.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/master/notebooks/official/matching_engine/two-tower-model-introduction.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/matching_engine/two-tower-model-introduction.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/official/matching_engine/two-tower-model-introduction.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
"id": "2b352e8fb437"
},
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use the Two-Tower built-in algorithm on the Vertex AI platform.\n",
"\n",
"Two-tower models learn to represent two items of various types (such as user profiles, search queries, web documents, answer passages, or images) in the same vector space, so that similar or related items are close to each other. These two items are referred to as the query and candidate object, since when paired with a nearest neighbor search service such as Vertex Matching Engine, the two-tower model can retrieve candidate objects related to an input query object. These objects are encoded by a query and candidate encoder (the two \"towers\") respectively, which are trained on pairs of relevant items. This built-in algorithm exports trained query and candidate encoders as model artifacts, which can be deployed in Vertex Prediction for usage in a recommendation system.\n",
"\n",
"### Dataset\n",
"\n",
"This tutorial uses the `movielens_100k sample dataset` in the public bucket `gs://cloud-samples-data/vertex-ai/matching-engine/two-tower`, which was generated from the [MovieLens movie rating dataset](https://grouplens.org/datasets/movielens/100k/). For simplicity, the data for this tutorial only includes the user id feature for users, and the movie id and movie title features for movies. In this example, the user is the query object and the movie is the candidate object, and each training example in the dataset contains a user and a movie they rated (we only include positive ratings in the dataset). The two-tower model will embed the user and the movie in the same embedding space, so that given a user, the model will recommend movies it thinks the user will like.\n",
"\n",
"Two-tower models learn to represent two items of various types (such as user profiles, search queries, web documents, answer passages, or images) in the same vector space, so that similar or related items are close to each other. These two items are referred to as the query and candidate object, since when paired with a nearest neighbor search service such as Vertex Matching Engine, the two-tower model can retrieve candidate objects related to an input query object. These objects are encoded by a query and candidate encoder (the two \"towers\") respectively, which are trained on pairs of relevant items. This built-in algorithm exports trained query and candidate encoders as model artifacts, which can be deployed in Vertex Prediction for usage in a recommendation system.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tvgnzT1CKxrO"
},
"source": [
"### Objective\n",
"\n",
"In this notebook, you will learn how to run the two-tower model.\n",
"The tutorial covers the following steps:\n",
"In this notebook, you learn how to run the two-tower model.\n",
"\n",
"The steps performed include:\n",
"1. **Setup**: Importing the required libraries and setting your global variables.\n",
"2. **Configure parameters**: Setting the appropriate parameter values for the training job.\n",
"3. **Train on Vertex Training**: Submitting a training job.\n",
"4. **Deploy on Vertex Prediction**: Importing and deploying the trained model to a callable endpoint.\n",
"3. **Train on Vertex AI Training**: Submitting a training job.\n",
"4. **Deploy on Vertex AI Prediction**: Importing and deploying the trained model to a callable endpoint.\n",
"5. **Predict**: Calling the deployed endpoint using online or batch prediction.\n",
"6. **Hyperparameter tuning**: Running a hyperparameter tuning job.\n",
"7. **Cleaning up**: Deleting resources created by this tutorial.\n",
"\n",
"7. **Cleaning up**: Deleting resources created by this tutorial."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "812ec4e27d66"
},
"source": [
"### Dataset\n",
"\n",
"This tutorial uses the `movielens_100k sample dataset` in the public bucket `gs://cloud-samples-data/vertex-ai/matching-engine/two-tower`, which was generated from the [MovieLens movie rating dataset](https://grouplens.org/datasets/movielens/100k/). For simplicity, the data for this tutorial only includes the user id feature for users, and the movie id and movie title features for movies. In this example, the user is the query object and the movie is the candidate object, and each training example in the dataset contains a user and a movie they rated (we only include positive ratings in the dataset). The two-tower model will embed the user and the movie in the same embedding space, so that given a user, the model will recommend movies it thinks the user will like."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0c997d8d92ce"
},
"source": [
"### Costs \n",
"\n",
"\n",
@@ -32,17 +32,24 @@
"# Vertex AI: Vertex AI Migration: AutoML Image Classification\n",
"\n",
"<table align=\"left\">\n",
"\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/ai-platform-samples/blob/master/vertex-ai-samples/tree/master/notebooks/official/migration/UJ1%20Vertex%20SDK%20AutoML%20Image%20Classification.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ1 Vertex SDK AutoML Image Classification.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/ai-platform-samples/blob/master/vertex-ai-samples/tree/master/notebooks/official/migration/UJ1%20Vertex%20SDK%20AutoML%20Image%20Classification.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ1 Vertex SDK AutoML Image Classification.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ1 Vertex SDK AutoML Image Classification.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td> \n",
"</table>\n",
"<br/><br/><br/>"
]
@@ -55,7 +62,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Flowers dataset](https://www.tensorflow.org/datasets/catalog/tf_flowers) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of flower an image is from a class of five flowers: daisy, dandelion, rose, sunflower, or tulip."
"The dataset used for this tutorial is the [Flowers dataset](https://www.tensorflow.org/datasets/catalog/tf_flowers) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). The version of the dataset you use in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of flower an image is from a class of five flowers: daisy, dandelion, rose, sunflower, or tulip."
]
},
{
@@ -119,7 +126,7 @@
"source": [
"## Installation\n",
"\n",
"Install the latest version of Vertex SDK for Python."
"Install the packages required for executing this notebook."
]
},
{
@@ -138,39 +145,7 @@
"else:\n",
" USER_FLAG = \"\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "install_storage"
},
"source": [
"Install the latest GA version of *google-cloud-storage* library as well."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_storage"
},
"outputs": [],
"source": [
"! pip3 install -U google-cloud-storage $USER_FLAG"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_tensorflow"
},
"outputs": [],
"source": [
"if os.getenv(\"IS_TESTING\"):\n",
" ! pip3 install --upgrade tensorflow $USER_FLAG"
"! pip3 install --upgrade google-cloud-aiplatform google-cloud-storage tensorflow $USER_FLAG -q"
]
},
{
@@ -224,7 +199,7 @@
"\n",
"3. [Enable the following APIs: Vertex AI APIs, Compute Engine APIs, and Cloud Storage.](https://console.cloud.google.com/flows/enableapi?apiid=ml.googleapis.com,compute_component,storage-component.googleapis.com)\n",
"\n",
"4. If you are running this notebook locally, you will need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"4. If you are running this notebook locally, you need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"\n",
"5. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
@@ -297,7 +272,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -306,9 +284,9 @@
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
@@ -319,9 +297,16 @@
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import random\n",
"import string\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
@@ -332,7 +317,7 @@
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Google Cloud Notebooks**, your environment is already authenticated. Skip this step.\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
@@ -367,8 +352,11 @@
"import os\n",
"import sys\n",
"\n",
"# If on Google Cloud Notebook, then don't execute this code\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\"):\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
@@ -378,7 +366,7 @@
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
" %env GOOGLE_APPLICATION_CREDENTIALS '[your-service-account-key-path]'"
]
},
{
@@ -391,7 +379,7 @@
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you initialize the Vertex SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"When you initialize the Vertex AI SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
@@ -404,7 +392,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -415,8 +404,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -436,7 +426,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URI"
]
},
{
@@ -456,7 +446,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -488,9 +478,9 @@
"id": "init_aip:mbsdk"
},
"source": [
"## Initialize Vertex SDK for Python\n",
"## Initialize Vertex AI SDK for Python\n",
"\n",
"Initialize the Vertex SDK for Python for your project and corresponding bucket."
"Initialize the Vertex AI SDK for Python for your project and corresponding bucket."
]
},
{
@@ -501,7 +491,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -605,7 +595,7 @@
"outputs": [],
"source": [
"dataset = aip.ImageDataset.create(\n",
" display_name=\"Flowers\" + \"_\" + TIMESTAMP,\n",
" display_name=\"Flowers\" + \"_\" + UUID,\n",
" gcs_source=[IMPORT_FILE],\n",
" import_schema_uri=aip.schema.dataset.ioformat.image.single_label_classification,\n",
")\n",
@@ -690,7 +680,7 @@
"outputs": [],
"source": [
"dag = aip.AutoMLImageTrainingJob(\n",
" display_name=\"flowers_\" + TIMESTAMP,\n",
" display_name=\"flowers_\" + UUID,\n",
" prediction_type=\"classification\",\n",
" multi_label=False,\n",
" model_type=\"CLOUD\",\n",
@@ -731,7 +721,7 @@
"\n",
"The `run` method when completed returns the `Model` resource.\n",
"\n",
"The execution of the training pipeline will take upto 20 minutes."
"The execution of the training pipeline take upto 20 minutes."
]
},
{
@@ -744,7 +734,7 @@
"source": [
"model = dag.run(\n",
" dataset=dataset,\n",
" model_display_name=\"flowers_\" + TIMESTAMP,\n",
" model_display_name=\"flowers_\" + UUID,\n",
" training_fraction_split=0.8,\n",
" validation_fraction_split=0.1,\n",
" test_fraction_split=0.1,\n",
@@ -817,7 +807,7 @@
"outputs": [],
"source": [
"# Get model resource ID\n",
"models = aip.Model.list(filter=\"display_name=flowers_\" + TIMESTAMP)\n",
"models = aip.Model.list(filter=\"display_name=flowers_\" + UUID)\n",
"\n",
"# Get a reference to the Model Service client\n",
"client_options = {\"api_endpoint\": f\"{REGION}-aiplatform.googleapis.com\"}\n",
@@ -896,7 +886,7 @@
"source": [
"### Get test item(s)\n",
"\n",
"Now do a batch prediction to your Vertex model. You will use arbitrary examples out of the dataset as a test items. Don't be concerned that the examples were likely used in training the model -- we just want to demonstrate how to make a prediction."
"Now do a batch prediction to your Vertex model. You use arbitrary examples out of the dataset as a test items. Don't be concerned that the examples were likely used in training the model -- we just want to demonstrate how to make a prediction."
]
},
{
@@ -941,11 +931,11 @@
"file_1 = test_item_1.split(\"/\")[-1]\n",
"file_2 = test_item_2.split(\"/\")[-1]\n",
"\n",
"! gsutil cp $test_item_1 $BUCKET_NAME/$file_1\n",
"! gsutil cp $test_item_2 $BUCKET_NAME/$file_2\n",
"! gsutil cp $test_item_1 $BUCKET_URI/$file_1\n",
"! gsutil cp $test_item_2 $BUCKET_URI/$file_2\n",
"\n",
"test_item_1 = BUCKET_NAME + \"/\" + file_1\n",
"test_item_2 = BUCKET_NAME + \"/\" + file_2"
"test_item_1 = BUCKET_URI + \"/\" + file_1\n",
"test_item_2 = BUCKET_URI + \"/\" + file_2"
]
},
{
@@ -956,7 +946,7 @@
"source": [
"### Make the batch input file\n",
"\n",
"Now make a batch input file, which you will store in your local Cloud Storage bucket. The batch input file can be either CSV or JSONL. You will use JSONL in this tutorial. For JSONL file, you make one dictionary entry per line for each data item (instance). The dictionary contains the key/value pairs:\n",
"Now make a batch input file, which you store in your local Cloud Storage bucket. The batch input file can be either CSV or JSONL. You use JSONL in this tutorial. For JSONL file, you make one dictionary entry per line for each data item (instance). The dictionary contains the key/value pairs:\n",
"\n",
"- `content`: The Cloud Storage path to the image.\n",
"- `mime_type`: The content type. In our example, it is a `jpeg` file.\n",
@@ -978,7 +968,7 @@
"\n",
"import tensorflow as tf\n",
"\n",
"gcs_input_uri = BUCKET_NAME + \"/test.jsonl\"\n",
"gcs_input_uri = BUCKET_URI + \"/test.jsonl\"\n",
"with tf.io.gfile.GFile(gcs_input_uri, \"w\") as f:\n",
" data = {\"content\": test_item_1, \"mime_type\": \"image/jpeg\"}\n",
" f.write(json.dumps(data) + \"\\n\")\n",
@@ -1002,7 +992,7 @@
"- `job_display_name`: The human readable name for the batch prediction job.\n",
"- `gcs_source`: A list of one or more batch request input files.\n",
"- `gcs_destination_prefix`: The Cloud Storage location for storing the batch prediction resuls.\n",
"- `sync`: If set to True, the call will block while waiting for the asynchronous batch job to complete."
"- `sync`: If set to True, the call block while waiting for the asynchronous batch job to complete."
]
},
{
@@ -1014,9 +1004,9 @@
"outputs": [],
"source": [
"batch_predict_job = model.batch_predict(\n",
" job_display_name=\"flowers_\" + TIMESTAMP,\n",
" job_display_name=\"flowers_\" + UUID,\n",
" gcs_source=gcs_input_uri,\n",
" gcs_destination_prefix=BUCKET_NAME,\n",
" gcs_destination_prefix=BUCKET_URI,\n",
" sync=False,\n",
")\n",
"\n",
@@ -1232,7 +1222,7 @@
"source": [
"### Get test item\n",
"\n",
"You will use an arbitrary example out of the dataset as a test item. Don't be concerned that the example was likely used in training the model -- we just want to demonstrate how to make a prediction."
"You use an arbitrary example out of the dataset as a test item. Don't be concerned that the example was likely used in training the model -- we just want to demonstrate how to make a prediction."
]
},
{
@@ -1423,7 +1413,7 @@
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -32,17 +32,24 @@
"# Vertex AI: Vertex AI Migration: AutoML Video Object Tracking\n",
"\n",
"<table align=\"left\">\n",
"\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/ai-platform-samples/blob/main/vertex-ai-samples/tree/master/notebooks/official/migration/UJ15%20Vertex%20SDK%20AutoML%20Object%20Tracking.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ15 Vertex SDK AutoML Object Tracking.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/ai-platform-samples/blob/master/vertex-ai-samples/blob/main/notebooks/official/migration/UJ15%20Vertex%20SDK%20AutoML%20Object%20Tracking.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ15 Vertex SDK AutoML Object Tracking.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/migration/UJ15 Vertex SDK AutoML Object Tracking.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td> \n",
"</table>\n",
"<br/><br/><br/>"
]
@@ -55,7 +62,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the Traffic. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket."
"The dataset used for this tutorial is the Traffic. The version of the dataset you use in this tutorial is stored in a public Cloud Storage bucket."
]
},
{
@@ -138,39 +145,7 @@
"else:\n",
" USER_FLAG = \"\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "install_storage"
},
"source": [
"Install the latest GA version of *google-cloud-storage* library as well."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_storage"
},
"outputs": [],
"source": [
"! pip3 install -U google-cloud-storage $USER_FLAG"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_tensorflow"
},
"outputs": [],
"source": [
"if os.getenv(\"IS_TESTING\"):\n",
" ! pip3 install --upgrade tensorflow $USER_FLAG"
"! pip3 install --upgrade google-cloud-aiplatform google-cloud-storage tensorflow $USER_FLAG -q"
]
},
{
@@ -224,7 +199,7 @@
"\n",
"3. [Enable the following APIs: Vertex AI APIs, Compute Engine APIs, and Cloud Storage.](https://console.cloud.google.com/flows/enableapi?apiid=ml.googleapis.com,compute_component,storage-component.googleapis.com)\n",
"\n",
"4. If you are running this notebook locally, you will need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"4. If you are running this notebook locally, you need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"\n",
"5. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
@@ -297,7 +272,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -306,9 +284,9 @@
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
@@ -319,9 +297,16 @@
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import random\n",
"import string\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
@@ -332,7 +317,7 @@
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Google Cloud Notebooks**, your environment is already authenticated. Skip this step.\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
@@ -367,8 +352,11 @@
"import os\n",
"import sys\n",
"\n",
"# If on Google Cloud Notebook, then don't execute this code\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\"):\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
@@ -378,7 +366,7 @@
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
" %env GOOGLE_APPLICATION_CREDENTIALS '[your-service-account-key-path]'"
]
},
{
@@ -391,7 +379,7 @@
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you initialize the Vertex SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"When you initialize the Vertex AI SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
@@ -404,7 +392,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -415,8 +404,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -436,7 +426,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URI"
]
},
{
@@ -456,7 +446,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -488,9 +478,9 @@
"id": "init_aip:mbsdk"
},
"source": [
"## Initialize Vertex SDK for Python\n",
"## Initialize Vertex AI SDK for Python\n",
"\n",
"Initialize the Vertex SDK for Python for your project and corresponding bucket."
"Initialize the Vertex AI SDK for Python for your project and corresponding bucket."
]
},
{
@@ -501,7 +491,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -602,7 +592,7 @@
"outputs": [],
"source": [
"dataset = aip.VideoDataset.create(\n",
" display_name=\"Traffic\" + \"_\" + TIMESTAMP,\n",
" display_name=\"Traffic\" + \"_\" + UUID,\n",
" gcs_source=[IMPORT_FILE],\n",
" import_schema_uri=aip.schema.dataset.ioformat.video.object_tracking,\n",
")\n",
@@ -677,7 +667,7 @@
"outputs": [],
"source": [
"dag = aip.AutoMLVideoTrainingJob(\n",
" display_name=\"traffic_\" + TIMESTAMP,\n",
" display_name=\"traffic_\" + UUID,\n",
" prediction_type=\"object_tracking\",\n",
")\n",
"\n",
@@ -712,7 +702,7 @@
"\n",
"The `run` method when completed returns the `Model` resource.\n",
"\n",
"The execution of the training pipeline will take upto 20 minutes."
"The execution of the training pipeline take upto 20 minutes."
]
},
{
@@ -725,7 +715,7 @@
"source": [
"model = dag.run(\n",
" dataset=dataset,\n",
" model_display_name=\"traffic_\" + TIMESTAMP,\n",
" model_display_name=\"traffic_\" + UUID,\n",
" training_fraction_split=0.8,\n",
" test_fraction_split=0.2,\n",
")"
@@ -800,7 +790,7 @@
"outputs": [],
"source": [
"# Get model resource ID\n",
"models = aip.Model.list(filter=\"display_name=traffic_\" + TIMESTAMP)\n",
"models = aip.Model.list(filter=\"display_name=traffic_\" + UUID)\n",
"\n",
"# Get a reference to the Model Service client\n",
"client_options = {\"api_endpoint\": f\"{REGION}-aiplatform.googleapis.com\"}\n",
@@ -879,7 +869,7 @@
"source": [
"### Get test item(s)\n",
"\n",
"Now do a batch prediction to your Vertex model. You will use arbitrary examples out of the dataset as a test items. Don't be concerned that the examples were likely used in training the model -- we just want to demonstrate how to make a prediction."
"Now do a batch prediction to your Vertex model. You use arbitrary examples out of the dataset as a test items. Don't be concerned that the examples were likely used in training the model -- we just want to demonstrate how to make a prediction."
]
},
{
@@ -918,7 +908,7 @@
"source": [
"### Make a batch input file\n",
"\n",
"Now make a batch input file, which you store in your local Cloud Storage bucket. The batch input file can be either CSV or JSONL. You will use JSONL in this tutorial. For JSONL file, you make one dictionary entry per line for each video. The dictionary contains the key/value pairs:\n",
"Now make a batch input file, which you store in your local Cloud Storage bucket. The batch input file can be either CSV or JSONL. You use JSONL in this tutorial. For JSONL file, you make one dictionary entry per line for each video. The dictionary contains the key/value pairs:\n",
"\n",
"- `content`: The Cloud Storage path to the video.\n",
"- `mimeType`: The content type. In our example, it is a `avi` file.\n",
@@ -938,7 +928,7 @@
"\n",
"import tensorflow as tf\n",
"\n",
"gcs_input_uri = BUCKET_NAME + \"/test.jsonl\"\n",
"gcs_input_uri = BUCKET_URI + \"/test.jsonl\"\n",
"with tf.io.gfile.GFile(gcs_input_uri, \"w\") as f:\n",
" data = {\n",
" \"content\": test_item_1,\n",
@@ -972,7 +962,7 @@
"- `job_display_name`: The human readable name for the batch prediction job.\n",
"- `gcs_source`: A list of one or more batch request input files.\n",
"- `gcs_destination_prefix`: The Cloud Storage location for storing the batch prediction resuls.\n",
"- `sync`: If set to True, the call will block while waiting for the asynchronous batch job to complete."
"- `sync`: If set to True, the call block while waiting for the asynchronous batch job to complete."
]
},
{
@@ -984,9 +974,9 @@
"outputs": [],
"source": [
"batch_predict_job = model.batch_predict(\n",
" job_display_name=\"traffic_\" + TIMESTAMP,\n",
" job_display_name=\"traffic_\" + UUID,\n",
" gcs_source=gcs_input_uri,\n",
" gcs_destination_prefix=BUCKET_NAME,\n",
" gcs_destination_prefix=BUCKET_URI,\n",
" sync=False,\n",
")\n",
"\n",
@@ -1215,7 +1205,7 @@
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
" ! gsutil rm -r $BUCKET_URI"
]
}
],

Some files were not shown because too many files have changed in this diff Show More