Skip to content

Instantly share code, notes, and snippets.

@gidutz
Created August 13, 2018 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gidutz/7a0bd510494285fd679cde71944e9d77 to your computer and use it in GitHub Desktop.
Save gidutz/7a0bd510494285fd679cde71944e9d77 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE MODEL
billing_dataset_example.model_linear_regression --model save path
OPTIONS
( model_type='linear_reg', -- As of Aug 2018 you can choose between linear regression and logistic regression
ls_init_learn_rate=.015,
l1_reg=0.1,
l2_reg=0.1,
data_split_method='seq',
data_split_col='split_col',
max_iterations=30 -- by default, uses early stopping!
) AS
SELECT
monthly_cost label, -- by naming this field "label" we make it target field
year split_col,
-- independent variables:
cumsum,
day,
mean_daily_cost
FROM
`billing_dataset_example.linear_regression_dataset`
WHERE account_name = 'DoIT'
AND YEAR < 2017 -- splitting by year ensures that we don't leak test data to training set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment