Created
July 3, 2019 07:14
-
-
Save myui/2a9bfa78002eba116c07623ec9f6afaf 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
WITH tmp1 as ( | |
select | |
userid, | |
array[ | |
probabilities[1], | |
probabilities[2], | |
probabilities[3], | |
probabilities[4], | |
probabilities[5], | |
probabilities[6], | |
probabilities[7], | |
probabilities[8] * 0.8 -- M3 | |
] as probabilities | |
from | |
rf_predicted_cv | |
), | |
tmp2 as ( | |
select | |
userid, | |
probabilities, | |
reduce( | |
probabilities, | |
CAST(ROW(-infinity(), 0, 0) AS ROW(max DOUBLE, index INTEGER, argmax INTEGER)), | |
(s, x) -> CAST(ROW(if(x > s.max, x, s.max), s.index + 1, if(x > s.max, s.index, s.argmax)) AS ROW(max DOUBLE, index INTEGER, argmax INTEGER)), | |
s -> s.argmax | |
) as label | |
from | |
tmp1 | |
) | |
select | |
l.userid, | |
l.probabilities, | |
r.label | |
from | |
tmp2 l | |
JOIN label_mapping r ON (l.label = r.label_id) | |
limit 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment