VTK  9.2.6
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  -------------------------------------------------------------------------*/
100 #ifndef vtkKMeansStatistics_h
101 #define vtkKMeansStatistics_h
102 
103 #include "vtkFiltersStatisticsModule.h" // For export macro
104 #include "vtkStatisticsAlgorithm.h"
105 
106 class vtkIdTypeArray;
107 class vtkIntArray;
108 class vtkDoubleArray;
111 
112 class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
113 {
114 public:
116  void PrintSelf(ostream& os, vtkIndent indent) override;
117  static vtkKMeansStatistics* New();
118 
120 
123  virtual void SetDistanceFunctor(vtkKMeansDistanceFunctor*);
124  vtkGetObjectMacro(DistanceFunctor, vtkKMeansDistanceFunctor);
126 
128 
131  vtkSetMacro(DefaultNumberOfClusters, int);
132  vtkGetMacro(DefaultNumberOfClusters, int);
134 
136 
139  vtkSetStringMacro(KValuesArrayName);
140  vtkGetStringMacro(KValuesArrayName);
142 
144 
148  vtkSetMacro(MaxNumIterations, int);
149  vtkGetMacro(MaxNumIterations, int);
151 
153 
157  vtkSetMacro(Tolerance, double);
158  vtkGetMacro(Tolerance, double);
160 
166 
170  bool SetParameter(const char* parameter, int index, vtkVariant value) override;
171 
173 
183  vtkSetMacro(GhostsToSkip, unsigned char);
184  vtkGetMacro(GhostsToSkip, unsigned char);
186 
187 protected:
189  ~vtkKMeansStatistics() override;
190 
192 
196  void Learn(vtkTable*, vtkTable*, vtkMultiBlockDataSet*) override;
197 
201  void Derive(vtkMultiBlockDataSet*) override;
202 
206  void Assess(vtkTable*, vtkMultiBlockDataSet*, vtkTable*) override;
207 
211  void Test(vtkTable*, vtkMultiBlockDataSet*, vtkTable*) override { return; }
212 
216  void SelectAssessFunctor(vtkTable* inData, vtkDataObject* inMeta, vtkStringArray* rowNames,
217  AssessFunctor*& dfunc) override;
218 
224  virtual void UpdateClusterCenters(vtkTable* newClusterElements, vtkTable* curClusterElements,
225  vtkIdTypeArray* numMembershipChanges, vtkIdTypeArray* numDataElementsInCluster,
226  vtkDoubleArray* error, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID,
227  vtkIntArray* computeRun);
228 
234  virtual vtkIdType GetTotalNumberOfObservations(vtkIdType numObservations);
235 
242  int InitializeDataAndClusterCenters(vtkTable* inParameters, vtkTable* inData,
243  vtkTable* dataElements, vtkIdTypeArray* numberOfClusters, vtkTable* curClusterElements,
244  vtkTable* newClusterElements, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID);
245 
251  virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
252  vtkIdTypeArray* numberOfClusters, vtkTable* inData, vtkTable* curClusterElements,
253  vtkTable* newClusterElements);
254 
273  double Tolerance;
279 
284 
285  unsigned char GhostsToSkip;
286 
287 private:
288  vtkKMeansStatistics(const vtkKMeansStatistics&) = delete;
289  void operator=(const vtkKMeansStatistics&) = delete;
290 };
291 
292 #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()
Store vtkAlgorithm input/output information.
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:332
A atomic type representing the union of many types.
Definition: vtkVariant.h:69
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:45
double Tolerance
This is the percentage of data elements that swap cluster IDs.
a simple class to control print indentation
Definition: vtkIndent.h:39
A class for KMeans clustering.
virtual void Learn(vtkTable *, vtkTable *, vtkMultiBlockDataSet *)=0
Execute the calculations required by the Learn option, given some input Data.
vtkIdType NumberOfGhosts
Number of ghosts in 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:73
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.
Store zero or more vtkInformation instances.
general representation of visualization data
Definition: vtkDataObject.h:65
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.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.