yat  0.16.4pre
Perceptron.h
1 #ifndef theplu_yat_classifier_perceptron
2 #define theplu_yat_classifier_perceptron
3 
4 // $Id: Perceptron.h 3709 2017-11-08 22:49:06Z peter $
5 
6 /*
7  Copyright (C) 2017 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include <yat/utility/Matrix.h>
26 #include <yat/utility/Vector.h>
27 
28 namespace theplu {
29 namespace yat {
30 namespace classifier {
31 
32  class Target;
33 
41  class Perceptron
42  {
43  public:
52  const utility::Matrix& covariance(void) const;
53 
57  double oddsratio(size_t i) const;
58 
65  double oddsratio_lower_CI(size_t i, double alpha=0.05) const;
66 
73  double oddsratio_upper_CI(size_t i, double alpha=0.05) const;
74 
78  double p_value(size_t i) const;
79 
83  double predict(const utility::VectorBase& x) const;
84 
93  void train(const utility::Matrix& x, const Target& target);
94 
98  const utility::Vector& weight(void) const;
99  private:
100  utility::Vector weight_;
101  utility::Matrix covariance_;
102  double margin(size_t i, double alpha) const;
103  // using compiler generated copy
104  //Perceptron(const Perceptron&)
105  //Perceptron& operator=(const Perceptron&)
106  };
107 
108 
109 }}}// end of namespace classifier, yat, and theplu
110 #endif
Class for containing sample labels.
Definition: Target.h:47
The Department of Theoretical Physics namespace as we define it.
A Single-layer Perceptron.
Definition: Perceptron.h:41
const utility::Matrix & covariance(void) const
const utility::Vector & weight(void) const
This is the yat interface to GSL vector.
Definition: Vector.h:59
double oddsratio(size_t i) const
double oddsratio_upper_CI(size_t i, double alpha=0.05) const
This is the yat interface to GSL vector.
Definition: VectorBase.h:55
double p_value(size_t i) const
void train(const utility::Matrix &x, const Target &target)
train the model
Interface to GSL matrix.
Definition: Matrix.h:74
double predict(const utility::VectorBase &x) const
double oddsratio_lower_CI(size_t i, double alpha=0.05) const

Generated on Thu Dec 12 2019 03:12:08 for yat by  doxygen 1.8.11