VTK
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  -------------------------------------------------------------------------*/
102 #ifndef vtkKMeansStatistics_h
103 #define vtkKMeansStatistics_h
104 
105 #include "vtkFiltersStatisticsModule.h" // For export macro
106 #include "vtkStatisticsAlgorithm.h"
107 
108 class vtkIdTypeArray;
109 class vtkIntArray;
110 class vtkDoubleArray;
113 
114 class VTKFILTERSSTATISTICS_EXPORT vtkKMeansStatistics : public vtkStatisticsAlgorithm
115 {
116 public:
118  void PrintSelf( ostream& os, vtkIndent indent ) VTK_OVERRIDE;
120 
122 
126  vtkGetObjectMacro(DistanceFunctor,vtkKMeansDistanceFunctor);
128 
130 
133  vtkSetMacro(DefaultNumberOfClusters, int);
134  vtkGetMacro(DefaultNumberOfClusters, int);
136 
138 
141  vtkSetStringMacro(KValuesArrayName);
142  vtkGetStringMacro(KValuesArrayName);
144 
146 
150  vtkSetMacro( MaxNumIterations, int );
151  vtkGetMacro( MaxNumIterations, int );
153 
155 
159  vtkSetMacro( Tolerance, double );
160  vtkGetMacro( Tolerance, double );
162 
168  vtkMultiBlockDataSet* ) VTK_OVERRIDE { return; };
169 
174  const char* parameter, int index, vtkVariant value ) VTK_OVERRIDE;
175 
176 protected:
178  ~vtkKMeansStatistics() VTK_OVERRIDE;
179 
183  void Learn( vtkTable*,
184  vtkTable*,
185  vtkMultiBlockDataSet* ) VTK_OVERRIDE;
186 
190  void Derive( vtkMultiBlockDataSet* ) VTK_OVERRIDE;
191 
195  void Assess( vtkTable*,
197  vtkTable* ) VTK_OVERRIDE;
198 
202  void Test( vtkTable*,
204  vtkTable* ) VTK_OVERRIDE { return; };
205 
210  vtkDataObject* inMeta,
211  vtkStringArray* rowNames,
212  AssessFunctor*& dfunc ) VTK_OVERRIDE;
213 
219  virtual void UpdateClusterCenters( vtkTable* newClusterElements,
220  vtkTable* curClusterElements,
221  vtkIdTypeArray* numMembershipChanges,
222  vtkIdTypeArray* numElementsInCluster,
223  vtkDoubleArray* error,
224  vtkIdTypeArray* startRunID,
225  vtkIdTypeArray* endRunID,
226  vtkIntArray *computeRun );
227 
234 
242  vtkTable* inData,
243  vtkTable* dataElements,
244  vtkIdTypeArray* numberOfClusters,
245  vtkTable* curClusterElements,
246  vtkTable* newClusterElements,
247  vtkIdTypeArray* startRunID,
248  vtkIdTypeArray* endRunID);
249 
255  virtual void CreateInitialClusterCenters(vtkIdType numToAllocate,
256  vtkIdTypeArray* numberOfClusters,
257  vtkTable* inData,
258  vtkTable* curClusterElements,
259  vtkTable* newClusterElements);
260 
261 
278  double Tolerance;
283 
284 private:
285  vtkKMeansStatistics( const vtkKMeansStatistics& ) VTK_DELETE_FUNCTION;
286  void operator=( const vtkKMeansStatistics& ) VTK_DELETE_FUNCTION;
287 };
288 
289 #endif
Tests instantiations of the vtkNew class template.
maintain an unordered list of data objects
general representation of visualization data
Definition: vtkDataObject.h:65
dynamic, self-adjusting array of double
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:40
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:46
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.
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.
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.
virtual void UpdateClusterCenters(vtkTable *newClusterElements, vtkTable *curClusterElements, vtkIdTypeArray *numMembershipChanges, vtkIdTypeArray *numElementsInCluster, vtkDoubleArray *error, vtkIdTypeArray *startRunID, vtkIdTypeArray *endRunID, vtkIntArray *computeRun)
Subroutine to update new cluster centers from the old centers.
int InitializeDataAndClusterCenters(vtkTable *inParameters, vtkTable *inData, vtkTable *dataElements, vtkIdTypeArray *numberOfClusters, vtkTable *curClusterElements, vtkTable *newClusterElements, vtkIdTypeArray *startRunID, vtkIdTypeArray *endRunID)
Subroutine to initalize the cluster centers using those provided by the user in input port LEARN_PARA...
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.
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:69
A atomic type representing the union of many types.
Definition: vtkVariant.h:76
@ value
Definition: vtkX3D.h:220
@ parameter
Definition: vtkX3D.h:443
@ index
Definition: vtkX3D.h:246
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
int vtkIdType
Definition: vtkType.h:287