Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drwnFisherLDA.h
1 /******************************************************************************
2 ** DARWIN: A FRAMEWORK FOR MACHINE LEARNING RESEARCH AND DEVELOPMENT
3 ** Distributed under the terms of the BSD license (see the LICENSE file)
4 ** Copyright (c) 2007-2015, Stephen Gould
5 ** All rights reserved.
6 **
7 ******************************************************************************
8 ** FILENAME: drwnFisherLDA.h
9 ** AUTHOR(S): Stephen Gould <stephen.gould@anu.edu.au>
10 **
11 *****************************************************************************/
12 
13 #pragma once
14 
15 #include <vector>
16 #include <limits>
17 
18 #include "Eigen/Core"
19 
20 #include "drwnBase.h"
21 #include "drwnFeatureTransform.h"
22 #include "drwnSuffStats.h"
23 
24 using namespace std;
25 using namespace Eigen;
26 
27 // drwnFisherLDA class --------------------------------------------------------
51 
53  private:
54  VectorXd _translation;
55  MatrixXd _projection;
56 
57  public:
59  drwnFisherLDA();
61  drwnFisherLDA(const drwnFisherLDA& lda);
62  ~drwnFisherLDA();
63 
64  // access functions
65  const char *type() const { return "drwnFisherLDA"; }
66  drwnFisherLDA *clone() const { return new drwnFisherLDA(*this); }
67 
68  // i/o
69  void clear();
70  bool save(drwnXMLNode& node) const;
71  bool load(drwnXMLNode& node);
72 
73  // input/output size
75  int numInputs() const { return _projection.cols(); }
77  int numOutputs() const { return _projection.rows(); }
78 
79  // training
83  double train(const drwnCondSuffStats& stats);
84  double train(const vector<vector<double> >& features, const vector<int>& labels);
85  double train(const vector<vector<double> >& features,
86  const vector<int>& labels, const vector<double>& weights);
87  double train(const vector<vector<double> >& features, const vector<int>& labels,
88  const drwnFeatureTransform& xform);
89  double train(const vector<vector<double> >& features, const vector<int>& labels,
90  const vector<double>& weights, const drwnFeatureTransform& xform);
91 
92  // evaluation
94  void transform(const vector<double>& x, vector<double>& y) const;
95 };
Implements a class for accumulating conditional first- and second-order sufficient statistics...
Definition: drwnSuffStats.h:150
virtual double train(const vector< vector< double > > &features, const vector< int > &labels)=0
Estimate the parameters of the features transformation. This function must be implemented in the deri...
Implements the interface for a generic feature transforms possibly with learned parameters, e.g., PCA (unsupervised) or LDA (supervised).
Definition: drwnFeatureTransform.h:31
virtual void transform(vector< double > &x) const
transforms a feature vector in-place
Definition: drwnFeatureTransform.cpp:57
int numOutputs() const
feature vector size for the output space
Definition: drwnFisherLDA.h:77
drwnFisherLDA * clone() const
returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); } ...
Definition: drwnFisherLDA.h:66
Fisher's linear discriminant analysis (LDA).
Definition: drwnFisherLDA.h:52
int numInputs() const
feature vector size for the input space
Definition: drwnFisherLDA.h:75
Implements interface for supervised feature transforms (i.e., with class labels). ...
Definition: drwnFeatureTransform.h:158
const char * type() const
returns object type as a string (e.g., Foo::type() { return "Foo"; })
Definition: drwnFisherLDA.h:65