# Demo entry 2790895

**similarity**

Submitted by **anonymous**
on Oct 01, 2015 at 01:20

Language: Python. Code size: 772 Bytes.

def compute_similarity_mp(self, home, num_proc): pool = mp.Pool(num_proc) unnormalized_factors = [pool.apply(self.compute_factors, (home, other)) for other in self.homes] # Compute the normalization constant for each factor. normal_const = [] for idx, n in enumerate(NORMALIZATION): if n: normal_const.append(1 / max(unnormalized_factors, key=itemgetter(idx))[idx]) else: normal_const.append(1) # Compute the final similarity for all homes. similarity = [] for idx, fac in enumerate(unnormalized_factors): similarity.append((idx, sum([a*b*c for a,b,c in zip(WEIGHT, normal_const, fac)]))) return similarity

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.