|
| 1 | +# Copyright 2024 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +def test_boosted_tree_model(random_model_id: str) -> None: |
| 17 | + # your_model_id = random_model_id |
| 18 | + # [START bigquery_dataframes_bqml_boosted_tree_prepare] |
| 19 | + import bigframes.pandas as bpd |
| 20 | + |
| 21 | + input_data = bpd.read_gbq( |
| 22 | + "bigquery-public-data.ml_datasets.census_adult_income", |
| 23 | + columns=( |
| 24 | + "age", |
| 25 | + "workclass", |
| 26 | + "marital_status", |
| 27 | + "education_num", |
| 28 | + "occupation", |
| 29 | + "hours_per_week", |
| 30 | + "income_bracket", |
| 31 | + "functional_weight", |
| 32 | + ), |
| 33 | + ) |
| 34 | + input_data["dataframe"] = bpd.Series("training", index=input_data.index,).case_when( |
| 35 | + [ |
| 36 | + (((input_data["functional_weight"] % 10) == 8), "evaluation"), |
| 37 | + (((input_data["functional_weight"] % 10) == 9), "prediction"), |
| 38 | + ] |
| 39 | + ) |
| 40 | + del input_data["functional_weight"] |
| 41 | + # [END bigquery_dataframes_bqml_boosted_tree_prepare] |
| 42 | + assert input_data is not None |
0 commit comments