Skip to content

feat: add DataFrame.ai.forecast() support #1828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 17, 2025
Merged

Conversation

GarrettWu
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@GarrettWu GarrettWu requested review from sycai and chelsea-lin June 16, 2025 23:27
@GarrettWu GarrettWu self-assigned this Jun 16, 2025
@GarrettWu GarrettWu requested review from a team as code owners June 16, 2025 23:27
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Jun 16, 2025

self._df: bigframes.dataframe.DataFrame = df
self._base_bqml = ml_core.BaseBqml(session=df._session)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you inject BaseBqml as a constructor parameter (default to None)? It might make testing easier if we want to fake/mock BaseBqml in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

"confidence_level": confidence_level,
}
if id_columns:
options["id_cols"] = id_columns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should verify the validity of timestamp_column and data_column, and raise error if necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the data types? We rely on the checks from the backend. Basically client libraries shouldn't do too much checks unless those are only specific to client.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I meant the existence of these columns. If the user has made some typos, we want the code to fail fast. The other methods have this check too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@GarrettWu GarrettWu requested a review from sycai June 16, 2025 23:51

self._df: bigframes.dataframe.DataFrame = df
self._base_bqml: ml_core.BaseBqml = base_bqml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also provide a default BaseBqml instance if None is provided: It should be just ml_core.BaseBqml(df._session).

By doing this, we don't need to provide one in that dataframe ai property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

sycai
sycai previously approved these changes Jun 17, 2025
@sycai
Copy link
Contributor

sycai commented Jun 17, 2025

Thanks!

@GarrettWu GarrettWu merged commit 7bc7f36 into main Jun 17, 2025
22 of 24 checks passed
@GarrettWu GarrettWu deleted the garrettwu-forecast branch June 17, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants