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 ) override;
119  static vtkKMeansStatistics* New();
120 
122 
125  virtual void SetDistanceFunctor( vtkKMeansDistanceFunctor* );
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* ) override { return; };
169 
173  bool SetParameter(
174  const char* parameter, int index, vtkVariant value ) override;
175 
176 protected:
178  ~vtkKMeansStatistics() override;
179 
183  void Learn( vtkTable*,
184  vtkTable*,
185  vtkMultiBlockDataSet* ) override;
186 
190  void Derive( vtkMultiBlockDataSet* ) override;
191 
195  void Assess( vtkTable*,
197  vtkTable* ) override;
198 
202  void Test( vtkTable*,
204  vtkTable* ) override { return; };
205 
209  void SelectAssessFunctor( vtkTable* inData,
210  vtkDataObject* inMeta,
211  vtkStringArray* rowNames,
212  AssessFunctor*& dfunc ) 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 
233  virtual vtkIdType GetTotalNumberOfObservations( vtkIdType numObservations );
234 
241  int InitializeDataAndClusterCenters(vtkTable* inParameters,
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& ) = delete;
286  void operator=( const vtkKMeansStatistics& ) = delete;
287 };
288 
289 #endif
vtkStatisticsAlgorithm.h
vtkX3D::value
Definition: vtkX3D.h:220
vtkKMeansStatistics::Aggregate
void Aggregate(vtkDataObjectCollection *, vtkMultiBlockDataSet *) override
Given a collection of models, calculate aggregate model NB: not implemented.
Definition: vtkKMeansStatistics.h:167
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkDataObjectCollection
maintain an unordered list of data objects
Definition: vtkDataObjectCollection.h:34
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
vtkKMeansDistanceFunctor
measure distance from k-means cluster centers
Definition: vtkKMeansDistanceFunctor.h:23
vtkKMeansStatistics::DefaultNumberOfClusters
int DefaultNumberOfClusters
This is the default number of clusters used when the user does not provide initial cluster centers.
Definition: vtkKMeansStatistics.h:265
vtkKMeansStatistics::Tolerance
double Tolerance
This is the percentage of data elements that swap cluster IDs.
Definition: vtkKMeansStatistics.h:278
vtkMultiBlockDataSet
Composite dataset that organizes datasets into blocks.
Definition: vtkMultiBlockDataSet.h:51
vtkKMeansStatistics::DistanceFunctor
vtkKMeansDistanceFunctor * DistanceFunctor
This is the Distance functor.
Definition: vtkKMeansStatistics.h:282
vtkKMeansStatistics::KValuesArrayName
char * KValuesArrayName
This is the name of the column that specifies the number of clusters in each run.
Definition: vtkKMeansStatistics.h:270
vtkKMeansStatistics::MaxNumIterations
int MaxNumIterations
This is the maximum number of iterations allowed if the new cluster centers have not yet converged.
Definition: vtkKMeansStatistics.h:274
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:71
vtkStatisticsAlgorithm::Learn
virtual void Learn(vtkTable *, vtkTable *, vtkMultiBlockDataSet *)=0
Execute the calculations required by the Learn option, given some input Data.
vtkStatisticsAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkStatisticsAlgorithm::SetParameter
virtual bool SetParameter(const char *parameter, int index, vtkVariant value)
A convenience method (in particular for access from other applications) to set parameter values of Le...
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:41
vtkStatisticsAlgorithm::Assess
virtual void Assess(vtkTable *, vtkMultiBlockDataSet *, vtkTable *)=0
Execute the calculations required by the Assess option.
vtkStatisticsAlgorithm::SelectAssessFunctor
virtual void SelectAssessFunctor(vtkTable *outData, vtkDataObject *inMeta, vtkStringArray *rowNames, AssessFunctor *&dfunc)=0
A pure virtual method to select the appropriate assessment functor.
vtkStatisticsAlgorithm::Derive
virtual void Derive(vtkMultiBlockDataSet *)=0
Execute the calculations required by the Derive option.
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:42
vtkKMeansStatistics
A class for KMeans clustering.
Definition: vtkKMeansStatistics.h:114
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:41
vtkStatisticsAlgorithm
Base class for statistics algorithms.
Definition: vtkStatisticsAlgorithm.h:77
vtkX3D::parameter
Definition: vtkX3D.h:443
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkKMeansStatistics::Test
void Test(vtkTable *, vtkMultiBlockDataSet *, vtkTable *) override
Execute the calculations required by the Test option.
Definition: vtkKMeansStatistics.h:202
vtkX3D::index
Definition: vtkX3D.h:246
vtkTableAlgorithm::New
static vtkTableAlgorithm * New()