Learning Curve Plus Plus (LCPP)
algo::regression::Kernel< KERNEL, T > Class Template Reference

Public Member Functions

template<typename... Ts>
 Kernel (const arma::Mat< T > &inputs, const arma::Row< T > &labels, const Ts &... args)
 
template<typename... Ts>
 Kernel (const Ts &... args)
 
void Train (const arma::Mat< T > &inputs, const arma::Row< T > &labels)
 
void Predict (const arma::Mat< T > &inputs, arma::Row< T > &labels) const
 
ComputeError (const arma::Mat< T > &points, const arma::Row< T > &responses) const
 
template<typename Archive >
void serialize (Archive &ar, const unsigned int)
 

Detailed Description

template<class KERNEL, class T = DTYPE>
class algo::regression::Kernel< KERNEL, T >

Definition at line 101 of file kernelridge.h.

Constructor & Destructor Documentation

◆ Kernel() [1/2]

template<class KERNEL , class T >
template<class... Ts>
algo::regression::Kernel< KERNEL, T >::Kernel ( const arma::Mat< T > &  inputs,
const arma::Row< T > &  labels,
const Ts &...  args 
)
Parameters
inputsX
labelsy
argsfor the kernel

Definition at line 82 of file kernelridge_impl.h.

84  : cov_(args...)
85 {
86  Train(inputs, labels);
87 }
void Train(const arma::Mat< T > &inputs, const arma::Row< T > &labels)

References algo::regression::Kernel< KERNEL, T >::Train().

+ Here is the call graph for this function:

◆ Kernel() [2/2]

template<class KERNEL , class T = DTYPE>
template<typename... Ts>
algo::regression::Kernel< KERNEL, T >::Kernel ( const Ts &...  args)
inline

Non-working model

Definition at line 119 of file kernelridge.h.

119 : cov_(args...){ }

Member Function Documentation

◆ ComputeError()

template<class KERNEL , class T >
T algo::regression::Kernel< KERNEL, T >::ComputeError ( const arma::Mat< T > &  points,
const arma::Row< T > &  responses 
) const

Calculate the L2 squared error

Parameters
inputs
labels

Definition at line 111 of file kernelridge_impl.h.

113 {
114  arma::Row<T> temp;
115  Predict(inputs, temp);
116  const size_t n_points = inputs.n_cols;
117 
118  temp = labels - temp;
119 
120  const T cost = (arma::dot(temp, temp) / n_points);
121 
122  return cost;
123 }
void Predict(const arma::Mat< T > &inputs, arma::Row< T > &labels) const

◆ Predict()

template<class KERNEL , class T >
void algo::regression::Kernel< KERNEL, T >::Predict ( const arma::Mat< T > &  inputs,
arma::Row< T > &  labels 
) const
Parameters
inputsX*
labelsy*

Definition at line 98 of file kernelridge_impl.h.

100 {
101  arma::Mat<T> sim = cov_.GetMatrix(train_inp_, inputs);
102  const size_t N = sim.n_rows;
103  for(size_t i=0; i<N; i++)
104  {
105  sim.row(i) /= arma::sum(sim,0);
106  }
107  labels = train_lab_ * sim;
108 }

◆ serialize()

template<class KERNEL , class T = DTYPE>
template<typename Archive >
void algo::regression::Kernel< KERNEL, T >::serialize ( Archive &  ar,
const unsigned int   
)
inline

Serialize the model.

Definition at line 149 of file kernelridge.h.

150  {
151  ar (cereal::make_nvp("train_inp",train_inp_),
152  cereal::make_nvp("train_lab",train_lab_),
153  cereal::make_nvp("cov",cov_));
154  }

◆ Train()

template<class KERNEL , class T >
void algo::regression::Kernel< KERNEL, T >::Train ( const arma::Mat< T > &  inputs,
const arma::Row< T > &  labels 
)
Parameters
inputsX
labelsy
argsfor the kernel

Definition at line 90 of file kernelridge_impl.h.

92 {
93  train_inp_ = inputs;
94  train_lab_ = labels;
95 }

Referenced by algo::regression::Kernel< KERNEL, T >::Kernel().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: