Skip to content

Commit

Permalink
+ obtain from generic Labels in sub-label classes
Browse files Browse the repository at this point in the history
  • Loading branch information
iglesias committed May 21, 2012
1 parent 89a638e commit 4562bc0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/shogun/labels/BinaryLabels.cpp
Expand Up @@ -27,6 +27,17 @@ CBinaryLabels::CBinaryLabels(CFile* loader) : CDenseLabels(loader),
{
}

CBinaryLabels* CBinaryLabels::obtain_from_generic(CLabels* base_labels)
{
if ( base_labels->get_label_type() == LT_BINARY )
return (CBinaryLabels*) base_labels;
else
SG_ERROR("base_labels must be of dynamic type CBinaryLabels");

return NULL;
}


bool CBinaryLabels::is_valid()
{
ASSERT(m_labels.vector);
Expand Down
6 changes: 6 additions & 0 deletions src/shogun/labels/BinaryLabels.h
Expand Up @@ -51,6 +51,12 @@ class CBinaryLabels : public CDenseLabels
*/
CBinaryLabels(CFile* loader);

/** helper method used to specialize a base class instance
*
* @param base_labels its dynamic type must be CBinaryLabels
*/
CBinaryLabels* obtain_from_generic(CLabels* base_labels);

/** is_valid checks if labeling is a two-class labeling
*
* possible with subset
Expand Down
2 changes: 2 additions & 0 deletions src/shogun/labels/MulticlassLabels.cpp
Expand Up @@ -27,6 +27,8 @@ CMulticlassLabels* CMulticlassLabels::obtain_from_generic(CLabels* base_labels)
return (CMulticlassLabels*) base_labels;
else
SG_ERROR("base_labels must be of dynamic type CMulticlassLabels");

return NULL;
}

bool CMulticlassLabels::is_valid()
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/labels/MulticlassLabels.h
Expand Up @@ -54,7 +54,7 @@ class CMulticlassLabels : public CDenseLabels
*/
CMulticlassLabels(CFile* loader);

/** helper method used to specialize a base class instance
/** helper method used to specialize a base class instance
*
* @param base_labels its dynamic type must be CMulticlassLabels
*/
Expand Down
10 changes: 10 additions & 0 deletions src/shogun/labels/RealLabels.cpp
Expand Up @@ -20,6 +20,16 @@ CRealLabels::CRealLabels(CFile* loader) : CDenseLabels(loader)
{
}

CRealLabels* CRealLabels::obtain_from_generic(CLabels* base_labels)
{
if ( base_labels->get_label_type() == LT_REAL )
return (CRealLabels*) base_labels;
else
SG_ERROR("base_labels must be of dynamic type CRealLabels");

return NULL;
}

bool CRealLabels::is_valid()
{
ASSERT(m_labels.vector);
Expand Down
8 changes: 7 additions & 1 deletion src/shogun/labels/RealLabels.h
Expand Up @@ -55,6 +55,12 @@ class CRealLabels : public CDenseLabels
*/
CRealLabels(CFile* loader);

/** helper method used to specialize a base class instance
*
* @param base_labels its dynamic type must be CRealLabels
*/
CRealLabels* obtain_from_generic(CLabels* base_labels);

/** is_valid checks if labeling is a multi-class labeling
*
* possible with subset
Expand All @@ -65,7 +71,7 @@ class CRealLabels : public CDenseLabels

/** get label type
*
* @return label type multiclass
* @return label type real
*/
virtual ELabelType get_label_type();
};
Expand Down

0 comments on commit 4562bc0

Please sign in to comment.