-
Notifications
You must be signed in to change notification settings - Fork 50
docs: add snippets for visualizing a time series and creating a time series model for the Limit forecasted values in time series model tutorial #1310
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
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
9c16442
merge main
rey-esp fa41486
temp snippet
rey-esp 61cc9b6
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 43f6acf
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp a8d4b5a
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp e92a752
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 5f36534
Merge branch 'b338872698-bigframes-limit-0' of github.com:googleapis/…
rey-esp c5020ff
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp f0e7f24
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 51c4e5f
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 34bd2e4
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp a976efb
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 3d42261
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 239cdbe
fix typo
rey-esp 82a5a58
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 972abe0
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp d1c57ac
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 31c1e30
Delete demo.ipynb
rey-esp 8138077
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp cec581f
Update samples/snippets/limit_single_timeseries_forecasting_model_tes…
rey-esp 582746d
Update samples/snippets/limit_single_timeseries_forecasting_model_tes…
rey-esp 2293f13
Update samples/snippets/limit_single_timeseries_forecasting_model_tes…
rey-esp 2f533d6
Update samples/snippets/limit_single_timeseries_forecasting_model_tes…
rey-esp 336109f
Update samples/snippets/limit_single_timeseries_forecasting_model_tes…
rey-esp 3a735a3
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 71d20e2
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 2ec31cc
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 7a2c893
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 2417408
add plot line for visualization
rey-esp f208543
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp b28ee89
Merge branch 'b338872698-bigframes-limit-0' of github.com:googleapis/…
rey-esp c6870c0
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp f196805
change bar chart to line chart
rey-esp d3d69f8
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 05484e8
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 90cf6b4
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp a4e746f
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp e913037
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 6a2a4f8
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 395a486
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp 62a931a
Merge branch 'main' into b338872698-bigframes-limit-0
rey-esp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
samples/snippets/limit_single_timeseries_forecasting_model_test.py
This file contains hidden or 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,64 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (t | ||
# you may not use this file except in compliance wi | ||
# 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 | ||
# distributed under the License is distributed on a | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eit | ||
# See the License for the specific language governi | ||
# limitations under the License. | ||
|
||
|
||
def test_limit_single_timeseries(random_model_id: str) -> None: | ||
your_model_id = random_model_id | ||
|
||
# [START bigquery_dataframes_bqml_limit_forecast_visualize] | ||
import bigframes.pandas as bpd | ||
|
||
df = bpd.read_gbq("bigquery-public-data.new_york.citibike_trips") | ||
|
||
features = bpd.DataFrame( | ||
{ | ||
"num_trips": df.starttime, | ||
"date": df["starttime"].dt.date, | ||
} | ||
) | ||
num_trips = features.groupby(["date"]).count() | ||
|
||
num_trips.plot.line() | ||
# [END bigquery_dataframes_bqml_limit_forecast_visualize] | ||
|
||
# [START bigquery_dataframes_bqml_limit_forecast_create] | ||
from bigframes.ml import forecasting | ||
import bigframes.pandas as bpd | ||
|
||
df = bpd.read_gbq("bigquery-public-data.new_york.citibike_trips") | ||
|
||
features = bpd.DataFrame( | ||
{ | ||
"start_station_id": df["start_station_id"], | ||
"num_trips": df.starttime, | ||
"date": df["starttime"].dt.date, | ||
} | ||
) | ||
num_trips = features.groupby(["date", "start_station_id"], as_index=False).count() | ||
model = forecasting.ARIMAPlus() | ||
|
||
X = num_trips[["date"]] | ||
y = num_trips[["num_trips"]] | ||
id_col = num_trips[["start_station_id"]] | ||
|
||
model.fit(X, y, id_col=id_col) | ||
|
||
model.to_gbq( | ||
your_model_id, # For example: "bqml_tutorial.nyc_citibike_arima_model", | ||
replace=True, | ||
) | ||
# [END bigquery_dataframes_bqml_limit_forecast_create] | ||
assert df is not None | ||
assert features is not None | ||
assert num_trips is not None |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.