Skip to content

Commit

Permalink
Fixes for WDSVMOcas
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed May 22, 2012
1 parent 3f690ca commit 4d58627
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/shogun/classifier/svm/WDSVMOcas.cpp
Expand Up @@ -97,7 +97,19 @@ CWDSVMOcas::~CWDSVMOcas()
{
}

CLabels* CWDSVMOcas::apply(CFeatures* data)
CBinaryLabels* CWDSVMOcas::apply_binary(CFeatures* data)
{
SGVector<float64_t> outputs = apply_get_outputs(data);
return new CBinaryLabels(outputs);
}

CRegressionLabels* CWDSVMOcas::apply_regression(CFeatures* data)
{
SGVector<float64_t> outputs = apply_get_outputs(data);
return new CRegressionLabels(outputs);
}

SGVector<float64_t> CWDSVMOcas::apply_get_outputs(CFeatures* data)
{
if (data)
{
Expand All @@ -114,21 +126,19 @@ CLabels* CWDSVMOcas::apply(CFeatures* data)
set_wd_weights();
set_normalization_const();

SGVector<float64_t> outputs;
if (features)
{
int32_t num=features->get_num_vectors();
ASSERT(num>0);

CBinaryLabels* output=new CBinaryLabels(num);
SG_REF(output);
outputs = SGVector<float64_t>(num);

for (int32_t i=0; i<num; i++)
output->set_label(i, apply_one(i));

return output;
outputs[i] = apply_one(i);
}

return NULL;
return outputs;
}

int32_t CWDSVMOcas::set_wd_weights()
Expand Down
14 changes: 13 additions & 1 deletion src/shogun/classifier/svm/WDSVMOcas.h
Expand Up @@ -151,11 +151,20 @@ class CWDSVMOcas : public CMachine
inline int32_t get_degree() { return degree; }

/** classify objects
* for binary classification problems
*
* @param data (test)data to be classified
* @return classified labels
*/
virtual CLabels* apply(CFeatures* data=NULL);
virtual CBinaryLabels* apply_binary(CFeatures* data=NULL);

/** classify objects
* for regression problems
*
* @param data (test)data to be classified
* @return classified labels
*/
virtual CRegressionLabels* apply_regression(CFeatures* data=NULL);

/** classify one example
*
Expand Down Expand Up @@ -210,6 +219,9 @@ class CWDSVMOcas : public CMachine


protected:

SGVector<float64_t> apply_get_outputs(CFeatures* data);

/** set wd weights
*
* @return w_dim_single_c
Expand Down

0 comments on commit 4d58627

Please sign in to comment.