00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00100 #ifndef __vtkKMeansStatistics_h
00101 #define __vtkKMeansStatistics_h
00102
00103 #include "vtkStatisticsAlgorithm.h"
00104
00105 class vtkIdTypeArray;
00106 class vtkIntArray;
00107 class vtkDoubleArray;
00108 class vtkKMeansDistanceFunctor;
00109
00110 class VTK_INFOVIS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
00111 {
00112 public:
00113 vtkTypeMacro(vtkKMeansStatistics, vtkStatisticsAlgorithm);
00114 virtual void PrintSelf( ostream& os, vtkIndent indent );
00115 static vtkKMeansStatistics* New();
00116
00118
00119 virtual void SetDistanceFunctor( vtkKMeansDistanceFunctor* );
00120 vtkGetObjectMacro(DistanceFunctor,vtkKMeansDistanceFunctor);
00122
00124
00126 vtkSetMacro(DefaultNumberOfClusters, int);
00127 vtkGetMacro(DefaultNumberOfClusters, int);
00129
00131
00132 vtkSetStringMacro(KValuesArrayName);
00133 vtkGetStringMacro(KValuesArrayName);
00135
00137
00139 vtkSetMacro( MaxNumIterations, int );
00140 vtkGetMacro( MaxNumIterations, int );
00142
00144
00146 vtkSetMacro( Tolerance, double );
00147 vtkGetMacro( Tolerance, double );
00149
00151
00153 virtual void Aggregate( vtkDataObjectCollection*,
00154 vtkDataObject* ) { return; };
00156
00157 protected:
00158 vtkKMeansStatistics();
00159 ~vtkKMeansStatistics();
00160
00162
00165 virtual int FillOutputPortInformation( int port, vtkInformation* info );
00166 virtual int FillInputPortInformation( int port, vtkInformation* info );
00168
00170
00171 virtual void Learn( vtkTable* inData,
00172 vtkTable* inParameters,
00173 vtkDataObject* outMeta );
00175
00177 virtual void Derive( vtkDataObject* );
00178
00180
00181 virtual void Assess( vtkTable*,
00182 vtkDataObject*,
00183 vtkTable* );
00185
00187
00188 virtual void Test( vtkTable*,
00189 vtkDataObject*,
00190 vtkDataObject* ) { return; };
00192
00193
00195
00196 virtual void SelectAssessFunctor( vtkTable* inData,
00197 vtkDataObject* inMeta,
00198 vtkStringArray* rowNames,
00199 AssessFunctor*& dfunc );
00200
00201
00202
00203
00204
00205 virtual void UpdateClusterCenters( vtkTable* newClusterElements,
00206 vtkTable* curClusterElements,
00207 vtkIdTypeArray* numMembershipChanges,
00208 vtkIdTypeArray* numElementsInCluster,
00209 vtkDoubleArray* error,
00210 vtkIdTypeArray* startRunID,
00211 vtkIdTypeArray* endRunID,
00212 vtkIntArray *computeRun );
00214
00218 virtual vtkIdType GetTotalNumberOfObservations( vtkIdType numObservations );
00219
00221
00225 int InitializeDataAndClusterCenters(vtkTable* inParameters,
00226 vtkTable* inData,
00227 vtkTable* dataElements,
00228 vtkIdTypeArray* numberOfClusters,
00229 vtkTable* curClusterElements,
00230 vtkTable* newClusterElements,
00231 vtkIdTypeArray* startRunID,
00232 vtkIdTypeArray* endRunID);
00234
00236
00239 virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
00240 vtkIdTypeArray* numberOfClusters,
00241 vtkTable* inData,
00242 vtkTable* curClusterElements,
00243 vtkTable* newClusterElements);
00245
00246
00248
00250 int DefaultNumberOfClusters;
00251
00252
00253
00254 char* KValuesArrayName;
00255
00256
00257 int MaxNumIterations;
00258
00259
00260 double Tolerance;
00261
00262
00263 vtkKMeansDistanceFunctor* DistanceFunctor;
00265
00266 private:
00267 vtkKMeansStatistics( const vtkKMeansStatistics& );
00268 void operator=( const vtkKMeansStatistics& );
00269 };
00270
00271 #endif