-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add file for Classification with a Boosted Treed Model and snip…
…pet for preparing sample data (#1135) * docs: add snippet for Linear Regression tutorial Explain Prediction section * add snippet that prepares census sample data * remove file changes * rename file due to typo
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
samples/snippets/classification_boosted_tree_model_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |