.. include:: ../../toolkit-substitutions

.. oe:namespace:: OEMath

.. meta::
   :keywords: OEKernelPLS, KernelPLS


.. _OEMath_OEKernelPLS:

.. oe:class:: OEKernelPLS

   .. oe:api::

      class OEKernelPLS
      
   The :ref:`OEKernelPLS <OEMath_OEKernelPLS>` can be used to build models using
   kernel partial least squares technique (kPLS).

   To train a model using kPLS, the descriptors are expected to be in the 
   dot-kernel space.  Kernel partial least squares (PLS) has been particularly 
   popular in chemometrics, due to its sub-cubic runtime for learning, and 
   an iterative construction of directions which are relevant for predicting 
   the outputs.

   The :ref:`OEKernelPLS <OEMath_OEKernelPLS>` class defines the following public methods:
    * :oe:meth:`Fit<OEMath::OEKernelPLS::Fit>`
    * :oe:meth:`GetB0<OEMath::OEKernelPLS::GetB0>`
    * :oe:meth:`GetBValues<OEMath::OEKernelPLS::GetBValues>`
    * :oe:meth:`GetNumFeaturesUsed<OEMath::OEKernelPLS::GetNumFeaturesUsed>`
    * :oe:meth:`Predict<OEMath::OEKernelPLS::Predict>`


   .. oe:method:: Constructor

      .. oe:language:: c++ java csharp

         .. oe:api::

            OEKernelPLS()
            OEKernelPLS(const OEKernelPLS&)

      .. oe:language:: python

         .. oe:api:: python

            OEKernelPLS() -> OEKernelPLS
            OEKernelPLS(arg2: OEKernelPLS) -> OEKernelPLS

      Default and copy constructors.

   .. oe:method:: operator=
      :language: c++

      .. oe:api::

         OEKernelPLS &operator=(const OEKernelPLS &)

      Assignment operator.


   .. oe:method:: Fit

      .. oe:language:: c++ java csharp

         .. oe:api::

            bool Fit(const OESquareMatrix& kernel,
                     const std::vector<double>& vecResponse,
                     const unsigned maxFeatures)

      .. oe:language:: python

         .. oe:api:: python

            Fit(kernel: OESquareMatrix, vecResponse: OEDoubleVector,
                maxFeatures: int) -> bool

      Fit model using the provided kernel descriptor matrix.

         *kernel*   
            kernel descriptor matrix.

         *vecResponse*    
            vector of response corresponding to descriptors.

         *maxFeatures*    
            Maximum number of PLS features to use for model fitting.  A value of *0 (zero)*
            corresponds to choosing number of features to fit the best model that minimizes 
            error on the training set.

   .. oe:method:: GetB0

      .. oe:language:: c++ java csharp

         .. oe:api::

            double GetB0() const

      .. oe:language:: python

         .. oe:api:: python

            GetB0() -> float

      Get the fitted model intercept.

   .. oe:method:: GetBValues

      .. oe:language:: c++ java csharp

         .. oe:api::

            const std::vector<double>& GetBValues() const

      .. oe:language:: python

         .. oe:api:: python

            GetBValues() -> OEDoubleVector

      Get the fitted model regression coefficients. 

   .. oe:method:: GetNumFeaturesUsed

      .. oe:language:: c++ java csharp

         .. oe:api::

            unsigned GetNumFeaturesUsed() const

      .. oe:language:: python

         .. oe:api:: python

            GetNumFeaturesUsed() -> int

      Returns the actual number of PLS features used for model fitting.

   .. oe:method:: Predict

      .. oe:language:: c++ java csharp

         .. oe:api::

            double Predict(const std::vector<double>& kernel) const

      .. oe:language:: python

         .. oe:api:: python

            Predict(kernel: OEDoubleVector) -> float

      Returns predicted estimation for the input descriptor vector.
