Message Boards Message Boards

GROUPS:

Customize DistanceFunction in FindClusters[ ]?

Posted 5 months ago
444 Views
|
0 Replies
|
0 Total Likes
|

The example data is as follows:

data = RandomInteger[{0, 50}, {50, 4}];

I have defined a distance function myself (as shown below), but the response cannot be computed (FindClusters::wrgdist: The distance function dist cannot be computed on the data. ); how should I modify it?

dist[{x1_, x2_, x3_, x4_}, {y1_, y2_, y3_, y4_}] := 
  N@Norm[#] &@
       Flatten@{Abs@(If[#[[2]] != 0, #[[1]]/#[[2]], 
            10000@#[[1]]]), #[[3]]} &@{Differences[{#[[1, 1]], #[[2, 
          1]]}], Differences[{#[[1, 2]], #[[2, 2]]}], #[[2, 
        1]]} &@{{x3, x4}, {y3, y4}};

FindClusters[data, 2, DistanceFunction -> dist]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract