Skip to content

Commit

Permalink
Merge pull request kristeligt-dagblad#36 from BrianLz/master
Browse files Browse the repository at this point in the history
Add BQML recommend feature for Recommender Systems workflows
  • Loading branch information
rbjerrum authored Sep 28, 2022
2 parents 5d331f2 + 52f1684 commit 83ae218
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ with eval_data as (
select * from {{ dbt_ml.predict(ref('model'), 'eval_data') }}
```

If you're using a BQML **matrix_factorization** model, you can use the recommend macro in the same way.
```sql
# downstream_model.sql
with predict_features AS (
...
)
select * from {{ dbt_ml.recommend(ref('model'), 'predict_features') }}
```

The ML.DETECT_ANOMALIES function provides anomaly detection for BigQuery ML.

```sql
Expand Down
10 changes: 10 additions & 0 deletions macros/recommend.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% macro recommend(relation, source, threshold = none) %}
ml.recommend(
model {{ relation }},
(select * from {{ source }})

{%- if threshold is not none -%}
, struct({{ threshold }} as threshold)
{%- endif -%}
)
{% endmacro %}

0 comments on commit 83ae218

Please sign in to comment.