24 using namespace shogun;
25 using namespace Eigen;
56 "Exact inference method can only use Gaussian likelihood function\n")
58 "Labels must be type of CRegressionLabels\n")
100 float64_t result=(eigen_y-eigen_m).dot(eigen_alpha)/2.0+
101 eigen_L.diagonal().array().log().sum()+
m_L.
num_rows*
178 a=L.triangularView<Upper>().adjoint().solve(eigen_y-eigen_m);
179 a=L.triangularView<Upper>().solve(a);
195 Map<VectorXd> eigen_mu(m_mu.
vector, m_mu.
vlen);
213 MatrixXd eigen_V=eigen_L.triangularView<Upper>().adjoint().solve(
235 eigen_Q=eigen_L.triangularView<Upper>().adjoint().solve(
237 eigen_Q=eigen_L.triangularView<Upper>().solve(eigen_Q);
243 eigen_Q-=eigen_alpha*eigen_alpha.transpose();
249 REQUIRE(!strcmp(param->
m_name,
"scale"),
"Can't compute derivative of "
250 "the nagative log marginal likelihood wrt %s.%s parameter\n",
259 result[0]=(eigen_Q.cwiseProduct(eigen_K)*
m_scale*2.0).
sum()/2.0;
267 REQUIRE(!strcmp(param->
m_name,
"sigma"),
"Can't compute derivative of "
268 "the nagative log marginal likelihood wrt %s.%s parameter\n",
283 result[0]=
CMath::sq(sigma)*eigen_Q.trace();
300 "Length of the parameter %s should not be NULL\n", param->
m_name)
338 "Length of the parameter %s should not be NULL\n", param->
m_name)
356 Map<VectorXd> eigen_dmu(dmu.
vector, dmu.
vlen);
359 result[i]=-eigen_dmu.
dot(eigen_alpha);
virtual const char * get_name() const =0
virtual void update_deriv()
static float64_t dot(const bool *v1, const bool *v2, int32_t n)
compute dot product between v1 and v2 (blas optimized)
virtual ELabelType get_label_type() const =0
Class that models Gaussian likelihood.
Real Labels are real-valued labels.
SGVector< float64_t > m_alpha
The Inference Method base class.
virtual SGMatrix< float64_t > get_posterior_covariance()
The class Labels models labels, i.e. class assignments of objects.
real valued labels (e.g. for regression, classifier outputs)
virtual const char * get_name() const
virtual SGVector< float64_t > get_alpha()
static T sum(T *vec, int32_t len)
return sum(vec)
virtual ELikelihoodModelType get_model_type() const
virtual int32_t get_num_vectors() const =0
virtual void update_mean()
virtual SGVector< float64_t > get_mean_vector(const CFeatures *features) const =0
An abstract class of the mean function.
virtual bool update_parameter_hash()
SGMatrix< float64_t > m_L
virtual void update_chol()
virtual ~CExactInferenceMethod()
virtual SGMatrix< float64_t > get_cholesky()
virtual SGVector< float64_t > get_derivative_wrt_mean(const TParameter *param)
virtual SGVector< float64_t > get_derivative_wrt_inference_method(const TParameter *param)
virtual SGVector< float64_t > get_diagonal_vector()
static void fill_vector(T *vec, int32_t len, T value)
static CGaussianLikelihood * obtain_from_generic(CLikelihoodModel *lik)
virtual SGVector< float64_t > get_parameter_derivative(const CFeatures *features, const TParameter *param, index_t index=-1)
virtual float64_t get_negative_log_marginal_likelihood()
The class Features is the base class of all feature objects.
virtual SGVector< float64_t > get_derivative_wrt_kernel(const TParameter *param)
virtual SGMatrix< float64_t > get_parameter_gradient(const TParameter *param, index_t index=-1)
static float64_t log(float64_t v)
virtual void check_members() const
virtual SGVector< float64_t > get_derivative_wrt_likelihood_model(const TParameter *param)
virtual void update_alpha()
virtual void update_cov()
virtual void check_members() const
The Likelihood model base class.
SGMatrix< float64_t > m_ktrtr
CLikelihoodModel * m_model
virtual SGVector< float64_t > get_posterior_mean()
static const float64_t PI