Skip to content
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

Congestion forecast #42

Open
toshi0607 opened this issue Oct 7, 2020 · 3 comments
Open

Congestion forecast #42

toshi0607 opened this issue Oct 7, 2020 · 3 comments

Comments

@toshi0607
Copy link
Owner

toshi0607 commented Oct 7, 2020

Explanatory variables

  • datetime
  • weekday
  • holiday
  • event
  • weather
  • temperature

male and female

Predictor variable

sauna state

Ref

https://medium.com/google-cloud-jp/bigquery-ml%E3%81%AE%E7%B7%9A%E5%BD%A2%E5%9B%9E%E5%B8%B0%E3%81%A7%E9%9B%BB%E5%8A%9B%E9%9C%80%E8%A6%81%E4%BA%88%E6%B8%AC%E3%82%84%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F-fd211a8a4ded

@toshi0607
Copy link
Owner Author

toshi0607 commented Oct 7, 2020

Test

Prediction with an existing feature (only datetime)

Data import from Sheets to BQ

https://cloud.google.com/bigquery/docs/loading-data
https://cloud.google.com/bigquery/external-data-drive

$ gcloud auth login --enable-gdrive-access

Create dataset
Follow the instruction to create table. Just input the sheets URL and decide a table name. Import scope is also selectable.

create model `sauna_prediction.congestion_model`
options(model_type='linear_reg') as
select
  string_field_2 as datetime
  ,cast (string_field_0 as INT64) as label
from `terraform-toshi0607.sauna_prediction.simple`
;

=> 'label' column should be numerical. Because fields are all string.
=> Bad int64 value: male because the header is not excluded

@toshi0607
Copy link
Owner Author

Import another sheet

  • RFC 3399 is unable to parse by BQ.
  • male and female are imported as INTEGER
create model `sauna_prediction.congestion_model`
options(model_type='linear_reg') as
select
  fts
  ,male as label
from `terraform-toshi0607.sauna_prediction.sauna_2020_1014_f`
;

このステートメントで新しいモデル terraform-toshi0607:sauna_prediction.congestion_model が作成されました。

@toshi0607
Copy link
Owner Author

Prediction

select * from ml.predict(model `sauna_prediction.congestion_model`, (select fts, male from `terraform-toshi0607.sauna_prediction.sauna_2020_1014_f`));

This is useless because

スクリーンショット 2020-10-15 0 07 17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant