Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snippets for xai bqml and looker post #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

slopp
Copy link

@slopp slopp commented Jan 24, 2022

Adding snippets from the XAI + BQML + Looker 1/24/2021 blogpost

(3)] as float64))))) AS card_transactions_transaction_distance,

--hour that transaction occured: fraud occurs in middle of night (usually between midnight and 4 am)
EXTRACT(HOUR FROM TIMESTAMP(CONCAT(card_transactions.trans_date,' ',card_transactions.trans_time)) ) AS card_transactions_transaction_hour_of_day
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is perhaps too long. Could you try using the || operator to concat, and/or break this line into multiple lines?
|| operator: https://cloud.google.com/bigquery/docs/reference/standard-sql/operators

@@ -0,0 +1,21 @@
SELECT * FROM
ML.EXPLAIN_PREDICT(MODEL retail_banking.fraud_prediction, (
SELECT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be helpful to add a comment as to what kind of transaction each of these are ... e.g. "a sample datapoint with an unusually high transaction amount"

--distance from the customers home: further distances are more likely to be fraud
ST_DISTANCE((ST_GEOGPOINT((cast(card_transactions.merchant_lon as FLOAT64)),
(cast(card_transactions.merchant_lat as FLOAT64)))),
(ST_GeogPoint((cast(SPLIT(client.address,'|')[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ST_GeogPoint seems to use camelcase unexpectedly -- perhaps all caps would be better?

@polong-lin
Copy link
Member

Looking good overall.

  1. Could you add in a README to your directory, similar to this?

  2. Could you rename the directory to:
    /finance/xai-fraud/bqml-looker/

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants