Skip to content

Instantly share code, notes, and snippets.

@gidutz
Created Aug 13, 2018
Embed
What would you like to do?
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