Message Boards Message Boards

0
|
2516 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Customize DistanceFunction in FindClusters[ ]?

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]
POSTED BY: Tsai Ming-Chou
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