Skip to content

prophet_table

prophet_table(records, periods, kwargs)

Description

Return Time Series Forecast as table using prophet python library.

Parameters of this function are passed as is to prophet python function and python function result is returned as is.

(Inspired from this Felipe Hoffa medium's post)

Usage

Call or Deploy prophet_table ?
Call prophet_table directly

The easiest way to use bigfunctions

  • prophet_table function is deployed in 39 public datasets for all of the 39 BigQuery regions.
  • It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
  • (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)

Public BigFunctions Datasets

Region Dataset
eu bigfunctions.eu
us bigfunctions.us
europe-west1 bigfunctions.europe_west1
asia-east1 bigfunctions.asia_east1
... ...
Deploy prophet_table in your project

Why deploy?

  • You may prefer to deploy prophet_table in your own project to build and manage your own catalog of functions.
  • This is particularly useful if you want to create private functions (for example calling your internal APIs).
  • Get started by reading the framework page

Deployment

prophet_table function can be deployed with:

pip install bigfunctions
bigfun get prophet_table
bigfun deploy prophet_table

Examples

1. Using a table with columns named ds and y for date and value respectively

with sample_data as (

  select date('2022-01-01') as ds, 1 as y,
      union all
      select date('2022-01-02') as ds, 2 as y,

)


select * from bigfunctions.eu.prophet_table(
      to_json((
        select array_agg(sample_data)
        from sample_data
      ))
      , 3, null)
with sample_data as (

  select date('2022-01-01') as ds, 1 as y,
      union all
      select date('2022-01-02') as ds, 2 as y,

)


select * from bigfunctions.us.prophet_table(
      to_json((
        select array_agg(sample_data)
        from sample_data
      ))
      , 3, null)
with sample_data as (

  select date('2022-01-01') as ds, 1 as y,
      union all
      select date('2022-01-02') as ds, 2 as y,

)


select * from bigfunctions.europe_west1.prophet_table(
      to_json((
        select array_agg(sample_data)
        from sample_data
      ))
      , 3, null)

| -------------------------------------|
|    date    | yhat | yhat_lower | ... |
| -------------------------------------|
| 2022-01-03 |  3   |     3      | ... |
| 2022-01-04 |  4   |     4      | ... |
| 2022-01-05 |  5   |     5      | ... |
| -------------------------------------|


2. Using a table with columns to rename to ds and y

with sample_data as (

  select date('2022-01-01') as date, 1 as value,
      union all
      select date('2022-01-02') as date, 2 as value,

)


select * from bigfunctions.eu.prophet_table(
      to_json((
        select array_agg(struct(date as ds, value as y))
        from sample_data
      ))
      , 3, null)
with sample_data as (

  select date('2022-01-01') as date, 1 as value,
      union all
      select date('2022-01-02') as date, 2 as value,

)


select * from bigfunctions.us.prophet_table(
      to_json((
        select array_agg(struct(date as ds, value as y))
        from sample_data
      ))
      , 3, null)
with sample_data as (

  select date('2022-01-01') as date, 1 as value,
      union all
      select date('2022-01-02') as date, 2 as value,

)


select * from bigfunctions.europe_west1.prophet_table(
      to_json((
        select array_agg(struct(date as ds, value as y))
        from sample_data
      ))
      , 3, null)

| -------------------------------------|
|    date    | yhat | yhat_lower | ... |
| -------------------------------------|
| 2022-01-03 |  3   |     3      | ... |
| 2022-01-04 |  4   |     4      | ... |
| 2022-01-05 |  5   |     5      | ... |
| -------------------------------------|



Need help or Found a bug?
Get help using prophet_table

The community can help! Engage the conversation on Slack

We also provide professional suppport.

Report a bug about prophet_table

If the function does not work as expected, please

  • report a bug so that it can be improved.
  • or open the discussion with the community on Slack.

We also provide professional suppport.


Show your ❤ by adding a ⭐ on