VTK  9.1.0
vtkKMeansStatistics.h
Go to the documentation of this file.
1/*=========================================================================
2
3Program: Visualization Toolkit
4Module: vtkKMeansStatistics.h
5
6Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7All rights reserved.
8See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10This software is distributed WITHOUT ANY WARRANTY; without even
11the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12PURPOSE. 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 -------------------------------------------------------------------------*/
106#ifndef vtkKMeansStatistics_h
107#define vtkKMeansStatistics_h
108
109#include "vtkFiltersStatisticsModule.h" // For export macro
111
112class vtkIdTypeArray;
113class vtkIntArray;
114class vtkDoubleArray;
117
118class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
119{
120public:
122 void PrintSelf(ostream& os, vtkIndent indent) override;
124
126
130 vtkGetObjectMacro(DistanceFunctor, vtkKMeansDistanceFunctor);
132
134
137 vtkSetMacro(DefaultNumberOfClusters, int);
138 vtkGetMacro(DefaultNumberOfClusters, int);
140
142
145 vtkSetStringMacro(KValuesArrayName);
146 vtkGetStringMacro(KValuesArrayName);
148
150
154 vtkSetMacro(MaxNumIterations, int);
155 vtkGetMacro(MaxNumIterations, int);
157
159
163 vtkSetMacro(Tolerance, double);
164 vtkGetMacro(Tolerance, double);
166
172
176 bool SetParameter(const char* parameter, int index, vtkVariant value) override;
177
178protected:
181
186
191
196
200 void Test(vtkTable*, vtkMultiBlockDataSet*, vtkTable*) override { return; }
201
206 AssessFunctor*& dfunc) override;
207
213 virtual void UpdateClusterCenters(vtkTable* newClusterElements, vtkTable* curClusterElements,
214 vtkIdTypeArray* numMembershipChanges, vtkIdTypeArray* numDataElementsInCluster,
215 vtkDoubleArray* error, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID,
216 vtkIntArray* computeRun);
217
224
232 vtkTable* dataElements, vtkIdTypeArray* numberOfClusters, vtkTable* curClusterElements,
233 vtkTable* newClusterElements, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID);
234
240 virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
241 vtkIdTypeArray* numberOfClusters, vtkTable* inData, vtkTable* curClusterElements,
242 vtkTable* newClusterElements);
243
262 double Tolerance;
268
269private:
271 void operator=(const vtkKMeansStatistics&) = delete;
272};
273
274#endif
maintain an unordered list of data objects
general representation of visualization data
Definition: vtkDataObject.h:69
dynamic, self-adjusting array of double
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:43
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:49
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.
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.
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:72
A atomic type representing the union of many types.
Definition: vtkVariant.h:75
@ value
Definition: vtkX3D.h:226
@ parameter
Definition: vtkX3D.h:449
@ index
Definition: vtkX3D.h:252
int vtkIdType
Definition: vtkType.h:332