Re: Fw: Clustering::Distance.php

From: Date: Mon, 12 Aug 2002 22:42:37 +0000
Subject: Re: Fw: Clustering::Distance.php
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-8336@lists.php.net to get a copy of this message
Nice class Alfredo. --- alfredo <yo@alfredorahn.com> wrote: > Hi! (again) > Here's some code i've coded for measuring distances and similarities, a basic > step in clustering of data (thanks Jesus). > Not all clustering methods are working (???) but I'm working on it :-) > > Distance.php: A library for distance measuring. It includes a pear class, > Clus_Distance which implements diverse methods > as internal functions. I have tought about reasons not to make a parent class > and derive child classes for each method, but > please feel free to make any comments that you think might help to PEARIZE > this code w/o harming efficience. The code looks OK to me (on a very quick glance). The advantage of having on monolitical Distance class is that you can calculate different metrics on the same data set. The disadvantage could be in the addition of more metrics/similarity indeces. At the moment I would go for your solution, if and when things get too complicated, then the class can be changed to use a factory method. > example1.php: A simple example that reads from data file, and shows > similarity matrices (upper triangular) for each method. > > swiss.txt: Some sample data. The last column is the class number of each > item, as outputed from a k-means > implementation (not in php), so we'll be living on R^6 and comparing these to > ours. > > please review it, and make any comments you like!! I can suggest some names for the class, because those metrics are generalized distances, which can be used for clustering or other purposes: Math_DistanceMetric or Math_Cluster_Distance or Math_Distance Then the Math_Cluster class(es) can use the Math_Cluster)_Distance (or Math_DistanceMetric) object(s) BTW, there are several metrics I did not know, but found this on Google: http://geochange.er.usgs.gov/pub/tools/analog/doc/distance.html http://fconyx.ncifcrf.gov/~lukeb/clusdis.html There are other simple metrics for vectors, which might not need to be there, but that I might add as a utility class for Math_Vector: City block distance (aka Manhattan distance) and Chessboard Distance. City dist = |x1 - x2| + |y1 - y2| + ... Chessboard dist. = max(|x1 - x2|, |y1 - y2|, ...) > > Alfredo > http://alfredorahn.com > > > ATTACHMENT part 2 application/x-zip-compressed name=Distance.zip > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com

« previous php.pear.dev (#8336) next »