Skip to content

Commit

Permalink
Merge pull request #479 from pluskid/multiclass-strategy
Browse files Browse the repository at this point in the history
Multiclass strategy refactoring
  • Loading branch information
Soeren Sonnenburg committed Apr 23, 2012
2 parents 719f903 + af1a9fb commit 1ccb9e4
Show file tree
Hide file tree
Showing 21 changed files with 517 additions and 373 deletions.
Expand Up @@ -3,6 +3,7 @@
#include <shogun/io/SGIO.h>
#include <shogun/features/StreamingSimpleFeatures.h>
#include <shogun/features/SimpleFeatures.h>
#include <shogun/multiclass/MulticlassOneVsOneStrategy.h>
#include <shogun/machine/LinearMulticlassMachine.h>
#include <shogun/classifier/svm/LibLinear.h>
#include <shogun/base/init.h>
Expand Down Expand Up @@ -80,7 +81,7 @@ int main(int argc, char** argv)

// Create a multiclass svm classifier that consists of several of the previous one
CLinearMulticlassMachine* mc_svm = new CLinearMulticlassMachine(
ONE_VS_ONE_STRATEGY, (CDotFeatures*) features, svm, labels);
new CMulticlassOneVsOneStrategy(), (CDotFeatures*) features, svm, labels);
SG_REF(mc_svm);

// Train the multiclass machine using the data passed in the constructor
Expand Down
Expand Up @@ -29,4 +29,4 @@ def classifier_multiclasslibsvm_modular (fm_train_real=traindat,fm_test_real=tes

if __name__=='__main__':
print('MulticlassLibSVM')
classifier_multiclasslibsvm_modular(*parameter_list[0])
[predictions, svm, labels] = classifier_multiclasslibsvm_modular(*parameter_list[0])
7 changes: 4 additions & 3 deletions src/shogun/classifier/mkl/MKLMulticlass.cpp
Expand Up @@ -8,14 +8,15 @@
* Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
*/

#include <shogun/multiclass/MulticlassOneVsRestStrategy.h>
#include <shogun/classifier/mkl/MKLMulticlass.h>
#include <shogun/io/SGIO.h>

using namespace shogun;


CMKLMulticlass::CMKLMulticlass()
: CMulticlassSVM(ONE_VS_REST_STRATEGY)
: CMulticlassSVM(new CMulticlassOneVsRestStrategy())
{
svm=NULL;
lpw=NULL;
Expand All @@ -26,7 +27,7 @@ CMKLMulticlass::CMKLMulticlass()
}

CMKLMulticlass::CMKLMulticlass(float64_t C, CKernel* k, CLabels* lab)
: CMulticlassSVM(ONE_VS_REST_STRATEGY, C, k, lab)
: CMulticlassSVM(new CMulticlassOneVsRestStrategy(), C, k, lab)
{
svm=NULL;
lpw=NULL;
Expand All @@ -46,7 +47,7 @@ CMKLMulticlass::~CMKLMulticlass()
}

CMKLMulticlass::CMKLMulticlass( const CMKLMulticlass & cm)
: CMulticlassSVM(ONE_VS_REST_STRATEGY)
: CMulticlassSVM(new CMulticlassOneVsRestStrategy())
{
svm=NULL;
lpw=NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/machine/KernelMulticlassMachine.h
Expand Up @@ -39,7 +39,7 @@ class CKernelMulticlassMachine : public CMulticlassMachine
* @param machine kernel machine
* @param labs labels
*/
CKernelMulticlassMachine(EMulticlassStrategy strategy, CKernel* kernel, CKernelMachine* machine, CLabels* labs) :
CKernelMulticlassMachine(CMulticlassStrategy *strategy, CKernel* kernel, CKernelMachine* machine, CLabels* labs) :
CMulticlassMachine(strategy,(CMachine*)machine,labs), m_kernel(NULL)
{
set_kernel(kernel);
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/machine/LinearMulticlassMachine.h
Expand Up @@ -41,7 +41,7 @@ class CLinearMulticlassMachine : public CMulticlassMachine
* @param machine linear machine
* @param labs labels
*/
CLinearMulticlassMachine(EMulticlassStrategy strategy, CDotFeatures* features, CLinearMachine* machine, CLabels* labs) :
CLinearMulticlassMachine(CMulticlassStrategy *strategy, CDotFeatures* features, CLinearMachine* machine, CLabels* labs) :
CMulticlassMachine(strategy,(CMachine*)machine,labs), m_features(NULL)
{
set_features(features);
Expand Down

0 comments on commit 1ccb9e4

Please sign in to comment.