Last active
August 14, 2019 06:33
-
-
Save myui/7e54590c7d048002a4fd5a67e7c148ad 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
SELECT | |
-- conversion for libsvm format | |
label || ' ' || array_join(array_sort( | |
feature_hashing(features), | |
(x, y) -> if(cast(substr(x, 1, strpos(x, ':') - 1) as bigint) < cast(substr(y, 1, strpos(y, ':') - 1) as bigint), | |
-1, | |
if(substr(x, 1, strpos(x, ':') - 1) = substr(y, 1, strpos(y, ':') - 1), 0, 1) | |
) | |
), ' ') as line | |
from | |
input |
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
SELECT | |
-- conversion for libsvm format | |
array_sort(features, | |
(x, y) -> if(cast(substr(x, 1, strpos(x, ':') - 1) as double) < cast(substr(y, 1, strpos(y, ':') - 1) as double), | |
-1, | |
if(substr(x, 1, strpos(x, ':') - 1) = substr(y, 1, strpos(y, ':') - 1), 0, 1) | |
) | |
) as features, | |
label | |
from | |
rf_input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sed -e 's/\"//g' -e 's/\[//' -e 's/\]//' 487600901.tsv | awk '{print $2,$1}' | sed -e 's/,/ /g' > 487600901.libsvm