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 class vtkMultiBlockDataSet;
00110
00111 class VTK_INFOVIS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
00112 {
00113 public:
00114 vtkTypeMacro(vtkKMeansStatistics, vtkStatisticsAlgorithm);
00115 virtual void PrintSelf( ostream& os, vtkIndent indent );
00116 static vtkKMeansStatistics* New();
00117
00119
00120 virtual void SetDistanceFunctor( vtkKMeansDistanceFunctor* );
00121 vtkGetObjectMacro(DistanceFunctor,vtkKMeansDistanceFunctor);
00123
00125
00127 vtkSetMacro(DefaultNumberOfClusters, int);
00128 vtkGetMacro(DefaultNumberOfClusters, int);
00130
00132
00133 vtkSetStringMacro(KValuesArrayName);
00134 vtkGetStringMacro(KValuesArrayName);
00136
00138
00140 vtkSetMacro( MaxNumIterations, int );
00141 vtkGetMacro( MaxNumIterations, int );
00143
00145
00147 vtkSetMacro( Tolerance, double );
00148 vtkGetMacro( Tolerance, double );
00150
00152
00154 virtual void Aggregate( vtkDataObjectCollection*,
00155 vtkMultiBlockDataSet* ) { return; };
00157
00158
00160
00161 virtual bool SetParameter(
00162 const char* parameter, int index, vtkVariant value );
00163
00165
00166 protected:
00167 vtkKMeansStatistics();
00168 ~vtkKMeansStatistics();
00169
00171
00172 virtual void Learn( vtkTable* inData,
00173 vtkTable* inParameters,
00174 vtkMultiBlockDataSet* outMeta );
00176
00178 virtual void Derive( vtkMultiBlockDataSet* );
00179
00181
00182 virtual void Assess( vtkTable*,
00183 vtkMultiBlockDataSet*,
00184 vtkTable* );
00186
00188
00189 virtual void Test( vtkTable*,
00190 vtkMultiBlockDataSet*,
00191 vtkTable* ) { return; };
00193
00194
00196
00197 virtual void SelectAssessFunctor( vtkTable* inData,
00198 vtkDataObject* inMeta,
00199 vtkStringArray* rowNames,
00200 AssessFunctor*& dfunc );
00201
00202
00203
00204
00205
00206 virtual void UpdateClusterCenters( vtkTable* newClusterElements,
00207 vtkTable* curClusterElements,
00208 vtkIdTypeArray* numMembershipChanges,
00209 vtkIdTypeArray* numElementsInCluster,
00210 vtkDoubleArray* error,
00211 vtkIdTypeArray* startRunID,
00212 vtkIdTypeArray* endRunID,
00213 vtkIntArray *computeRun );
00215
00219 virtual vtkIdType GetTotalNumberOfObservations( vtkIdType numObservations );
00220
00222
00226 int InitializeDataAndClusterCenters(vtkTable* inParameters,
00227 vtkTable* inData,
00228 vtkTable* dataElements,
00229 vtkIdTypeArray* numberOfClusters,
00230 vtkTable* curClusterElements,
00231 vtkTable* newClusterElements,
00232 vtkIdTypeArray* startRunID,
00233 vtkIdTypeArray* endRunID);
00235
00237
00240 virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
00241 vtkIdTypeArray* numberOfClusters,
00242 vtkTable* inData,
00243 vtkTable* curClusterElements,
00244 vtkTable* newClusterElements);
00246
00247
00249
00251 int DefaultNumberOfClusters;
00252
00253
00254
00255 char* KValuesArrayName;
00256
00257
00258 int MaxNumIterations;
00259
00260
00261 double Tolerance;
00262
00263
00264 vtkKMeansDistanceFunctor* DistanceFunctor;
00266
00267 private:
00268 vtkKMeansStatistics( const vtkKMeansStatistics& );
00269 void operator=( const vtkKMeansStatistics& );
00270 };
00271
00272 #endif