Group Abstract Group Abstract

Message Boards Message Boards

Avoid problem using a custom distance function in ClusteringTree?

Posted 9 years ago
POSTED BY: Carlos Muñoz
4 Replies

That's because of this I think:

EuclideanDistance[1, 2]
HammingDistance[1, 2]

the first one gives a number, while the second doesn't... So in order to fix it you have to put data in a certain format:

ClusteringTree[{1, 2, 5}, DistanceFunction -> EuclideanDistance]
ClusteringTree[{{1}, {2}, {5}}, DistanceFunction -> HammingDistance]
POSTED BY: Sander Huisman

Last update:

I just realized I was using the wrong set of data, haha.

If it helps to explain, in case anyone has a similar problem, I was using sequences of different lengths when my custom function only worked with sequences of equal lengths.

POSTED BY: Carlos Muñoz
Update:

The results I got were a bit odd, and I though it was because of my distance function, but when I checked my distance function with the data in a different format it gave me always a distance of 0.

POSTED BY: Carlos Muñoz

Thanks! My data was an association with strings as values, so I transformed them into lists with one element, as in your example, and it worked.

POSTED BY: Carlos Muñoz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard