Skip to content

Commit 2cb1a47

Browse files
committed
adding minor refactors
1 parent 61f26c7 commit 2cb1a47

File tree

4 files changed

+73
-50
lines changed

4 files changed

+73
-50
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#standardSQL
2+
--demo baseline model
3+
CREATE
4+
OR REPLACE MODEL `<model_dataset>.<model_name>` OPTIONS(
5+
model_type = "LOGISTIC_REG",
6+
data_split_method = "AUTO_SPLIT",
7+
input_label_cols = ["will_buy_later"],
8+
enable_global_explain = TRUE,
9+
auto_class_weights = TRUE
10+
) AS
11+
SELECT
12+
bounces,
13+
time_on_site,
14+
page_views,
15+
source,
16+
medium,
17+
channel_grouping,
18+
is_mobile,
19+
add_to_cart,
20+
product_detail_view,
21+
will_buy_later
22+
FROM
23+
`<curated_dataset>.<table_name>_ready_for_ml`
24+
WHERE
25+
split_col = 'training';
26+
27+
-- evaluate model
28+
SELECT
29+
*
30+
FROM
31+
ML.EVALUATE(MODEL `<model_dataset>.<model_name>`,
32+
(
33+
SELECT
34+
bounces,
35+
time_on_site,
36+
page_views,
37+
SOURCE,
38+
medium,
39+
channel_grouping,
40+
is_mobile,
41+
add_to_cart,
42+
product_detail_view,
43+
will_buy_later
44+
FROM
45+
`<curated_dataset>.<table_name>_ready_for_ml`
46+
WHERE
47+
split_col = 'validation'),
48+
STRUCT(0.5 AS threshold));
49+
50+
-- predict results
51+
SELECT
52+
*
53+
FROM
54+
ML.PREDICT(
55+
MODEL `<model_dataset>.<model_name>`,
56+
(
57+
SELECT
58+
bounces,
59+
time_on_site,
60+
page_views,
61+
source,
62+
medium,
63+
channel_grouping,
64+
is_mobile,
65+
add_to_cart,
66+
product_detail_view,
67+
will_buy_later
68+
FROM
69+
`<curated_dataset>.<table_name>_ready_for_ml`
70+
WHERE
71+
split_col = 'test'
72+
), STRUCT(0.5 AS threshold)
73+
);

sql/create_and_evaluate_model.sql

Lines changed: 0 additions & 50 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)