40 using namespace Eigen;
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79 void set_sigma(
float64_t sigma) { m_sigma=sigma; }
102 class CSigmoidFunction :
public CFunction
143 class CProductFunction :
public CFunction
159 virtual ~CProductFunction()
173 return (*m_f)(x)*(*m_g)(x);
188 CLinearFunction() { }
190 virtual ~CLinearFunction() { }
205 class CQuadraticFunction :
public CFunction
209 CQuadraticFunction() { }
211 virtual ~CQuadraticFunction() { }
248 eigen_r=2.0*eigen_lp.array().exp()-1.0;
266 eigen_r=1-(2.0*eigen_lp.array().exp()-1.0).square();
275 REQUIRE(lab,
"Labels are required (lab should not be NULL)\n")
277 "Labels must be type of CBinaryLabels\n")
279 "length of the function vector\n")
290 eigen_r=-(1.0+(-eigen_y.array()*eigen_f.array()).exp()).log();
299 REQUIRE(lab,
"Labels are required (lab should not be NULL)\n")
301 "Labels must be type of CBinaryLabels\n")
303 "length of the function vector\n")
304 REQUIRE(i>=1 && i<=3,
"Index for derivative should be 1, 2 or 3\n")
315 VectorXd eigen_s=(VectorXd::Ones(func.
vlen)).cwiseQuotient((1.0+
316 (-eigen_f).array().exp()).matrix());
322 eigen_r=(eigen_y.array()+1.0)/2.0-eigen_s.array();
327 eigen_r=-eigen_s.array()*(1.0-eigen_s.array());
332 eigen_r=-eigen_s.array()*(1.0-eigen_s.array())*(1.0-2.0*eigen_s.array());
336 SG_ERROR(
"Invalid index for derivative\n")
350 "Length of the vector of means (%d), length of the vector of "
351 "variances (%d) and number of labels (%d) should be the same\n",
354 "Labels must be type of CBinaryLabels\n")
361 "length of the vector of variances (%d) should be the same\n",
369 CNormalPDF* f=
new CNormalPDF();
372 CSigmoidFunction* g=
new CSigmoidFunction();
375 CProductFunction* h=
new CProductFunction(f, g);
407 REQUIRE(lab,
"Labels are required (lab should not be NULL)\n")
409 "Length of the vector of means (%d), length of the vector of "
410 "variances (%d) and number of labels (%d) should be the same\n",
412 REQUIRE(i>=0 && i<=mu.
vlen,
"Index (%d) out of bounds!\n", i)
414 "Labels must be type of CBinaryLabels\n")
419 CNormalPDF* f=
new CNormalPDF(mu[i],
CMath::sqrt(s2[i]));
422 CSigmoidFunction* g=
new CSigmoidFunction(y[i]);
425 CProductFunction* h=
new CProductFunction(f, g);
428 CLinearFunction* l=
new CLinearFunction();
431 CProductFunction* k=
new CProductFunction(l, h);
451 REQUIRE(lab,
"Labels are required (lab should not be NULL)\n")
453 "Length of the vector of means (%d), length of the vector of "
454 "variances (%d) and number of labels (%d) should be the same\n",
456 REQUIRE(i>=0 && i<=mu.
vlen,
"Index (%d) out of bounds!\n", i)
458 "Labels must be type of CBinaryLabels\n")
463 CNormalPDF* f=
new CNormalPDF(mu[i],
CMath::sqrt(s2[i]));
466 CSigmoidFunction* g=
new CSigmoidFunction(y[i]);
469 CProductFunction* h=
new CProductFunction(f, g);
472 CLinearFunction* l=
new CLinearFunction();
475 CProductFunction* k=
new CProductFunction(l, h);
479 CQuadraticFunction* q=
new CQuadraticFunction();
482 CProductFunction* p=
new CProductFunction(q, h);
virtual SGVector< float64_t > get_predictive_means(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab=NULL) const
virtual SGVector< float64_t > get_predictive_variances(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab=NULL) const
virtual ELabelType get_label_type() const =0
virtual ~CLogitLikelihood()
static float64_t integrate_quadgk(CFunction *f, float64_t a, float64_t b, float64_t abs_tol=1e-10, float64_t rel_tol=1e-5, uint32_t max_iter=1000, index_t sn=10)
The class Labels models labels, i.e. class assignments of objects.
static const float64_t INFTY
infinity
virtual int32_t get_num_labels() const =0
virtual float64_t get_second_moment(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab, index_t i) const
Class of a function of one variable.
virtual SGVector< float64_t > get_log_probability_derivative_f(const CLabels *lab, SGVector< float64_t > func, index_t i) const
virtual SGVector< float64_t > get_log_zeroth_moments(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab) const
all of classes and functions are contained in the shogun namespace
static float64_t exp(float64_t x)
static float64_t log(float64_t v)
virtual float64_t get_first_moment(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab, index_t i) const
Binary Labels for binary classification.
virtual SGVector< float64_t > get_log_probability_f(const CLabels *lab, SGVector< float64_t > func) const
static float32_t sqrt(float32_t x)
The Likelihood model base class.
void set_const(T const_elem)
static const float64_t PI