From 099b5b60e737ac92201c987a4d5dd052680da339 Mon Sep 17 00:00:00 2001 From: Daniela Date: Mon, 4 Nov 2024 22:12:24 +0000 Subject: [PATCH 1/4] docs: add snippet for Linear Regression tutorial Explain Prediction section --- samples/snippets/linear_regression_tutorial_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/snippets/linear_regression_tutorial_test.py b/samples/snippets/linear_regression_tutorial_test.py index 452d88746d..8799612e89 100644 --- a/samples/snippets/linear_regression_tutorial_test.py +++ b/samples/snippets/linear_regression_tutorial_test.py @@ -78,6 +78,8 @@ def test_linear_regression(random_model_id: str) -> None: # 332 4740.7907 Gentoo penguin (Pygoscelis papua) Biscoe 46.2 14.4 214.0 4650.0 # 160 4731.310452 Gentoo penguin (Pygoscelis papua) Biscoe 44.5 14.3 216.0 4100.0 # [END bigquery_dataframes_bqml_linear_predict] + # [START bigquery_dataframes_bqml_linear_explain] + # [END bigquery_dataframes_bqml_linear_explain] assert feature_columns is not None assert label_columns is not None assert model is not None From 0877b5760dd0ad54d6e4f4680226cc47ed5cdd3e Mon Sep 17 00:00:00 2001 From: Daniela Date: Wed, 6 Nov 2024 20:52:17 +0000 Subject: [PATCH 2/4] add snippet that prepares census sample data --- ...classification_booseted_tree_model_test.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 samples/snippets/classification_booseted_tree_model_test.py diff --git a/samples/snippets/classification_booseted_tree_model_test.py b/samples/snippets/classification_booseted_tree_model_test.py new file mode 100644 index 0000000000..fbc9369dde --- /dev/null +++ b/samples/snippets/classification_booseted_tree_model_test.py @@ -0,0 +1,42 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +def test_boosted_tree_model(random_model_id: str) -> None: + # your_model_id = random_model_id + # [START bigquery_dataframes_bqml_boosted_tree_prepare] + import bigframes.pandas as bpd + + input_data = bpd.read_gbq( + "bigquery-public-data.ml_datasets.census_adult_income", + columns=( + "age", + "workclass", + "marital_status", + "education_num", + "occupation", + "hours_per_week", + "income_bracket", + "functional_weight", + ), + ) + input_data["dataframe"] = bpd.Series("training", index=input_data.index,).case_when( + [ + (((input_data["functional_weight"] % 10) == 8), "evaluation"), + (((input_data["functional_weight"] % 10) == 9), "prediction"), + ] + ) + del input_data["functional_weight"] + # [END bigquery_dataframes_bqml_boosted_tree_prepare] + assert input_data is not None From de4e036272e8db104d6b4464969141beef5d8854 Mon Sep 17 00:00:00 2001 From: Daniela Date: Wed, 6 Nov 2024 21:13:55 +0000 Subject: [PATCH 3/4] remove file changes --- samples/snippets/linear_regression_tutorial_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/snippets/linear_regression_tutorial_test.py b/samples/snippets/linear_regression_tutorial_test.py index 8799612e89..452d88746d 100644 --- a/samples/snippets/linear_regression_tutorial_test.py +++ b/samples/snippets/linear_regression_tutorial_test.py @@ -78,8 +78,6 @@ def test_linear_regression(random_model_id: str) -> None: # 332 4740.7907 Gentoo penguin (Pygoscelis papua) Biscoe 46.2 14.4 214.0 4650.0 # 160 4731.310452 Gentoo penguin (Pygoscelis papua) Biscoe 44.5 14.3 216.0 4100.0 # [END bigquery_dataframes_bqml_linear_predict] - # [START bigquery_dataframes_bqml_linear_explain] - # [END bigquery_dataframes_bqml_linear_explain] assert feature_columns is not None assert label_columns is not None assert model is not None From de9b4b08de6b56e1e30e9b0b3aeec1fde0e6ee16 Mon Sep 17 00:00:00 2001 From: Daniela Date: Wed, 6 Nov 2024 21:17:05 +0000 Subject: [PATCH 4/4] rename file due to typo --- ...ee_model_test.py => classification_boosted_tree_model_test.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/snippets/{classification_booseted_tree_model_test.py => classification_boosted_tree_model_test.py} (100%) diff --git a/samples/snippets/classification_booseted_tree_model_test.py b/samples/snippets/classification_boosted_tree_model_test.py similarity index 100% rename from samples/snippets/classification_booseted_tree_model_test.py rename to samples/snippets/classification_boosted_tree_model_test.py