fixed notebook with dynamic model name

cleared output from cells
added creation of view instead of table
This commit is contained in:
Giorgio Conte 2023-02-27 15:28:49 +00:00
parent 3271acd2f2
commit 17b8a461f0
2 changed files with 6 additions and 15 deletions

View File

@ -98,7 +98,7 @@
" query=f'CREATE SCHEMA IF NOT EXISTS {dataset}'\n",
" )\n",
"\n",
" create_features_table = bqop.BigqueryQueryJobOp(\n",
" create_features_view = bqop.BigqueryQueryJobOp(\n",
" project=project_id,\n",
" location=location,\n",
" query=features_query.format(dataset=dataset, project_id=project_id),\n",
@ -114,7 +114,7 @@
" , dataset = dataset\n",
" , model_name = model_name\n",
" , split_fraction=split_fraction)\n",
" ).after(create_features_table)\n",
" ).after(create_features_view)\n",
"\n",
" evaluate_bqml_model = bqop.BigqueryEvaluateModelJobOp(\n",
" project=project_id,\n",
@ -205,7 +205,7 @@
"outputs": [],
"source": [
"# get the model from the Model Registry \n",
"model = aip.Model(model_name='levelup_model_name-fraction-10')\n",
"model = aip.Model(model_name=f'{MODEL_NAME}-fraction-10')\n",
"\n",
"# let's create a Vertex Endpoint where we will deploy the ML model\n",
"endpoint = aip.Endpoint.create(\n",
@ -219,18 +219,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with '/usr/bin/python3' requires the ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: '/usr/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
]
}
],
"outputs": [],
"source": [
"# deploy the BQ ML model on Vertex Endpoint\n",
"# have a coffe - this step can take up 10/15 minutes to finish\n",

View File

@ -1,3 +1,5 @@
CREATE view if not exists `{project_id}.{dataset}.ecommerce_abt` as
with abt as (
SELECT user_id, session_id, city, postal_code, browser,traffic_source, min(created_at) as session_starting_ts, sum(case when event_type = 'purchase' then 1 else 0 end) has_purchased
FROM `bigquery-public-data.thelook_ecommerce.events`