From 743e08af1bc1cb2b9d3bc8d0b571363318b01567 Mon Sep 17 00:00:00 2001 From: Daniela Date: Mon, 6 Jan 2025 22:39:33 +0000 Subject: [PATCH 1/5] merge main --- ...single_timeseries_forecasting_model_test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/samples/snippets/create_single_timeseries_forecasting_model_test.py b/samples/snippets/create_single_timeseries_forecasting_model_test.py index 0e69eba3dd..0e29d2aa11 100644 --- a/samples/snippets/create_single_timeseries_forecasting_model_test.py +++ b/samples/snippets/create_single_timeseries_forecasting_model_test.py @@ -64,6 +64,24 @@ def test_create_single_timeseries() -> None: model.fit(X, y) # [END bigquery_dataframes_single_timeseries_forecasting_model_tutorial_create] + + # [START bigquery_dataframes_single_timeseries_forecasting_model_tutorial_evaluate] + + # + model.summary( + show_all_candidate_models=True, + ) + + # Expected output: + # row non_seasonal_p non_seasonal_d non_seasonal_q has_drift log_likelihood AIC variance seasonal_periods has_holiday_effect has_spikes_and_dips has_step_changes error_message + # 0 0 1 3 True -2464.255656 4938.511313 42772.506055 ['WEEKLY'] False False True + # 1 2 1 0 False -2473.141651 4952.283303 44942.416463 ['WEEKLY'] False False True + # 2 1 1 0 False -2479.880885 4963.76177 46642.953433 ['WEEKLY'] False False True + # 3 0 1 1 False -2470.632377 4945.264753 44319.379307 ['WEEKLY'] False False True + # 4 2 1 1 True -2463.671247 4937.342493 42633.299513 ['WEEKLY'] False False True + + # [END bigquery_dataframes_single_timeseries_forecasting_model_tutorial_evaluate] + assert model is not None assert parsed_date is not None assert total_visits is not None From d9476b7af413b34489fc3b7375e8485567b15a4b Mon Sep 17 00:00:00 2001 From: Daniela Date: Mon, 6 Jan 2025 23:08:13 +0000 Subject: [PATCH 2/5] details --- .../create_single_timeseries_forecasting_model_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/snippets/create_single_timeseries_forecasting_model_test.py b/samples/snippets/create_single_timeseries_forecasting_model_test.py index 0e29d2aa11..9b02839e1b 100644 --- a/samples/snippets/create_single_timeseries_forecasting_model_test.py +++ b/samples/snippets/create_single_timeseries_forecasting_model_test.py @@ -67,7 +67,9 @@ def test_create_single_timeseries() -> None: # [START bigquery_dataframes_single_timeseries_forecasting_model_tutorial_evaluate] - # + # Evaluate the time series models by using the summary() function. The summary() + # function shows you the evaluation metrics of all the candidate models evaluated + # during the process of automatic hyperparameter tuning. model.summary( show_all_candidate_models=True, ) From e33661cb9b9596eb38a72c46389351e93c93a3b9 Mon Sep 17 00:00:00 2001 From: rey-esp Date: Tue, 7 Jan 2025 10:45:04 -0600 Subject: [PATCH 3/5] Update samples/snippets/create_single_timeseries_forecasting_model_test.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tim Sweña (Swast) --- .../create_single_timeseries_forecasting_model_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/snippets/create_single_timeseries_forecasting_model_test.py b/samples/snippets/create_single_timeseries_forecasting_model_test.py index 9b02839e1b..7ba1ce4747 100644 --- a/samples/snippets/create_single_timeseries_forecasting_model_test.py +++ b/samples/snippets/create_single_timeseries_forecasting_model_test.py @@ -70,9 +70,10 @@ def test_create_single_timeseries() -> None: # Evaluate the time series models by using the summary() function. The summary() # function shows you the evaluation metrics of all the candidate models evaluated # during the process of automatic hyperparameter tuning. - model.summary( + summary = model.summary( show_all_candidate_models=True, ) + print(summary.peek()) # Expected output: # row non_seasonal_p non_seasonal_d non_seasonal_q has_drift log_likelihood AIC variance seasonal_periods has_holiday_effect has_spikes_and_dips has_step_changes error_message @@ -84,6 +85,7 @@ def test_create_single_timeseries() -> None: # [END bigquery_dataframes_single_timeseries_forecasting_model_tutorial_evaluate] + assert summary is not None assert model is not None assert parsed_date is not None assert total_visits is not None From c03105f75dd2d2f204d0e730b6b34d4d162769bb Mon Sep 17 00:00:00 2001 From: Daniela Date: Thu, 9 Jan 2025 20:49:00 +0000 Subject: [PATCH 4/5] expand ibis to bq type conversion --- .../bigframes_vendored/ibis/backends/bigquery/datatypes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/bigframes_vendored/ibis/backends/bigquery/datatypes.py b/third_party/bigframes_vendored/ibis/backends/bigquery/datatypes.py index baf20dff75..5b4e4d85a1 100644 --- a/third_party/bigframes_vendored/ibis/backends/bigquery/datatypes.py +++ b/third_party/bigframes_vendored/ibis/backends/bigquery/datatypes.py @@ -55,6 +55,8 @@ def from_ibis(cls, dtype: dt.DataType) -> str: return "INT64" elif dtype.is_binary(): return "BYTES" + elif dtype.is_string(): + return "STRING" elif dtype.is_date(): return "DATE" elif dtype.is_timestamp(): From f3127d06aedf40e0e4e3d7e88b07139599b2d596 Mon Sep 17 00:00:00 2001 From: Daniela Date: Thu, 9 Jan 2025 21:17:03 +0000 Subject: [PATCH 5/5] added unit test for from_ibis --- tests/unit/core/test_dtypes.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/core/test_dtypes.py b/tests/unit/core/test_dtypes.py index 83a643f6e1..a5b0889bf9 100644 --- a/tests/unit/core/test_dtypes.py +++ b/tests/unit/core/test_dtypes.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import bigframes_vendored.ibis.backends.bigquery.datatypes as ibis_bq_types import bigframes_vendored.ibis.expr.datatypes as ibis_dtypes import bigframes_vendored.ibis.expr.types as ibis_types import geopandas as gpd # type: ignore @@ -152,6 +153,15 @@ def test_ibis_dtype_to_arrow_dtype(ibis_dtype, arrow_dtype): assert result == arrow_dtype +@pytest.mark.parametrize( + ("ibis_dtype", "bigquery_type"), + [(ibis_dtypes.String(), "STRING"), (ibis_dtypes.String(nullable=False), "STRING")], +) +def test_ibis_dtype_to_bigquery_type(ibis_dtype, bigquery_type): + result = ibis_bq_types.BigQueryType.from_ibis(ibis_dtype) + assert result == bigquery_type + + @pytest.mark.parametrize( ["bigframes_dtype", "ibis_dtype"], [