SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
LatentFeatures.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) 2012 Viktor Gal
8  * Copyright (C) 2012 Viktor Gal
9  */
10 
12 
13 using namespace shogun;
14 
16 {
17  init();
20 }
21 
23 {
24  init();
25  m_samples = new CDynamicObjectArray(num_samples);
27 }
28 
30 {
32 }
33 
35 {
36  return new CLatentFeatures(*this);
37 }
38 
40 {
41  return F_ANY;
42 }
43 
45 {
46  return C_LATENT;
47 }
48 
49 
51 {
52  if (m_samples == NULL)
53  return 0;
54  else
55  return m_samples->get_array_size();
56 }
57 
59 {
60  ASSERT(m_samples != NULL)
61  if (m_samples != NULL)
62  {
63  m_samples->push_back(example);
64  return true;
65  }
66  else
67  return false;
68 }
69 
71 {
72  ASSERT(m_samples != NULL)
73  if (idx < 0 || idx >= this->get_num_vectors())
74  SG_ERROR("Out of index!\n")
75 
76  return (CData*) m_samples->get_element(idx);
77 
78 }
79 
80 void CLatentFeatures::init()
81 {
82  SG_ADD((CSGObject**) &m_samples, "samples", "Array of examples",
84 }
85 
87 {
88  ASSERT(base_feats != NULL)
89  if (base_feats->get_feature_class() == C_LATENT)
90  return (CLatentFeatures*) base_feats;
91  else
92  SG_SERROR("base_labels must be of dynamic type CLatentLabels\n")
93 
94  return NULL;
95 }
96 
Latent Features class The class if for representing features for latent learning, e...
CDynamicObjectArray * m_samples
int32_t index_t
Definition: common.h:62
static CLatentFeatures * obtain_from_generic(CFeatures *base_feats)
#define SG_ERROR(...)
Definition: SGIO.h:129
#define SG_REF(x)
Definition: SGObject.h:54
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
#define ASSERT(x)
Definition: SGIO.h:201
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
dummy data holder
Definition: Data.h:25
bool add_sample(CData *example)
virtual int32_t get_num_vectors() const
virtual EFeatureClass get_feature_class() const =0
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
CData * get_sample(index_t idx)
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
#define SG_UNREF(x)
Definition: SGObject.h:55
virtual CFeatures * duplicate() const
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
#define SG_SERROR(...)
Definition: SGIO.h:179
virtual EFeatureClass get_feature_class() const
CSGObject * get_element(int32_t index) const
#define SG_ADD(...)
Definition: SGObject.h:84
virtual EFeatureType get_feature_type() const

SHOGUN Machine Learning Toolbox - Documentation