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

Last change on this file since 1450 was 1450, checked in by Peter, 13 years ago

adding reset function in regression::Local

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1#ifndef _theplu_yat_regression_local_
2#define _theplu_yat_regression_local_
3
4// $Id: Local.h 1450 2008-08-28 20:28:09Z peter $
5
6/*
7  Copyright (C) 2004 Peter Johansson
8  Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2008 Peter Johansson
10
11  This file is part of the yat library, http://dev.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 "yat/utility/Vector.h"
30
31#include <iostream>
32
33namespace theplu {
34namespace yat {
35namespace regression {
36
37  class Kernel;
38  class OneDimensionalWeighted;
39
40  ///
41  /// @brief Class for Locally weighted regression.
42  ///
43  /// Locally weighted regression is an algorithm for learning
44  /// continuous non-linear mappings in a non-parametric manner.  In
45  /// locally weighted regression, points are weighted by proximity to
46  /// the current x in question using a Kernel. A weighted regression
47  /// is then computed using the weighted points and a specific
48  /// Regression method. This procedure is repeated, which results in
49  /// a pointwise approximation of the underlying (unknown) function.
50  ///
51  class Local
52  {
53 
54  public:
55    ///
56    /// @brief Constructor taking type of \a regressor,
57    /// type of \a kernel.
58    ///
59    Local(OneDimensionalWeighted& r, Kernel& k);
60
61    ///
62    /// @brief The destructor
63    ///
64    virtual ~Local(void);
65
66    ///
67    /// adding a data point
68    ///
69    void add(const double x, const double y);
70
71    ///
72    /// @param step_size Size of step between each fit
73    /// @param nof_points Number of points used in each fit
74    ///
75    void fit(const size_t step_size, const size_t nof_points);
76
77    /**
78       \brief Set everything to zero
79
80       \since New in yat 0.5
81     */
82    void reset(void);
83
84    ///
85    /// @return x-values where fitting was performed.
86    ///
87    const utility::Vector& x(void) const;
88
89    ///
90    /// Function returning predicted values
91    ///
92    const utility::Vector& y_predicted(void) const;
93
94    ///
95    /// Function returning error of predictions
96    ///
97    const utility::Vector& y_err(void) const;
98
99  private:
100    ///
101    /// Copy Constructor. (Not implemented)
102    ///
103    Local(const Local&);
104
105    std::vector<std::pair<double, double> > data_;
106    Kernel* kernel_;
107    OneDimensionalWeighted* regressor_;
108    utility::Vector x_;
109    utility::Vector y_predicted_; 
110    utility::Vector y_err_; 
111  };
112
113  ///
114  /// The output operator for the Regression::Local class.
115  ///
116  std::ostream& operator<<(std::ostream&, const Local& );
117
118}}} // of namespaces regression, yat, and theplu
119
120#endif
Note: See TracBrowser for help on using the repository browser.