Last active
June 20, 2019 10:41
-
-
Save afranzi/c08eec19bda799f67976402c20aafe3d 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
def personality_udf(personality_mapping: dict): | |
@udf(returnType=IntegerType()) | |
def inner(cat): | |
return personality_mapping.get(cat, -1) | |
return inner | |
def compute_gvector_udf(personality_mapping: dict): | |
@udf(returnType=ArrayType(DoubleType())) | |
def inner(ngvector, cgvector, suma): | |
result = [0.] * len(personality_mapping) | |
for i in range(len(ngvector)): | |
result[ngvector[i]] = cgvector[i] / suma | |
return result | |
return inner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment