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
84#ifndef vtkKMeansStatistics_h
85#define vtkKMeansStatistics_h
86
87#include "vtkFiltersStatisticsModule.h" // For export macro
89
90VTK_ABI_NAMESPACE_BEGIN
91class vtkIdTypeArray;
92class vtkIntArray;
93class vtkDoubleArray;
96
97class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
98{
99public:
101 void PrintSelf(ostream& os, vtkIndent indent) override;
103
105
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
172protected:
175
177
182
187
192
197
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
220
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
272private:
274 void operator=(const vtkKMeansStatistics&) = delete;
275};
276
277VTK_ABI_NAMESPACE_END
278#endif
maintain an unordered list of data objects
general representation of visualization data
dynamic, self-adjusting array of double
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition vtkIntArray.h:35
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.
static vtkKMeansStatistics * New()
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
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:59
A type representing the union of many types.
Definition vtkVariant.h:53
int vtkIdType
Definition vtkType.h:315