source: trunk/yat/regression/Local.h @ 767

Last change on this file since 767 was 767, checked in by Peter, 15 years ago

Fixes #65

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1#ifndef _theplu_yat_regression_local_
2#define _theplu_yat_regression_local_
3
4// $Id: Local.h 767 2007-02-22 15:14:40Z peter $
5
6/*
7  Copyright (C) The authors contributing to this file.
8
9  This file is part of the yat library, http://lev.thep.lu.se/trac/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 2 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 this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include "yat/utility/vector.h"
28
29#include <iostream>
30
31namespace theplu {
32namespace yat {
33namespace regression {
34
35  class Kernel;
36  class OneDimensionalWeighted;
37
38  ///
39  /// @brief Class for Locally weighted regression.
40  ///
41  /// Locally weighted regression is an algorithm for learning
42  /// continuous non-linear mappings in a non-parametric manner.  In
43  /// locally weighted regression, points are weighted by proximity to
44  /// the current x in question using a Kernel. A weighted regression
45  /// is then computed using the weighted points and a specific
46  /// Regression method. This procedure is repeated, which results in
47  /// a pointwise approximation of the underlying (unknown) function.
48  ///
49  class Local
50  {
51 
52  public:
53    ///
54    /// @brief Constructor taking type of \a regressor,
55    /// type of \a kernel.
56    ///
57    Local(OneDimensionalWeighted& r, Kernel& k);
58
59    ///
60    /// @brief The destructor
61    ///
62    virtual ~Local(void);
63
64    ///
65    /// adding a data point
66    ///
67    void add(const double x, const double y);
68
69    ///
70    /// @param nof_points Number of points used in each fit
71    /// @param step_size Size of step between each fit
72    ///
73    void fit(const size_t step_size, const size_t nof_points);
74
75    ///
76    /// @return x-values where fitting was performed.
77    ///
78    const utility::vector& x(void) const;
79
80    ///
81    /// Function returning predicted values
82    ///
83    const utility::vector& y_predicted(void) const;
84
85    ///
86    /// Function returning error of predictions
87    ///
88    const utility::vector& y_err(void) const;
89
90  private:
91    ///
92    /// Copy Constructor. (Not implemented)
93    ///
94    Local(const Local&);
95
96    std::vector<std::pair<double, double> > data_;
97    Kernel* kernel_;
98    OneDimensionalWeighted* regressor_;
99    utility::vector x_;
100    utility::vector y_predicted_; 
101    utility::vector y_err_; 
102  };
103
104  ///
105  /// The output operator for the Regression::Local class.
106  ///
107  std::ostream& operator<<(std::ostream&, const Local& );
108
109}}} // of namespaces regression, yat, and theplu
110
111#endif
Note: See TracBrowser for help on using the repository browser.