mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
@@ -157,8 +157,8 @@
|
||||
"\n",
|
||||
"! pip3 install --upgrade --quiet google-cloud-aiplatform \\\n",
|
||||
" google-cloud-storage \\\n",
|
||||
" 'kfp<2' \\\n",
|
||||
" 'google-cloud-pipeline-components<2'\n",
|
||||
" kfp \\\n",
|
||||
" google-cloud-pipeline-components\n",
|
||||
"\n",
|
||||
"if os.getenv(\"IS_TESTING\"):\n",
|
||||
" ! pip3 install --upgrade matplotlib $USER_FLAG -q"
|
||||
@@ -389,7 +389,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! gsutil mb -l $REGION -p $PROJECT_ID $BUCKET_URI"
|
||||
"! gsutil mb -l {REGION} -p {PROJECT_ID} {BUCKET_URI}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -489,8 +489,8 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import google.cloud.aiplatform as aip\n",
|
||||
"from kfp.v2 import dsl\n",
|
||||
"from kfp.v2.dsl import ClassificationMetrics, Metrics, Output, component"
|
||||
"from kfp import compiler, dsl\n",
|
||||
"from kfp.dsl import ClassificationMetrics, Metrics, Output, component"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -567,11 +567,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"@component(\n",
|
||||
" packages_to_install=[\"scikit-learn==1.2.2\"],\n",
|
||||
" base_image=\"python:3.9\",\n",
|
||||
" output_component_file=\"wine_classification_component.yaml\",\n",
|
||||
")\n",
|
||||
"@component(packages_to_install=[\"scikit-learn==1.2.2\"], base_image=\"python:3.9\")\n",
|
||||
"def wine_classification(wmetrics: Output[ClassificationMetrics]):\n",
|
||||
" from sklearn.datasets import load_wine\n",
|
||||
" from sklearn.ensemble import RandomForestClassifier\n",
|
||||
@@ -589,7 +585,10 @@
|
||||
" fpr, tpr, thresholds = roc_curve(\n",
|
||||
" y_true=y_train, y_score=y_scores[:, 1], pos_label=True\n",
|
||||
" )\n",
|
||||
" wmetrics.log_roc_curve(fpr, tpr, thresholds)"
|
||||
" wmetrics.log_roc_curve(fpr, tpr, thresholds)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"compiler.Compiler().compile(wine_classification, \"wine_classification_component.yaml\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -758,11 +757,9 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from kfp.v2 import compiler # noqa: F811\n",
|
||||
"\n",
|
||||
"compiler.Compiler().compile(\n",
|
||||
" pipeline_func=pipeline,\n",
|
||||
" package_path=\"tabular_classification_pipeline.json\",\n",
|
||||
" package_path=\"tabular_classification_pipeline.yaml\",\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
@@ -789,7 +786,7 @@
|
||||
"\n",
|
||||
"job = aip.PipelineJob(\n",
|
||||
" display_name=DISPLAY_NAME,\n",
|
||||
" template_path=\"tabular_classification_pipeline.json\",\n",
|
||||
" template_path=\"tabular_classification_pipeline.yaml\",\n",
|
||||
" job_id=f\"tabular-classification-v2{UUID}-1\",\n",
|
||||
" pipeline_root=PIPELINE_ROOT,\n",
|
||||
" parameter_values={\"seed\": 7, \"splits\": 10},\n",
|
||||
@@ -847,7 +844,7 @@
|
||||
"source": [
|
||||
"job = aip.PipelineJob(\n",
|
||||
" display_name=\"iris_\" + UUID,\n",
|
||||
" template_path=\"tabular_classification_pipeline.json\",\n",
|
||||
" template_path=\"tabular_classification_pipeline.yaml\",\n",
|
||||
" job_id=f\"tabular-classification-pipeline-v2{UUID}-2\",\n",
|
||||
" pipeline_root=PIPELINE_ROOT,\n",
|
||||
" parameter_values={\"seed\": 5, \"splits\": 7},\n",
|
||||
@@ -982,7 +979,9 @@
|
||||
"\n",
|
||||
"job.delete()\n",
|
||||
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
|
||||
" ! gsutil rm -r $BUCKET_URI"
|
||||
" ! gsutil rm -r $BUCKET_URI\n",
|
||||
"\n",
|
||||
"! rm -rf tabular_classification_pipeline.yaml"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user