Created
October 25, 2019 22:52
-
-
Save netskink/a96d639b174f133390c9de00f179a1e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TEMP FUNCTION | |
my_corr(x FLOAT64, y FLOAT64) | |
RETURNS FLOAT64 | |
AS ( | |
(x*y) | |
); | |
WITH | |
cte1 (feat, colname, bc) AS ( | |
SELECT col1, 'col1', bc | |
FROM tbl UNION | |
SELECT col2, 'col2', | |
bc FROM table_one ... for all columns | |
), | |
table_one AS ( | |
SELECT 0.123 feat_1, 0.645 feat_2 , 1.0 label_bc, 'a' dontcare UNION ALL | |
SELECT 0.567, 0.456, 0.0, 'b' UNION ALL | |
SELECT 0.243, 0.734, 1.0, 'c' UNION ALL | |
SELECT 0.456, 0.888, 0.0, 'i' UNION ALL | |
SELECT 0.645, 0.222, 1.0, 'j' UNION ALL | |
SELECT 0.321, 0.123, 0.0, 'c' | |
) | |
--SELECT colname, corr(feat, bc) FROM cte1; | |
select * from table_one | |
--select *, my_corr(label_bc, feat_1) as correlation from table_one | |
--select corr(label_bc, feat_1) as feat1_corr, corr(label_bc, feat_2) as feat2_corr from table_one | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment