#ifndef _theplu_yat_regression_local_
#define _theplu_yat_regression_local_
// $Id: Local.h 1487 2008-09-10 08:41:36Z jari $
/*
Copyright (C) 2004 Peter Johansson
Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
Copyright (C) 2008 Peter Johansson
This file is part of the yat library, http://dev.thep.lu.se/yat
The yat library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
The yat library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with yat. If not, see .
*/
#include "yat/utility/Vector.h"
#include
namespace theplu {
namespace yat {
namespace regression {
class Kernel;
class OneDimensionalWeighted;
///
/// @brief Class for Locally weighted regression.
///
/// Locally weighted regression is an algorithm for learning
/// continuous non-linear mappings in a non-parametric manner. In
/// locally weighted regression, points are weighted by proximity to
/// the current x in question using a Kernel. A weighted regression
/// is then computed using the weighted points and a specific
/// Regression method. This procedure is repeated, which results in
/// a pointwise approximation of the underlying (unknown) function.
///
class Local
{
public:
///
/// @brief Constructor taking type of \a regressor,
/// type of \a kernel.
///
Local(OneDimensionalWeighted& r, Kernel& k);
///
/// @brief The destructor
///
virtual ~Local(void);
///
/// adding a data point
///
void add(const double x, const double y);
///
/// @param step_size Size of step between each fit
/// @param nof_points Number of points used in each fit
///
/// \throw std::runtime_error if step_size is 0, nof_points is
/// less than 3, or step_size is larger than number of added data
/// points.
void fit(const size_t step_size, const size_t nof_points);
/**
\brief Set everything to zero
\since New in yat 0.5
*/
void reset(void);
///
/// @return x-values where fitting was performed.
///
const utility::Vector& x(void) const;
///
/// Function returning predicted values
///
const utility::Vector& y_predicted(void) const;
///
/// Function returning error of predictions
///
const utility::Vector& y_err(void) const;
private:
///
/// Copy Constructor. (Not implemented)
///
Local(const Local&);
std::vector > data_;
Kernel* kernel_;
OneDimensionalWeighted* regressor_;
utility::Vector x_;
utility::Vector y_predicted_;
utility::Vector y_err_;
};
///
/// The output operator for the Regression::Local class.
///
std::ostream& operator<<(std::ostream&, const Local& );
}}} // of namespaces regression, yat, and theplu
#endif