VTK  9.6.20260422
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
112
113#ifndef vtkKMeansStatistics_h
114#define vtkKMeansStatistics_h
115
116#include "vtkFiltersStatisticsModule.h" // For export macro
118
119VTK_ABI_NAMESPACE_BEGIN
120class vtkIdTypeArray;
121class vtkIntArray;
122class vtkDoubleArray;
125
126class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
127{
128public:
130 void PrintSelf(ostream& os, vtkIndent indent) override;
132
134
140
142
145 vtkSetMacro(DefaultNumberOfClusters, int);
146 vtkGetMacro(DefaultNumberOfClusters, int);
148
150
153 vtkSetStringMacro(KValuesArrayName);
154 vtkGetStringMacro(KValuesArrayName);
156
158
162 vtkSetMacro(MaxNumIterations, int);
163 vtkGetMacro(MaxNumIterations, int);
165
167
171 vtkSetMacro(Tolerance, double);
172 vtkGetMacro(Tolerance, double);
174
179 bool Aggregate(vtkDataObjectCollection*, vtkStatisticalModel*) override { return false; }
180
184 bool SetParameter(const char* parameter, int index, vtkVariant value) override;
185
187 void AppendAlgorithmParameters(std::string& algorithmParameters) const override;
188
191 vtkStringToken parameterName, const std::string& algorithmParameters) override;
192
193protected:
196
201
206
211
216
221 AssessFunctor*& dfunc) override;
222
228 virtual void UpdateClusterCenters(vtkTable* newClusterElements, vtkTable* curClusterElements,
229 vtkIdTypeArray* numMembershipChanges, vtkIdTypeArray* numDataElementsInCluster,
230 vtkDoubleArray* error, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID,
231 vtkIntArray* computeRun);
232
239
247 vtkTable* dataElements, vtkIdTypeArray* numberOfClusters, vtkTable* curClusterElements,
248 vtkTable* newClusterElements, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID);
249
255 virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
256 vtkIdTypeArray* numberOfClusters, vtkTable* inData, vtkTable* curClusterElements,
257 vtkTable* newClusterElements);
258
277 double Tolerance;
283
284private:
286 void operator=(const vtkKMeansStatistics&) = delete;
287};
288
289VTK_ABI_NAMESPACE_END
290#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:108
dynamic, self-adjusting array of int
measure distance from k-means cluster centers
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()
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.
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.
void AppendAlgorithmParameters(std::string &algorithmParameters) const override
Provide a string that can be used to recreate an instance of this algorithm.
virtual vtkIdType GetTotalNumberOfObservations(vtkIdType numObservations)
Subroutine to get the total number of observations.
std::size_t ConsumeNextAlgorithmParameter(vtkStringToken parameterName, const std::string &algorithmParameters) override
Implement the inverse of AppendAlgorithmParameters(): given parameters, update this algorithm.
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 Test(vtkTable *, vtkStatisticalModel *, vtkTable *) override
Execute the calculations required by the Test option.
void Derive(vtkStatisticalModel *) override
Execute the calculations required by the Derive 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 Assess(vtkTable *, vtkStatisticalModel *, vtkTable *) override
Execute the calculations required by the Assess option.
bool Aggregate(vtkDataObjectCollection *, vtkStatisticalModel *) override
Given a collection of models, calculate aggregate model NB: not implemented.
void Learn(vtkTable *, vtkTable *, vtkStatisticalModel *) override
Execute the calculations required by the Learn option.
virtual void SetDistanceFunctor(vtkKMeansDistanceFunctor *)
Set the DistanceFunctor.
a base class for statistical modeling of other data
A base class for a functor that assesses data.
vtkStatisticsAlgorithm()
Return a new instance of a subclass named and configured by the algorithmParameters.
a vtkAbstractArray subclass for strings
Represent a string by its integer hash.
A table, which contains similar-typed columns of data.
Definition vtkTable.h:169
A type representing the union of many types.
Definition vtkVariant.h:162
int vtkIdType
Definition vtkType.h:363