Skip to content

Commit

Permalink
Restored apply_one method of multiclass machine
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed May 21, 2012
1 parent 5f9d58b commit e496dce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/shogun/machine/MulticlassMachine.cpp
Expand Up @@ -175,3 +175,18 @@ bool CMulticlassMachine::train_machine(CFeatures* data)

return true;
}

float64_t CMulticlassMachine::apply_one(int32_t vec_idx)
{
init_machines_for_apply(NULL);

ASSERT(m_machines->get_num_elements()>0);
SGVector<float64_t> outputs(m_machines->get_num_elements());

for (int32_t i=0; i<m_machines->get_num_elements(); i++)
outputs[i] = get_submachine_output(i, vec_idx);

float64_t result = m_multiclass_strategy->decide_label(outputs);

return result;
}
6 changes: 6 additions & 0 deletions src/shogun/machine/MulticlassMachine.h
Expand Up @@ -100,6 +100,12 @@ class CMulticlassMachine : public CMachine
*/
virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);

/** classify one example
* @param vec_idx
* @return label
*/
virtual float64_t apply_one(int32_t vec_idx);

/** get the type of multiclass'ness
*
* @return multiclass type one vs one etc
Expand Down

0 comments on commit e496dce

Please sign in to comment.