yat  0.20.3pre
Perceptron.h
1 #ifndef theplu_yat_classifier_perceptron
2 #define theplu_yat_classifier_perceptron
3 
4 // $Id: Perceptron.h 4207 2022-08-26 04:36:28Z peter $
5 
6 /*
7  Copyright (C) 2017, 2021, 2022 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 
99  void train(const utility::MatrixBase& x, const Target& target);
100 
104  const utility::Vector& weight(void) const;
105  private:
106  utility::Vector weight_;
107  utility::Matrix covariance_;
108  double margin(size_t i, double alpha) const;
109  // using compiler generated copy
110  //Perceptron(const Perceptron&)
111  //Perceptron& operator=(const Perceptron&)
112  };
113 
114 
115 }}}// end of namespace classifier, yat, and theplu
116 #endif
Definition: MatrixBase.h:54
Class for containing sample labels.
Definition: Target.h:47
double oddsratio_lower_CI(size_t i, double alpha=0.05) const
The Department of Theoretical Physics namespace as we define it.
A Single-layer Perceptron.
Definition: Perceptron.h:41
double oddsratio(size_t i) const
This is the yat interface to GSL vector.
Definition: Vector.h:59
double oddsratio_upper_CI(size_t i, double alpha=0.05) const
This is the yat interface to GSL vector.
Definition: VectorBase.h:55
void train(const utility::MatrixBase &x, const Target &target)
train the model
double p_value(size_t i) const
Interface to GSL matrix.
Definition: Matrix.h:104
const utility::Vector & weight(void) const
double predict(const utility::VectorBase &x) const
const utility::Matrix & covariance(void) const

Generated on Sat Feb 18 2023 03:31:44 for yat by  doxygen 1.8.14