Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rbjerrum authored Sep 28, 2022
2 parents 07859b2 + 5d331f2 commit 52f1684
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,24 @@ 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
# detect_anomalies_model.sql
{{
config(
materialized='table'
)
}}
with eval_data as (
...
)
select * from {{ dbt_ml.detect_anomalies(ref('model'), 'eval_data', threshold) }}
```

### Tuning hyperparameters
Expand Down
7 changes: 7 additions & 0 deletions macros/detect_anomalies.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% macro detect_anomalies(relation, source, threshold = 0.95) %}
ml.detect_anomalies(
model {{ relation }},
struct({{ threshold }} as anomaly_prob_threshold),
(select * from {{ source }})
)
{% endmacro %}

0 comments on commit 52f1684

Please sign in to comment.