-
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.
feat: add
ARIMAPlus.predict_explain()
to generate forecasts with ex…
…planation columns (#1177) * feat: create arima_plus_predict_attribution method * tmp: debug notes for time_series_arima_plus_model.predict_attribution * update test_arima_plus_predict_explain_default test and create test_arima_plus_predict_explain_params test * Merge branch 'ml-predict-explain' of github.com:googleapis/python-bigquery-dataframes into ml-predict-explain * update test_arima_plus_predict_explain_params test * Revert "tmp: debug notes for time_series_arima_plus_model.predict_attribution" This reverts commit f6dd455. * format and lint * Update bigframes/ml/forecasting.py Co-authored-by: Tim Sweña (Swast) <[email protected]> * update predict explain params test * update test * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add unit test file - bare bones * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fixed tests * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * lint * lint * fix test: float -> int --------- Co-authored-by: Chelsea Lin <[email protected]> Co-authored-by: Tim Sweña (Swast) <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0d8a16b
commit 05f8b4d
Showing
5 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
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,58 @@ | ||
# Copyright 2023 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. | ||
|
||
import re | ||
|
||
import pytest | ||
|
||
from bigframes.ml import forecasting | ||
|
||
|
||
def test_predict_explain_low_confidence_level(): | ||
confidence_level = -0.5 | ||
|
||
model = forecasting.ARIMAPlus() | ||
|
||
with pytest.raises( | ||
ValueError, | ||
match=re.escape( | ||
f"confidence_level must be [0.0, 1.0), but is {confidence_level}." | ||
), | ||
): | ||
model.predict_explain(horizon=4, confidence_level=confidence_level) | ||
|
||
|
||
def test_predict_high_explain_confidence_level(): | ||
confidence_level = 2.1 | ||
|
||
model = forecasting.ARIMAPlus() | ||
|
||
with pytest.raises( | ||
ValueError, | ||
match=re.escape( | ||
f"confidence_level must be [0.0, 1.0), but is {confidence_level}." | ||
), | ||
): | ||
model.predict_explain(horizon=4, confidence_level=confidence_level) | ||
|
||
|
||
def test_predict_explain_low_horizon(): | ||
horizon = -1 | ||
|
||
model = forecasting.ARIMAPlus() | ||
|
||
with pytest.raises( | ||
ValueError, match=f"horizon must be at least 1, but is {horizon}." | ||
): | ||
model.predict_explain(horizon=horizon, confidence_level=0.9) |