feat: add df.bigquery.ai.forecast method to pandas dataframe accessor#2518
feat: add df.bigquery.ai.forecast method to pandas dataframe accessor#2518
df.bigquery.ai.forecast method to pandas dataframe accessor#2518Conversation
This adds a new `ai` property to `BigQueryDataFrameAccessor` which returns an `AIAccessor`. The `AIAccessor` provides a `forecast` method that calls `bigframes.bigquery.ai.forecast`, converting the Pandas DataFrame to a BigFrames DataFrame and the result back to a Pandas DataFrame. Co-authored-by: tswast <247555+tswast@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| The time points column provides the time points used to generate the forecast. | ||
| The time points column must use one of the following data types: TIMESTAMP, DATE and DATETIME | ||
| model (str, default "TimesFM 2.0"): | ||
| A str value that specifies the name of the model. TimesFM 2.0 is the only supported value, and is the default value. |
There was a problem hiding this comment.
@jules According to https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast, "TimesFM 2.5" is also supported. We should link to https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast in the docstring, above.
There was a problem hiding this comment.
Added a link to the standard-sql documentation for ai.forecast and updated the model param documentation to include TimesFM 2.5.
| The DataFrame is converted to BigFrames by calling ``read_pandas``, then the forecast | ||
| is generated using ``bigframes.bigquery.ai.forecast``, and the result is | ||
| converted back to a pandas DataFrame using ``to_pandas``. |
There was a problem hiding this comment.
@jules This is an implementation detail that doesn't belong in the docstring.
There was a problem hiding this comment.
Removed the implementation details regarding read_pandas and to_pandas from the docstring.
| model: str = "TimesFM 2.0", | ||
| id_cols: Optional[Iterable[str]] = None, | ||
| horizon: int = 10, | ||
| confidence_level: float = 0.95, |
There was a problem hiding this comment.
@jules Missing the output_historical_time_series boolean parameter.
There was a problem hiding this comment.
Added the missing output_historical_time_series boolean parameter and documented it.
| @@ -0,0 +1,25 @@ | |||
| import pandas as pd | |||
There was a problem hiding this comment.
@jules missing the license header.
There was a problem hiding this comment.
Added the missing Apache 2.0 license header to tests/system/small/extensions/test_dataframe_accessor.py.
* Updated documentation to refer to BigQuery AI.FORECAST syntax. * Removed internal implementation details (`read_pandas` and `to_pandas`) from docstring. * Added missing `output_historical_time_series` parameter. * Added missing copyright headers to `tests/system/small/extensions/test_dataframe_accessor.py`. Co-authored-by: tswast <247555+tswast@users.noreply.github.com>
df.bigquery.ai.forecast method to pandas dataframe accessor
| session = bf_session.get_global_session() | ||
|
|
||
| bf_df = cast(bpd.DataFrame, session.read_pandas(self._obj)) | ||
| result = bigframes.bigquery.ai.forecast( |
There was a problem hiding this comment.
I'm curious if this triggers our logger.
My gut feeling says yes, because our logger only seems to track the call stack of annotated classes / functions. However, I still feel like to double check with you on this.
Adds the
.bigquery.ai.forecast()method to pandas DataFrame objects, which proxies tobigframes.bigquery.ai.forecast(). Added unit tests and mocked session responses.PR created automatically by Jules for task 14604090974587392182 started by @tswast