docs: add sample for getting started with BQML#141
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
| # When writing a DataFrame to a BigQuery table, include destinaton table | ||
| # and parameters, index defaults to "True". |
There was a problem hiding this comment.
This comment has nothing to do with BigQuery ML models. Please fix.
Note: The important thing here is that we're taking our trained model and writing it to a permanent location.
There was a problem hiding this comment.
Agreed, corrected.
There was a problem hiding this comment.
FYI: The comment is still talking about tables not models. I'll make a comment with a suggested edit.
| @@ -0,0 +1,13 @@ | |||
| # Copyright 2023 Google LLC | |||
There was a problem hiding this comment.
We can remove this file for now. Let's do a separate PR for the K-Means tutorials.
There was a problem hiding this comment.
This file still needs to be deleted.
|
|
||
| # The model.fit() call above created a temporary model. | ||
| # Use the to_gbq() method to write to a permanent location. | ||
| model.to_gbq("bqml_tutorial.sample_model", replace=True) |
There was a problem hiding this comment.
FYI: We're getting
E google.api_core.exceptions.BadRequest: 400 Concurrent update on same model: bigframes-dev:bqml_tutorial.sample_model is not supported. Share your usecase with the BigQuery DataFrames team at the [https://bit.ly/bigframes-feedback](https://www.google.com/url?q=https://bit.ly/bigframes-feedback&sa=D) survey.
failure in our test suite: https://fusion2.corp.google.com/invocations/8a7513c8-e7c9-4b5b-82fe-9a83c176fbc1/targets/bigframes%2Fpresubmit%2Fe2e/log
I think we'll need a test fixture for this to create a temporary place for the model and clean it up when the test finishes.
-
Create a file called
samples/snippets/conftest.py. -
In the
conftest.pyfile you create, add a fixture calledrandom_model_id, similar to this one: https://github.com/googleapis/python-bigquery/blob/f804d639fe95bef5d083afe1246d756321128b05/samples/snippets/conftest.py#L101-L111 except it'll calldelete_model(...)instead ofdelete_table(...).You'll also need to add "prefixer" https://github.com/googleapis/python-bigquery/blob/f804d639fe95bef5d083afe1246d756321128b05/samples/snippets/conftest.py#L21 and
bigquery_clientfixture https://github.com/googleapis/python-bigquery/blob/f804d639fe95bef5d083afe1246d756321128b05/samples/snippets/conftest.py#L33-L36 -
Update your code sample to use the new
random_model_idfixture.Look how we do it in the remote functions test:
but instead you'll be settingpython-bigquery-dataframes/samples/snippets/remote_function.py
Lines 17 to 23 in 81125f9
your_model_id = random_model_idand callingmodel.to_gbq( your_model_id, # "project.dataset.model_id" or "dataset.model_id" replace=True, )
|
|
||
|
|
||
| def test_bqml_getting_started(): | ||
| # [START bigquery_getting_started_bqml_tutorial] |
There was a problem hiding this comment.
Let's use bigquery_dataframes_bqml_getting_started for our region tags.
| @@ -0,0 +1,25 @@ | |||
| Copyright (c) 2013-2022, GeoPandas developers. | |||
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕