yat/regression/Local.h

Code
Comments
Other
Rev Date Author Line
681 11 Oct 06 jari 1 #ifndef _theplu_yat_regression_local_
681 11 Oct 06 jari 2 #define _theplu_yat_regression_local_
202 01 Nov 04 peter 3
616 31 Aug 06 jari 4 // $Id$
616 31 Aug 06 jari 5
675 10 Oct 06 jari 6 /*
831 27 Mar 07 peter 7   Copyright (C) 2004 Peter Johansson
4359 23 Aug 23 peter 8   Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
4359 23 Aug 23 peter 9   Copyright (C) 2007 Peter Johansson
4359 23 Aug 23 peter 10   Copyright (C) 2008 Jari Häkkinen, Peter Johansson
4359 23 Aug 23 peter 11   Copyright (C) 2009, 2010, 2011 Peter Johansson
202 01 Nov 04 peter 12
1437 25 Aug 08 peter 13   This file is part of the yat library, http://dev.thep.lu.se/yat
675 10 Oct 06 jari 14
675 10 Oct 06 jari 15   The yat library is free software; you can redistribute it and/or
675 10 Oct 06 jari 16   modify it under the terms of the GNU General Public License as
1486 09 Sep 08 jari 17   published by the Free Software Foundation; either version 3 of the
675 10 Oct 06 jari 18   License, or (at your option) any later version.
675 10 Oct 06 jari 19
675 10 Oct 06 jari 20   The yat library is distributed in the hope that it will be useful,
675 10 Oct 06 jari 21   but WITHOUT ANY WARRANTY; without even the implied warranty of
675 10 Oct 06 jari 22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
675 10 Oct 06 jari 23   General Public License for more details.
675 10 Oct 06 jari 24
675 10 Oct 06 jari 25   You should have received a copy of the GNU General Public License
1487 10 Sep 08 jari 26   along with yat. If not, see <http://www.gnu.org/licenses/>.
675 10 Oct 06 jari 27 */
675 10 Oct 06 jari 28
1120 21 Feb 08 peter 29 #include "yat/utility/Vector.h"
675 10 Oct 06 jari 30
2532 31 Jul 11 peter 31 #include <iosfwd>
202 01 Nov 04 peter 32
202 01 Nov 04 peter 33 namespace theplu {
680 11 Oct 06 jari 34 namespace yat {
383 12 Aug 05 jari 35 namespace regression {
383 12 Aug 05 jari 36
747 11 Feb 07 peter 37   class Kernel;
747 11 Feb 07 peter 38   class OneDimensionalWeighted;
747 11 Feb 07 peter 39
202 01 Nov 04 peter 40   ///
4200 19 Aug 22 peter 41   /// @brief Class for Locally weighted regression.
202 01 Nov 04 peter 42   ///
280 20 Apr 05 peter 43   /// Locally weighted regression is an algorithm for learning
280 20 Apr 05 peter 44   /// continuous non-linear mappings in a non-parametric manner.  In
280 20 Apr 05 peter 45   /// locally weighted regression, points are weighted by proximity to
346 08 Jun 05 peter 46   /// the current x in question using a Kernel. A weighted regression
346 08 Jun 05 peter 47   /// is then computed using the weighted points and a specific
346 08 Jun 05 peter 48   /// Regression method. This procedure is repeated, which results in
346 08 Jun 05 peter 49   /// a pointwise approximation of the underlying (unknown) function.
280 20 Apr 05 peter 50   ///
383 12 Aug 05 jari 51   class Local
202 01 Nov 04 peter 52   {
4200 19 Aug 22 peter 53
202 01 Nov 04 peter 54   public:
202 01 Nov 04 peter 55     ///
703 18 Dec 06 jari 56     /// @brief Constructor taking type of \a regressor,
235 21 Feb 05 peter 57     /// type of \a kernel.
202 01 Nov 04 peter 58     ///
703 18 Dec 06 jari 59     Local(OneDimensionalWeighted& r, Kernel& k);
202 01 Nov 04 peter 60
202 01 Nov 04 peter 61     ///
4200 19 Aug 22 peter 62     /// @brief The destructor
202 01 Nov 04 peter 63     ///
703 18 Dec 06 jari 64     virtual ~Local(void);
206 02 Nov 04 peter 65
221 30 Dec 04 peter 66     ///
235 21 Feb 05 peter 67     /// adding a data point
235 21 Feb 05 peter 68     ///
718 26 Dec 06 jari 69     void add(const double x, const double y);
235 21 Feb 05 peter 70
235 21 Feb 05 peter 71     ///
1437 25 Aug 08 peter 72     /// @param step_size Size of step between each fit
718 26 Dec 06 jari 73     /// @param nof_points Number of points used in each fit
221 30 Dec 04 peter 74     ///
2210 05 Mar 10 peter 75     /// \throw utility::runtime_error if step_size is 0, nof_points is
1473 03 Sep 08 peter 76     /// less than 3, or step_size is larger than number of added data
1473 03 Sep 08 peter 77     /// points.
718 26 Dec 06 jari 78     void fit(const size_t step_size, const size_t nof_points);
221 30 Dec 04 peter 79
1450 28 Aug 08 peter 80     /**
1450 28 Aug 08 peter 81        \brief Set everything to zero
1450 28 Aug 08 peter 82
1450 28 Aug 08 peter 83        \since New in yat 0.5
1450 28 Aug 08 peter 84      */
1450 28 Aug 08 peter 85     void reset(void);
1450 28 Aug 08 peter 86
221 30 Dec 04 peter 87     ///
718 26 Dec 06 jari 88     /// @return x-values where fitting was performed.
221 30 Dec 04 peter 89     ///
1120 21 Feb 08 peter 90     const utility::Vector& x(void) const;
718 26 Dec 06 jari 91
216 29 Dec 04 peter 92     ///
718 26 Dec 06 jari 93     /// Function returning predicted values
216 29 Dec 04 peter 94     ///
1120 21 Feb 08 peter 95     const utility::Vector& y_predicted(void) const;
235 21 Feb 05 peter 96
430 08 Dec 05 peter 97     ///
718 26 Dec 06 jari 98     /// Function returning error of predictions
430 08 Dec 05 peter 99     ///
1120 21 Feb 08 peter 100     const utility::Vector& y_err(void) const;
235 21 Feb 05 peter 101
216 29 Dec 04 peter 102   private:
383 12 Aug 05 jari 103     ///
383 12 Aug 05 jari 104     /// Copy Constructor. (Not implemented)
383 12 Aug 05 jari 105     ///
383 12 Aug 05 jari 106     Local(const Local&);
383 12 Aug 05 jari 107
216 29 Dec 04 peter 108     std::vector<std::pair<double, double> > data_;
295 29 Apr 05 peter 109     Kernel* kernel_;
429 08 Dec 05 peter 110     OneDimensionalWeighted* regressor_;
1120 21 Feb 08 peter 111     utility::Vector x_;
4200 19 Aug 22 peter 112     utility::Vector y_predicted_;
4200 19 Aug 22 peter 113     utility::Vector y_err_;
202 01 Nov 04 peter 114    };
202 01 Nov 04 peter 115
430 08 Dec 05 peter 116   ///
726 04 Jan 07 peter 117   /// The output operator for the Regression::Local class.
430 08 Dec 05 peter 118   ///
1885 31 Mar 09 peter 119   /// \relates Local
1885 31 Mar 09 peter 120   ///
430 08 Dec 05 peter 121   std::ostream& operator<<(std::ostream&, const Local& );
202 01 Nov 04 peter 122
681 11 Oct 06 jari 123 }}} // of namespaces regression, yat, and theplu
430 08 Dec 05 peter 124
202 01 Nov 04 peter 125 #endif