k-means-clusterer.h

Go to the documentation of this file.
00001 // Copyright 2007, Massachusetts Institute of Technology.
00002 // The use of this code is permitted for research only. There is
00003 // absolutely no warranty for this software.
00004 //
00005 // Author: John Lee (jjl@mit.edu)
00006 //
00007 
00008 #ifndef CLUSTERING_K_MEANS_CLUSTERER_H
00009 #define CLUSTERING_K_MEANS_CLUSTERER_H
00010 
00011 #include <vector>
00012 #include "clustering/clusterer.h"
00013 #include "point_set/point-ref.h"
00014 #include "util/distance-computer.h"
00015 
00016 using namespace std;
00017 
00018 namespace libpmk {
00020 
00037 class KMeansClusterer : public Clusterer {
00038  public:
00039    KMeansClusterer(int num_clusters, int max_iters,
00040                    const DistanceComputer& distance_computer);
00041 
00042  protected:
00044 
00052    virtual void DoClustering(const vector<PointRef>& data);
00053 
00054  private:
00055    int num_clusters_;
00056    int max_iterations_;
00057    const DistanceComputer& distance_computer_;
00058 
00059    void ComputeMembership(const vector<PointRef>& data);
00060 
00061    // Returns true if this call to ComputeMeans() has changed
00062    // cluster_centers_.
00063    bool ComputeMeans(const vector<PointRef>& data);
00064 };
00065 }  // namespace libpmk
00066 
00067 #endif  // CLUSTERING_K_MEANS_CLUSTERER_H
00068 

Generated on Wed May 2 11:17:12 2007 for libpmk by  doxygen 1.5.1