VTK  9.3.0
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
93 #ifndef vtkKMeansStatistics_h
94 #define vtkKMeansStatistics_h
95 
96 #include "vtkFiltersStatisticsModule.h" // For export macro
97 #include "vtkStatisticsAlgorithm.h"
98 
99 VTK_ABI_NAMESPACE_BEGIN
100 class vtkIdTypeArray;
101 class vtkIntArray;
102 class vtkDoubleArray;
105 
106 class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
107 {
108 public:
110  void PrintSelf(ostream& os, vtkIndent indent) override;
112 
114 
118  vtkGetObjectMacro(DistanceFunctor, vtkKMeansDistanceFunctor);
120 
122 
125  vtkSetMacro(DefaultNumberOfClusters, int);
126  vtkGetMacro(DefaultNumberOfClusters, int);
128 
130 
133  vtkSetStringMacro(KValuesArrayName);
134  vtkGetStringMacro(KValuesArrayName);
136 
138 
142  vtkSetMacro(MaxNumIterations, int);
143  vtkGetMacro(MaxNumIterations, int);
145 
147 
151  vtkSetMacro(Tolerance, double);
152  vtkGetMacro(Tolerance, double);
154 
160 
164  bool SetParameter(const char* parameter, int index, vtkVariant value) override;
165 
167 
177  vtkSetMacro(GhostsToSkip, unsigned char);
178  vtkGetMacro(GhostsToSkip, unsigned char);
180 
181 protected:
184 
186 
191 
195  void Derive(vtkMultiBlockDataSet*) override;
196 
201 
206 
210  void SelectAssessFunctor(vtkTable* inData, vtkDataObject* inMeta, vtkStringArray* rowNames,
211  AssessFunctor*& dfunc) override;
212 
218  virtual void UpdateClusterCenters(vtkTable* newClusterElements, vtkTable* curClusterElements,
219  vtkIdTypeArray* numMembershipChanges, vtkIdTypeArray* numDataElementsInCluster,
220  vtkDoubleArray* error, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID,
221  vtkIntArray* computeRun);
222 
229 
237  vtkTable* dataElements, vtkIdTypeArray* numberOfClusters, vtkTable* curClusterElements,
238  vtkTable* newClusterElements, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID);
239 
245  virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
246  vtkIdTypeArray* numberOfClusters, vtkTable* inData, vtkTable* curClusterElements,
247  vtkTable* newClusterElements);
248 
267  double Tolerance;
273 
278 
279  unsigned char GhostsToSkip;
280 
281 private:
282  vtkKMeansStatistics(const vtkKMeansStatistics&) = delete;
283  void operator=(const vtkKMeansStatistics&) = delete;
284 };
285 
286 VTK_ABI_NAMESPACE_END
287 #endif
maintain an unordered list of data objects
general representation of visualization data
Definition: vtkDataObject.h:64
dynamic, self-adjusting array of double
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:44
measure distance from k-means cluster centers
A class for KMeans clustering.
int MaxNumIterations
This is the maximum number of iterations allowed if the new cluster centers have not yet converged.
void SelectAssessFunctor(vtkTable *inData, vtkDataObject *inMeta, vtkStringArray *rowNames, AssessFunctor *&dfunc) override
Provide the appropriate assessment functor.
void Aggregate(vtkDataObjectCollection *, vtkMultiBlockDataSet *) override
Given a collection of models, calculate aggregate model NB: not implemented.
virtual void UpdateClusterCenters(vtkTable *newClusterElements, vtkTable *curClusterElements, vtkIdTypeArray *numMembershipChanges, vtkIdTypeArray *numDataElementsInCluster, vtkDoubleArray *error, vtkIdTypeArray *startRunID, vtkIdTypeArray *endRunID, vtkIntArray *computeRun)
Subroutine to update new cluster centers from the old centers.
char * KValuesArrayName
This is the name of the column that specifies the number of clusters in each run.
vtkIdType NumberOfGhosts
Number of ghosts in input data.
void Learn(vtkTable *, vtkTable *, vtkMultiBlockDataSet *) override
Execute the calculations required by the Learn option.
vtkKMeansDistanceFunctor * DistanceFunctor
This is the Distance functor.
bool SetParameter(const char *parameter, int index, vtkVariant value) override
A convenience method for setting properties by name.
virtual vtkIdType GetTotalNumberOfObservations(vtkIdType numObservations)
Subroutine to get the total number of observations.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int DefaultNumberOfClusters
This is the default number of clusters used when the user does not provide initial cluster centers.
void Derive(vtkMultiBlockDataSet *) override
Execute the calculations required by the Derive option.
void Assess(vtkTable *, vtkMultiBlockDataSet *, vtkTable *) override
Execute the calculations required by the Assess option.
int InitializeDataAndClusterCenters(vtkTable *inParameters, vtkTable *inData, vtkTable *dataElements, vtkIdTypeArray *numberOfClusters, vtkTable *curClusterElements, vtkTable *newClusterElements, vtkIdTypeArray *startRunID, vtkIdTypeArray *endRunID)
Subroutine to initialize the cluster centers using those provided by the user in input port LEARN_PAR...
virtual void CreateInitialClusterCenters(vtkIdType numToAllocate, vtkIdTypeArray *numberOfClusters, vtkTable *inData, vtkTable *curClusterElements, vtkTable *newClusterElements)
Subroutine to initialize cluster centerss if not provided by the user.
~vtkKMeansStatistics() override
static vtkKMeansStatistics * New()
double Tolerance
This is the percentage of data elements that swap cluster IDs.
void Test(vtkTable *, vtkMultiBlockDataSet *, vtkTable *) override
Execute the calculations required by the Test option.
virtual void SetDistanceFunctor(vtkKMeansDistanceFunctor *)
Set the DistanceFunctor.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
Composite dataset that organizes datasets into blocks.
A base class for a functor that assesses data.
Base class for statistics algorithms.
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
A type representing the union of many types.
Definition: vtkVariant.h:62
@ value
Definition: vtkX3D.h:220
@ parameter
Definition: vtkX3D.h:443
@ index
Definition: vtkX3D.h:246
int vtkIdType
Definition: vtkType.h:315