For 02/03 lecture, I'm not sure why we need to have this second line in euclidean function? Thank you.
def euclidean(x1: Dict[str, float], x2: Dict[str, float]) -> float:
t = sum(((s1 - x2.get(term, 0)) 2 for term, s1 in x1.items()))
t += sum((s2 2 for term, s2 in x2.items() if term not in x1))
return t
For 02/03 lecture, I'm not sure why we need to have this second line in euclidean function? Thank you.
def euclidean(x1: Dict[str, float], x2: Dict[str, float]) -> float: t = sum(((s1 - x2.get(term, 0)) 2 for term, s1 in x1.items())) t += sum((s2 2 for term, s2 in x2.items() if term not in x1)) return t