VTK  9.1.0
vtkKMeansStatistics.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkKMeansStatistics.h
5 
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. 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  -------------------------------------------------------------------------*/
126 #ifndef vtkKMeansStatistics_h
127 #define vtkKMeansStatistics_h
128 
129 #include "vtkFiltersStatisticsModule.h" // For export macro
130 #include "vtkStatisticsAlgorithm.h"
131 
132 class vtkIdTypeArray;
133 class vtkIntArray;
134 class vtkDoubleArray;
137 
138 class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
139 {
140 public:
142  void PrintSelf(ostream& os, vtkIndent indent) override;
144 
146 
150  vtkGetObjectMacro(DistanceFunctor, vtkKMeansDistanceFunctor);
152 
154 
157  vtkSetMacro(DefaultNumberOfClusters, int);
158  vtkGetMacro(DefaultNumberOfClusters, int);
160 
162 
165  vtkSetStringMacro(KValuesArrayName);
166  vtkGetStringMacro(KValuesArrayName);
168 
170 
174  vtkSetMacro(MaxNumIterations, int);
175  vtkGetMacro(MaxNumIterations, int);
177 
179 
183  vtkSetMacro(Tolerance, double);
184  vtkGetMacro(Tolerance, double);
186 
192 
196  bool SetParameter(const char* parameter, int index, vtkVariant value) override;
197 
198 protected:
201 
206 
210  void Derive(vtkMultiBlockDataSet*) override;
211 
216 
220  void Test(vtkTable*, vtkMultiBlockDataSet*, vtkTable*) override { return; }
221 
225  void SelectAssessFunctor(vtkTable* inData, vtkDataObject* inMeta, vtkStringArray* rowNames,
226  AssessFunctor*& dfunc) override;
227 
233  virtual void UpdateClusterCenters(vtkTable* newClusterElements, vtkTable* curClusterElements,
234  vtkIdTypeArray* numMembershipChanges, vtkIdTypeArray* numDataElementsInCluster,
235  vtkDoubleArray* error, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID,
236  vtkIntArray* computeRun);
237 
244 
252  vtkTable* dataElements, vtkIdTypeArray* numberOfClusters, vtkTable* curClusterElements,
253  vtkTable* newClusterElements, vtkIdTypeArray* startRunID, vtkIdTypeArray* endRunID);
254 
260  virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
261  vtkIdTypeArray* numberOfClusters, vtkTable* inData, vtkTable* curClusterElements,
262  vtkTable* newClusterElements);
263 
282  double Tolerance;
288 
289 private:
290  vtkKMeansStatistics(const vtkKMeansStatistics&) = delete;
291  void operator=(const vtkKMeansStatistics&) = delete;
292 };
293 
294 #endif
vtkKMeansStatistics::Derive
void Derive(vtkMultiBlockDataSet *) override
Execute the calculations required by the Derive option.
vtkStatisticsAlgorithm.h
vtkKMeansStatistics::UpdateClusterCenters
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.
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkKMeansStatistics::Aggregate
void Aggregate(vtkDataObjectCollection *, vtkMultiBlockDataSet *) override
Given a collection of models, calculate aggregate model NB: not implemented.
Definition: vtkKMeansStatistics.h:191
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkDataObjectCollection
maintain an unordered list of data objects
Definition: vtkDataObjectCollection.h:32
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:172
vtkKMeansStatistics::CreateInitialClusterCenters
virtual void CreateInitialClusterCenters(vtkIdType numToAllocate, vtkIdTypeArray *numberOfClusters, vtkTable *inData, vtkTable *curClusterElements, vtkTable *newClusterElements)
Subroutine to initialize cluster centerss if not provided by the user.
vtkKMeansDistanceFunctor
measure distance from k-means cluster centers
Definition: vtkKMeansDistanceFunctor.h:24
vtkKMeansStatistics::DefaultNumberOfClusters
int DefaultNumberOfClusters
This is the default number of clusters used when the user does not provide initial cluster centers.
Definition: vtkKMeansStatistics.h:268
vtkKMeansStatistics::Tolerance
double Tolerance
This is the percentage of data elements that swap cluster IDs.
Definition: vtkKMeansStatistics.h:282
vtkStatisticsAlgorithm::AssessFunctor
A base class for a functor that assesses data.
Definition: vtkStatisticsAlgorithm.h:205
vtkMultiBlockDataSet
Composite dataset that organizes datasets into blocks.
Definition: vtkMultiBlockDataSet.h:155
vtkKMeansStatistics::InitializeDataAndClusterCenters
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...
vtkKMeansStatistics::Learn
void Learn(vtkTable *, vtkTable *, vtkMultiBlockDataSet *) override
Execute the calculations required by the Learn option.
vtkKMeansStatistics::~vtkKMeansStatistics
~vtkKMeansStatistics() override
vtkKMeansStatistics::New
static vtkKMeansStatistics * New()
vtkKMeansStatistics::vtkKMeansStatistics
vtkKMeansStatistics()
vtkKMeansStatistics::SetDistanceFunctor
virtual void SetDistanceFunctor(vtkKMeansDistanceFunctor *)
Set the DistanceFunctor.
vtkKMeansStatistics::SelectAssessFunctor
void SelectAssessFunctor(vtkTable *inData, vtkDataObject *inMeta, vtkStringArray *rowNames, AssessFunctor *&dfunc) override
Provide the appropriate assessment functor.
vtkKMeansStatistics::DistanceFunctor
vtkKMeansDistanceFunctor * DistanceFunctor
This is the Distance functor.
Definition: vtkKMeansStatistics.h:287
vtkKMeansStatistics::KValuesArrayName
char * KValuesArrayName
This is the name of the column that specifies the number of clusters in each run.
Definition: vtkKMeansStatistics.h:273
vtkKMeansStatistics::MaxNumIterations
int MaxNumIterations
This is the maximum number of iterations allowed if the new cluster centers have not yet converged.
Definition: vtkKMeansStatistics.h:278
vtkKMeansStatistics::GetTotalNumberOfObservations
virtual vtkIdType GetTotalNumberOfObservations(vtkIdType numObservations)
Subroutine to get the total number of observations.
vtkKMeansStatistics::SetParameter
bool SetParameter(const char *parameter, int index, vtkVariant value) override
A convenience method for setting properties by name.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:149
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:155
vtkKMeansStatistics::Assess
void Assess(vtkTable *, vtkMultiBlockDataSet *, vtkTable *) override
Execute the calculations required by the Assess option.
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:145
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:146
vtkKMeansStatistics
A class for KMeans clustering.
Definition: vtkKMeansStatistics.h:139
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:145
vtkKMeansStatistics::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkStatisticsAlgorithm
Base class for statistics algorithms.
Definition: vtkStatisticsAlgorithm.h:91
vtkX3D::parameter
@ parameter
Definition: vtkX3D.h:449
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:169
vtkKMeansStatistics::Test
void Test(vtkTable *, vtkMultiBlockDataSet *, vtkTable *) override
Execute the calculations required by the Test option.
Definition: vtkKMeansStatistics.h:220
vtkX3D::index
@ index
Definition: vtkX3D.h:252