def gen_comm_info(self,main_rdd):
def cominfo(tpl):
p=[]
for ((tx,lam),index) in tpl:
p.append(np.matrix(tx).T*lam)
return p
def findDim(tpl):
for ((tx,lam),index) in tpl:
d = len(tx)
return d
d = main_rdd.mapValues(findDim).values().reduce(lambda x,y:x)
c=main_rdd.flatMapValues(cominfo).map(lambda (key,value):value).reduce(lambda x,y:x+y)
V=matrix(0.0,(d,1))
for j in range(d):
V[j]=math.exp(-self.C*self.r[j]*c[j,0])
return d,V
评论列表
文章目录