VTK  9.3.1
vtkKMeansStatistics.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2010 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
84 #ifndef vtkKMeansStatistics_h
85 #define vtkKMeansStatistics_h
86 
87 #include "vtkFiltersStatisticsModule.h" // For export macro
88 #include "vtkStatisticsAlgorithm.h"
89 
90 VTK_ABI_NAMESPACE_BEGIN
91 class vtkIdTypeArray;
92 class vtkIntArray;
93 class vtkDoubleArray;
96 
97 class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
98 {
99 public:
101  void PrintSelf(ostream& os, vtkIndent indent) override;
102  static vtkKMeansStatistics* New();
103 
105 
108  virtual void SetDistanceFunctor(vtkKMeansDistanceFunctor*);
109  vtkGetObjectMacro(DistanceFunctor, vtkKMeansDistanceFunctor);
111 
113 
116  vtkSetMacro(DefaultNumberOfClusters, int);
117  vtkGetMacro(DefaultNumberOfClusters, int);
119 
121 
124  vtkSetStringMacro(KValuesArrayName);
125  vtkGetStringMacro(KValuesArrayName);
127 
129 
133  vtkSetMacro(MaxNumIterations, int);
134  vtkGetMacro(MaxNumIterations, int);
136 
138 
142  vtkSetMacro(Tolerance, double);
143  vtkGetMacro(Tolerance, double);
145 
151 
155  bool SetParameter(const char* parameter, int index, vtkVariant value) override;
156 
158 
168  vtkSetMacro(GhostsToSkip, unsigned char);
169  vtkGetMacro(GhostsToSkip, unsigned char);
171 
172 protected:
174  ~vtkKMeansStatistics() override;
175 
177 
181  void Learn(vtkTable*, vtkTable*, vtkMultiBlockDataSet*) override;
182 
186  void Derive(vtkMultiBlockDataSet*) override;
187 
191  void Assess(vtkTable*, vtkMultiBlockDataSet*, vtkTable*) override;
192 
197 
201  void SelectAssessFunctor(vtkTable* inData, vtkDataObject* inMeta, vtkStringArray* rowNames,
202  AssessFunctor*& dfunc) override;
203 
209  virtual void UpdateClusterCenters(vtkTable* newClusterElements, vtkTable* curClusterElements,
210  vtkIdTypeArray* numMembershipChanges, vtkIdTypeArray* numDataElementsInCluster,
211  vtkDoubleArray* error, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID,
212  vtkIntArray* computeRun);
213 
219  virtual vtkIdType GetTotalNumberOfObservations(vtkIdType numObservations);
220 
227  int InitializeDataAndClusterCenters(vtkTable* inParameters, vtkTable* inData,
228  vtkTable* dataElements, vtkIdTypeArray* numberOfClusters, vtkTable* curClusterElements,
229  vtkTable* newClusterElements, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID);
230 
236  virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
237  vtkIdTypeArray* numberOfClusters, vtkTable* inData, vtkTable* curClusterElements,
238  vtkTable* newClusterElements);
239 
258  double Tolerance;
264 
269 
270  unsigned char GhostsToSkip;
271 
272 private:
273  vtkKMeansStatistics(const vtkKMeansStatistics&) = delete;
274  void operator=(const vtkKMeansStatistics&) = delete;
275 };
276 
277 VTK_ABI_NAMESPACE_END
278 #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:315
A type representing the union of many types.
Definition: vtkVariant.h:52
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:34
double Tolerance
This is the percentage of data elements that swap cluster IDs.
a simple class to control print indentation
Definition: vtkIndent.h:28
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:58
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:54
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.