quick look at machine learning class cluster(object)def __init__(selfexamplesexampletype)"""assumes examples is list of example of type exampletype""self examples examples self exampletype exampletype self centroid self computecentroid(def update(selfexamples)"""replace the examples in the cluster by new examples return how much the centroid has changed""oldcentroid self centroid self examples examples if len(examples self centroid self computecentroid(return oldcentroid distance(self centroidelsereturn def members(self)for in self examplesyield def size(self)return len(self examplesdef getcentroid(self)return self centroid def computecentroid(self)dim self examples[ dimensionality(totvals pylab array([ ]*dimfor in self examplestotvals + getfeatures(centroid self exampletype('centroid'totvals/float(len(self examples))return centroid def variance(self)totdist for in self examplestotdist +( distance(self centroid))** return totdist** def __str__(self)names [for in self examplesnames append( getname()names sort(result 'cluster with centroid 'str(self centroid getfeatures()contains:\ for in namesresult result 'return result[:- figure class cluster