/**
* @file RegressionAlgorithmKernel.h
* @brief interface for a regression algorithm which is based on kernels
* @author Erik Rodner
* @date 12/09/2009

*/
#ifndef REGRESSIONALGORITHMKERNELINCLUDE
#define REGRESSIONALGORITHMKERNELINCLUDE

#include "vislearning/math/kernels/Kernel.h"
#include "vislearning/math/kernels/KernelData.h"
#include "RegressionAlgorithm.h"

namespace OBJREC
{

/** interface for a regression algorithm which is based on kernels */
class RegressionAlgorithmKernel : public RegressionAlgorithm
{
  protected:
    NICE::VVector X;
    NICE::Vector y;

    NICE::Config conf;

    Kernel *kernelFunction;

  public:

    /** simple constructor */
    RegressionAlgorithmKernel ( const NICE::Config *conf, Kernel *kernelFunction = NULL );

    /** copy constructor */
    RegressionAlgorithmKernel ( const RegressionAlgorithmKernel & src );

    /** simple destructor */
    virtual ~RegressionAlgorithmKernel();

    /** learn parameters/models/whatever with a kernel matrix (contained in a general structure kernel data)
     *  of a set
     *  of vectors and the corresponding function values \c y
     */
    virtual void teach ( KernelData *kernelData, const NICE::Vector & y ) = 0;

    /** predict the function value for a vector by using its kernel values with
     * the used training set, be careful with the order in \c kernelVector
     */
    virtual double predictKernel ( const NICE::Vector & kernelVector, double kernelSelf ) = 0;

    // functions to build an interface to RegressionAlgorithm

    /** learn parameters/models/whatever using a set of vectors and
     *  their corresponding function values
     */
    void teach ( const NICE::VVector & X, const NICE::Vector & y );

    /** predict the function value for \c x */
    double predict ( const NICE::Vector & x );

    /** clone function */
    virtual RegressionAlgorithmKernel *clone ( void ) const
    {
      fthrow ( NICE::Exception, "clone() not yet implemented!\n" );
    }

};

}

#endif
