SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LikelihoodModel.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Roman Votyakov
8  * Written (W) 2013 Heiko Strathmann
9  * Copyright (C) 2012 Jacob Walker
10  * Copyright (C) 2013 Roman Votyakov
11  */
12 
14 
15 using namespace shogun;
16 
18 {
19 }
20 
22 {
23 }
24 
27 {
28  return get_log_zeroth_moments(mu, s2, lab);
29 }
30 
32  const CLabels* lab, SGMatrix<float64_t> F) const
33 {
34  REQUIRE(lab, "Given labels are NULL!\n");
35  REQUIRE(lab->get_num_labels()==F.num_rows, "Number of labels (%d) does "
36  "not match dimension of functions (%d)\n",
37  lab->get_num_labels(),F.num_rows);
38  REQUIRE(F.num_cols>0, "Number of passed functions (%d) must be positive\n",
39  F.num_cols);
40 
41  SGVector<float64_t> result(F.num_cols);
42  for (index_t i=0; i<F.num_cols; ++i)
43  {
44  /* extract current sample from matrix, assume col-major, dont copy */
45  SGVector<float64_t> f(&F.matrix[i*F.num_rows], F.num_rows, false);
47  }
48 
49  return result;
50 }
51 
53  SGVector<float64_t> s2, const CLabels* lab) const
54 {
55  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
56  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
57  "Length of the vector of means (%d), length of the vector of "
58  "variances (%d) and number of labels (%d) should be the same\n",
59  mu.vlen, s2.vlen, lab->get_num_labels())
60 
61  SGVector<float64_t> result(mu.vlen);
62 
63  for (index_t i=0; i<mu.vlen; i++)
64  result[i]=get_first_moment(mu, s2, lab, i);
65 
66  return result;
67 }
68 
70  SGVector<float64_t> s2, const CLabels* lab) const
71 {
72  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
73  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
74  "Length of the vector of means (%d), length of the vector of "
75  "variances (%d) and number of labels (%d) should be the same\n",
76  mu.vlen, s2.vlen, lab->get_num_labels())
77 
78  SGVector<float64_t> result(mu.vlen);
79 
80  for (index_t i=0; i<mu.vlen; i++)
81  result[i]=get_second_moment(mu, s2, lab, i);
82 
83  return result;
84 }
virtual SGVector< float64_t > get_first_moments(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab) const
virtual SGVector< float64_t > get_log_probability_f(const CLabels *lab, SGVector< float64_t > func) const =0
int32_t index_t
Definition: common.h:62
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
virtual int32_t get_num_labels() const =0
virtual SGVector< float64_t > get_log_zeroth_moments(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab) const =0
#define REQUIRE(x,...)
Definition: SGIO.h:206
index_t num_cols
Definition: SGMatrix.h:378
virtual SGVector< float64_t > get_second_moments(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab) const
virtual float64_t get_second_moment(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab, index_t i) const =0
index_t num_rows
Definition: SGMatrix.h:376
index_t vlen
Definition: SGVector.h:494
virtual SGVector< float64_t > get_log_probability_fmatrix(const CLabels *lab, SGMatrix< float64_t > F) const
virtual SGVector< float64_t > get_predictive_log_probabilities(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab=NULL)
static T sum(T *vec, int32_t len)
Return sum(vec)
Definition: SGVector.h:354
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual float64_t get_first_moment(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab, index_t i) const =0

SHOGUN Machine Learning Toolbox - Documentation