## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
apseyed
@apseyed
Hello
For the python course, I'm just trying to understand the reading of this line in "Learning without supervision":
return min(combinations(range(len(dm)), 2), key=lambda i: dm[i[0]][i1])
i understand combinations, but not the lambda expression and reference to dm[i[0] i1] . um what is substituted for i or is there a better way to think it through?
Folgert Karsdorp
@fbkarsdorp
so, basically the combinations part will return tuples of all indexes in one of the triangles of dm. The lambda expression uses these indexes to query the distance matrix dm. So, a possible i could be (0, 1), the we query the distance matrix on dm[i[0]][i[1]] = dm[0][1].
apseyed
@apseyed
given
distances = [[0, 1, 2, 3, 3, 2],
[1, 0, 1, 2, 4, 1],
[2, 1, 0, 3, 3, 0],
[3, 2, 3, 0, 2, 3],
[3, 4, 3, 2, 0, 3],
[2, 1, 0, 3, 3, 0]]
and that distances[(1,4)[0]] is [1, 0, 1, 2, 4, 1]
and print distances[(1,4)1] is [3, 4, 3, 2, 0, 3]
how do I get 4 from distances[(1,4)[0]][(1,4)1] ? and how does that assist finding the two rows with the shortest "distance" ?
distances[(1,4)[0]][(1,4)1] that is
distances[(1,4)[0]][(1,4)[1]]
apseyed
@apseyed
I think i see. of the expressions (1,4)[0] and (1,4)1 they refer to 1 and 4 resp., and so, it simply retrieves the distance value for that tuple, and returns the tuples with the minimum.
certainly is elegant
Folgert Karsdorp
@fbkarsdorp
exactly!
Dan Strong
@strongdan
@fbkarsdorp Got stuck after installing Anaconda on a Windows PC. Where do I find the start-windows.bat. file?