Statismo  0.10.1
 All Classes Namespaces Functions Typedefs
ModelBuilder.h
1 /*
2  * This file is part of the statismo library.
3  *
4  * Author: Marcel Luethi (marcel.luethi@unibas.ch)
5  *
6  * Copyright (c) 2011 University of Basel
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  *
20  * Neither the name of the project's author nor the names of its
21  * contributors may be used to endorse or promote products derived from
22  * this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef __MODELBUILDER_H_
39 #define __MODELBUILDER_H_
40 
41 #include <vector>
42 #include <memory>
43 
44 #include "CommonTypes.h"
45 #include "DataManager.h"
46 #include "StatisticalModel.h"
47 
48 namespace statismo {
49 
53 template <typename T>
54 class ModelBuilder {
55 
56  public:
57  typedef Representer<T> RepresenterType;
60  typedef typename DataManagerType::DataItemListType DataItemListType;
61 
62  // Values below this tolerance are treated as 0.
63  static const double TOLERANCE;
64 
65 
66  protected:
67 
68  MatrixType ComputeScores(const MatrixType& X, const StatisticalModelType* model) const {
69 
70  MatrixType scores(model->GetNumberOfPrincipalComponents(), X.rows());
71  for (unsigned i = 0; i < scores.cols(); i++) {
72  scores.col(i) = model->ComputeCoefficientsForSampleVector(X.row(i));
73  }
74  return scores;
75  }
76 
77 
78  ModelBuilder() {}
79 
80  ModelInfo CollectModelInfo() const;
81 
82  private:
83  // private - to prevent use
84  ModelBuilder(const ModelBuilder& orig);
85  ModelBuilder& operator=(const ModelBuilder& rhs);
86 
87 };
88 
89 template <class Representer>
90 const double ModelBuilder<Representer>::TOLERANCE = 1e-5;
91 
92 } // namespace statismo
93 
94 
95 #endif /* __MODELBUILDER_H_ */
Common base class for all the model builder classes.
Definition: ModelBuilder.h:54
Manages Training and Test Data for building Statistical Models and provides functionality for Crossva...
Definition: DataManager.h:114
VectorType ComputeCoefficientsForSampleVector(const VectorType &sample) const
Definition: StatisticalModel.hxx:283
stores meta information about the model, such as e.g. the name (uri) of the datasets used to build th...
Definition: ModelInfo.h:61
unsigned int GetNumberOfPrincipalComponents() const
Definition: StatisticalModel.hxx:501
A Point/Value pair that is used to specify a value at a given point.
Definition: StatisticalModel.h:100