VTK
vtkKMeansStatistics.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkKMeansStatistics.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2010 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19  -------------------------------------------------------------------------*/
96 #ifndef vtkKMeansStatistics_h
97 #define vtkKMeansStatistics_h
98 
99 #include "vtkFiltersStatisticsModule.h" // For export macro
100 #include "vtkStatisticsAlgorithm.h"
101 
102 class vtkIdTypeArray;
103 class vtkIntArray;
104 class vtkDoubleArray;
107 
108 class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
109 {
110 public:
112  void PrintSelf( ostream& os, vtkIndent indent ) override;
113  static vtkKMeansStatistics* New();
114 
116 
119  virtual void SetDistanceFunctor( vtkKMeansDistanceFunctor* );
120  vtkGetObjectMacro(DistanceFunctor,vtkKMeansDistanceFunctor);
122 
124 
127  vtkSetMacro(DefaultNumberOfClusters, int);
128  vtkGetMacro(DefaultNumberOfClusters, int);
130 
132 
135  vtkSetStringMacro(KValuesArrayName);
136  vtkGetStringMacro(KValuesArrayName);
138 
140 
144  vtkSetMacro( MaxNumIterations, int );
145  vtkGetMacro( MaxNumIterations, int );
147 
149 
153  vtkSetMacro( Tolerance, double );
154  vtkGetMacro( Tolerance, double );
156 
162  vtkMultiBlockDataSet* ) override { return; };
163 
167  bool SetParameter(
168  const char* parameter, int index, vtkVariant value ) override;
169 
170 protected:
172  ~vtkKMeansStatistics() override;
173 
177  void Learn( vtkTable*,
178  vtkTable*,
179  vtkMultiBlockDataSet* ) override;
180 
184  void Derive( vtkMultiBlockDataSet* ) override;
185 
189  void Assess( vtkTable*,
191  vtkTable* ) override;
192 
196  void Test( vtkTable*,
198  vtkTable* ) override { return; };
199 
203  void SelectAssessFunctor( vtkTable* inData,
204  vtkDataObject* inMeta,
205  vtkStringArray* rowNames,
206  AssessFunctor*& dfunc ) override;
207 
213  virtual void UpdateClusterCenters( vtkTable* newClusterElements,
214  vtkTable* curClusterElements,
215  vtkIdTypeArray* numMembershipChanges,
216  vtkIdTypeArray* numElementsInCluster,
217  vtkDoubleArray* error,
218  vtkIdTypeArray* startRunID,
219  vtkIdTypeArray* endRunID,
220  vtkIntArray *computeRun );
221 
227  virtual vtkIdType GetTotalNumberOfObservations( vtkIdType numObservations );
228 
235  int InitializeDataAndClusterCenters(vtkTable* inParameters,
236  vtkTable* inData,
237  vtkTable* dataElements,
238  vtkIdTypeArray* numberOfClusters,
239  vtkTable* curClusterElements,
240  vtkTable* newClusterElements,
241  vtkIdTypeArray* startRunID,
242  vtkIdTypeArray* endRunID);
243 
249  virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
250  vtkIdTypeArray* numberOfClusters,
251  vtkTable* inData,
252  vtkTable* curClusterElements,
253  vtkTable* newClusterElements);
254 
255 
272  double Tolerance;
277 
278 private:
279  vtkKMeansStatistics( const vtkKMeansStatistics& ) = delete;
280  void operator=( const vtkKMeansStatistics& ) = delete;
281 };
282 
283 #endif
virtual void Assess(vtkTable *, vtkMultiBlockDataSet *, vtkTable *)=0
Execute the calculations required by the Assess option.
int MaxNumIterations
This is the maximum number of iterations allowed if the new cluster centers have not yet converged.
static vtkTableAlgorithm * New()
maintain an unordered list of data objects
vtkKMeansDistanceFunctor * DistanceFunctor
This is the Distance functor.
int DefaultNumberOfClusters
This is the default number of clusters used when the user does not provide initial cluster centers.
char * KValuesArrayName
This is the name of the column that specifies the number of clusters in each run.
a vtkAbstractArray subclass for strings
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
A atomic type representing the union of many types.
Definition: vtkVariant.h:65
dynamic, self-adjusting array of double
void Test(vtkTable *, vtkMultiBlockDataSet *, vtkTable *) override
Execute the calculations required by the Test option.
Base class for statistics algorithms.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
double Tolerance
This is the percentage of data elements that swap cluster IDs.
a simple class to control print indentation
Definition: vtkIndent.h:33
A class for KMeans clustering.
virtual void Learn(vtkTable *, vtkTable *, vtkMultiBlockDataSet *)=0
Execute the calculations required by the Learn option, given some input Data.
virtual void Derive(vtkMultiBlockDataSet *)=0
Execute the calculations required by the Derive option.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
virtual bool SetParameter(const char *parameter, int index, vtkVariant value)
A convenience method (in particular for access from other applications) to set parameter values of Le...
void Aggregate(vtkDataObjectCollection *, vtkMultiBlockDataSet *) override
Given a collection of models, calculate aggregate model NB: not implemented.
Composite dataset that organizes datasets into blocks.
virtual void SelectAssessFunctor(vtkTable *outData, vtkDataObject *inMeta, vtkStringArray *rowNames, AssessFunctor *&dfunc)=0
A pure virtual method to select the appropriate assessment functor.
general representation of visualization data
Definition: vtkDataObject.h:58
measure distance from k-means cluster centers
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.