Skip to content

Commit

Permalink
Add MulticlassLabels constructor from BinaryLabels
Browse files Browse the repository at this point in the history
  • Loading branch information
micmn authored and vigsterkr committed Jul 5, 2017
1 parent 1ee49a8 commit fdfef65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/shogun/labels/MulticlassLabels.cpp
Expand Up @@ -25,6 +25,15 @@ CMulticlassLabels::CMulticlassLabels(CFile* loader) : CDenseLabels(loader)
init();
}

CMulticlassLabels::CMulticlassLabels(CBinaryLabels* labels)
: CDenseLabels(labels->get_num_labels())
{
init();

for (index_t i = 0; i < labels->get_num_labels(); ++i)
m_labels[i] = (labels->get_label(i) == 1 ? 1 : 0);
}

CMulticlassLabels::~CMulticlassLabels()
{
}
Expand Down
8 changes: 8 additions & 0 deletions src/shogun/labels/MulticlassLabels.h
Expand Up @@ -57,6 +57,14 @@ class CMulticlassLabels : public CDenseLabels
*/
CMulticlassLabels(CFile* loader);

/**
* Convert binary labels to multiclass labels,
* namely -1 is mapped to 0 and 1 to 1.
*
* @param labels Binary labels
*/
CMulticlassLabels(CBinaryLabels* labels);

/** destructor */
~CMulticlassLabels();

Expand Down

0 comments on commit fdfef65

Please sign in to comment.