source: trunk/yat/classifier/SupervisedClassifier.h @ 1176

Last change on this file since 1176 was 1176, checked in by Markus Ringnér, 14 years ago

Working on #75

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 3.5 KB
Line 
1#ifndef _theplu_yat_classifier_supervisedclassifier_
2#define _theplu_yat_classifier_supervisedclassifier_
3
4// $Id$
5
6/*
7  Copyright (C) 2005 Markus Ringnér
8  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson
9  Copyright (C) 2007 Peter Johansson
10
11  This file is part of the yat library, http://trac.thep.lu.se/yat
12
13  The yat library is free software; you can redistribute it and/or
14  modify it under the terms of the GNU General Public License as
15  published by the Free Software Foundation; either version 2 of the
16  License, or (at your option) any later version.
17
18  The yat library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  General Public License for more details.
22
23  You should have received a copy of the GNU General Public License
24  along with this program; if not, write to the Free Software
25  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26  02111-1307, USA.
27*/
28
29#include <stddef.h>
30
31namespace theplu {
32namespace yat {
33
34  namespace utility {
35    class Matrix;
36  }
37
38namespace classifier { 
39
40  class MatrixLookup;
41  class MatrixLookupWeighted;
42  class Target;
43
44  ///
45  /// @brief Interface class for supervised classifiers that use data
46  /// in a matrix format with data points as columns and each row
47  /// corresponding to a variable for the data points. Supervised
48  /// classifiers that do not use data in this format include
49  /// kernel-based classifiers such as SVM.
50  ///
51  class SupervisedClassifier
52  {
53   
54  public:
55    ///
56    /// @brief Constructor
57    ///
58    SupervisedClassifier(void);
59   
60
61    ///
62    /// @brief Destructor
63    ///
64    virtual ~SupervisedClassifier(void);
65
66
67    ///
68    /// An interface for making new %classifier objects. This function
69    /// allows for specification at run-time of which %classifier type
70    /// to instatiate (see 'Prototype' in Design Patterns). Derived
71    /// classes should implement this function with DerivedClass* as
72    /// the return type and not SupervisedClassifier*, and a
73    /// dynamically allocated %classifier should be returned. The
74    /// implementation of this function should correspond to a copy
75    /// constructor with the exception that the returned %classifier
76    /// is not trained.
77    ///
78    /// @note Returns a dynamically allocated %classifier, which has
79    /// to be deleted by the caller to avoid memory leaks.
80    ///
81    virtual SupervisedClassifier* 
82    make_classifier() const =0;
83   
84
85
86    ///
87    /// Generate output values for a data set
88    ///
89    virtual void predict(const MatrixLookup&, utility::Matrix&) const =0;   
90
91    ///
92    /// Generate output values for a weighted data set
93    ///
94    virtual void predict(const MatrixLookupWeighted&, utility::Matrix&) const =0;   
95
96
97    ///
98    /// Train the %classifier using unweighted training data and
99    /// targets. The training data \a data should have one column per
100    /// training sample and one row for each variable measured for the
101    /// training samples. The size of \a target should be the number
102    /// of samples in \a data and \a target should contain the class
103    /// for each sample ordered in the same order as columns in \a data.
104    ///
105    virtual void train(const MatrixLookup& data, const Target& targets)=0;
106
107    ///
108    /// Train the %classifier using weighted training data and
109    /// targets. Both \a data and \a targets should follow the
110    /// description for train(const MatrixLookup& data, const Target& targets)
111    ///
112    virtual void train(const MatrixLookupWeighted& data, const Target& targets)=0;
113
114  }; 
115 
116}}} // of namespace classifier, yat, and theplu
117
118#endif
Note: See TracBrowser for help on using the repository browser.