Skip to content

Commit

Permalink
Merge pull request #221 from karlnapf/master
Browse files Browse the repository at this point in the history
changes towards kernel machine model storage
  • Loading branch information
Soeren Sonnenburg committed Jul 21, 2011
2 parents 5ac6102 + 963da14 commit 2399d29
Show file tree
Hide file tree
Showing 47 changed files with 306 additions and 340 deletions.
2 changes: 0 additions & 2 deletions src/interfaces/modular/Classifier.i
Expand Up @@ -21,7 +21,6 @@
%rename(GNPPSVM) CGNPPSVM;
%rename(GPBTSVM) CGPBTSVM;
%rename(GaussianNaiveBayes) CGaussianNaiveBayes;
%rename(KernelPerceptron) CKernelPerceptron;
%rename(KNN) CKNN;
%rename(LDA) CLDA;
%rename(LibLinear) CLibLinear;
Expand Down Expand Up @@ -79,7 +78,6 @@
%include <shogun/classifier/svm/GMNPSVM.h>
%include <shogun/classifier/svm/GNPPSVM.h>
%include <shogun/classifier/svm/GPBTSVM.h>
%include <shogun/classifier/KernelPerceptron.h>
%include <shogun/classifier/KNN.h>
%include <shogun/classifier/LDA.h>
%include <shogun/classifier/svm/LibLinear.h>
Expand Down
1 change: 0 additions & 1 deletion src/interfaces/modular/Classifier_includes.i
Expand Up @@ -3,7 +3,6 @@
#include <shogun/classifier/svm/GMNPSVM.h>
#include <shogun/classifier/svm/GNPPSVM.h>
#include <shogun/classifier/svm/GPBTSVM.h>
#include <shogun/classifier/KernelPerceptron.h>
#include <shogun/machine/DistanceMachine.h>
#include <shogun/classifier/KNN.h>
#include <shogun/classifier/LDA.h>
Expand Down
60 changes: 0 additions & 60 deletions src/shogun/classifier/KernelPerceptron.cpp

This file was deleted.

75 changes: 0 additions & 75 deletions src/shogun/classifier/KernelPerceptron.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/shogun/classifier/mkl/MKL.cpp
Expand Up @@ -190,7 +190,7 @@ bool CMKL::check_lpx_status(LPX *lp)
}
#endif // USE_GLPK

bool CMKL::train(CFeatures* data)
bool CMKL::train_kernel_machine(CFeatures* data)
{
ASSERT(kernel);
ASSERT(labels && labels->get_num_labels());
Expand Down
27 changes: 13 additions & 14 deletions src/shogun/classifier/mkl/MKL.h
Expand Up @@ -133,17 +133,6 @@ class CMKL : public CSVM
return svm;
}


/** train MKL classifier
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train(CFeatures* data=NULL);

/** set C mkl
*
* @param C new C_mkl
Expand Down Expand Up @@ -265,7 +254,20 @@ class CMKL : public CSVM
*/
virtual void compute_sum_beta(float64_t* sumw);

/** @return object name */
inline virtual const char* get_name() const { return "MKL"; }

protected:
/** train MKL classifier
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train_kernel_machine(CFeatures* data=NULL);

/** check run before starting training (to e.g. check if labeling is
* two-class labeling in classification case
*/
Expand Down Expand Up @@ -442,9 +444,6 @@ class CMKL : public CSVM
bool check_lpx_status(LPX *lp);
#endif

/** @return object name */
inline virtual const char* get_name() const { return "MKL"; }

protected:
/** wrapper SVM */
CSVM* svm;
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/classifier/mkl/MKLMultiClass.cpp
Expand Up @@ -325,7 +325,7 @@ float64_t CMKLMultiClass::getsquarenormofprimalcoefficients(
}


bool CMKLMultiClass::train(CFeatures* data)
bool CMKLMultiClass::train_kernel_machine(CFeatures* data)
{
int numcl=labels->get_num_classes();
ASSERT(kernel);
Expand Down
19 changes: 9 additions & 10 deletions src/shogun/classifier/mkl/MKLMultiClass.h
Expand Up @@ -49,16 +49,6 @@ class CMKLMultiClass : public CMultiClassSVM
*/
virtual ~CMKLMultiClass();

/** train Multiclass MKL classifier
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train(CFeatures* data=NULL);

/** get classifier type
*
* @return classifier type GMNPMKL
Expand Down Expand Up @@ -158,6 +148,15 @@ class CMKLMultiClass : public CMultiClassSVM
const int32_t ind);


/** train Multiclass MKL classifier
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train_kernel_machine(CFeatures* data=NULL);


protected:
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/classifier/svm/CPLEXSVM.cpp
Expand Up @@ -28,7 +28,7 @@ CCPLEXSVM::~CCPLEXSVM()
{
}

bool CCPLEXSVM::train(CFeatures* data)
bool CCPLEXSVM::train_kernel_machine(CFeatures* data)
{
bool result = false;
CCplex cplex;
Expand Down
7 changes: 4 additions & 3 deletions src/shogun/classifier/svm/CPLEXSVM.h
Expand Up @@ -26,6 +26,9 @@ IGNORE_IN_CLASSLIST class CCPLEXSVM : public CSVM
CCPLEXSVM();
virtual ~CCPLEXSVM();

virtual inline EClassifierType get_classifier_type() { return CT_CPLEXSVM; }

protected:
/** train SVM classifier
*
* @param data training data (parameter can be avoided if distance or
Expand All @@ -34,9 +37,7 @@ IGNORE_IN_CLASSLIST class CCPLEXSVM : public CSVM
*
* @return whether training was successful
*/
virtual bool train(CFeatures* data=NULL);

virtual inline EClassifierType get_classifier_type() { return CT_CPLEXSVM; }
virtual bool train_kernel_machine(CFeatures* data=NULL);
};
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/shogun/classifier/svm/DomainAdaptationSVM.cpp
Expand Up @@ -78,7 +78,7 @@ bool CDomainAdaptationSVM::is_presvm_sane()
}


bool CDomainAdaptationSVM::train(CFeatures* data)
bool CDomainAdaptationSVM::train_kernel_machine(CFeatures* data)
{

if (data)
Expand Down Expand Up @@ -111,7 +111,7 @@ bool CDomainAdaptationSVM::train(CFeatures* data)
delete[] lin_term;

//train SVM
bool success = CSVMLight::train();
bool success = CSVMLight::train_kernel_machine();

ASSERT(presvm)

Expand Down
20 changes: 10 additions & 10 deletions src/shogun/classifier/svm/DomainAdaptationSVM.h
Expand Up @@ -49,16 +49,6 @@ class CDomainAdaptationSVM : public CSVMLight
* */
void init(CSVM* presvm, float64_t B);

/** train SVM classifier
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train(CFeatures* data=NULL);

/** get classifier type
*
* @return classifier type
Expand Down Expand Up @@ -106,6 +96,16 @@ class CDomainAdaptationSVM : public CSVMLight
*/
virtual bool is_presvm_sane();

/** train SVM classifier
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train_kernel_machine(CFeatures* data=NULL);

private:
void init();

Expand Down
2 changes: 1 addition & 1 deletion src/shogun/classifier/svm/GMNPSVM.cpp
Expand Up @@ -48,7 +48,7 @@ CGMNPSVM::init(void)
m_basealphas = NULL, m_basealphas_y = 0, m_basealphas_x = 0;
}

bool CGMNPSVM::train(CFeatures* data)
bool CGMNPSVM::train_kernel_machine(CFeatures* data)
{
ASSERT(kernel);
ASSERT(labels && labels->get_num_labels());
Expand Down
21 changes: 11 additions & 10 deletions src/shogun/classifier/svm/GMNPSVM.h
Expand Up @@ -40,16 +40,6 @@ class CGMNPSVM : public CMultiClassSVM
/** default destructor */
virtual ~CGMNPSVM();

/** train SVM
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train(CFeatures* data=NULL);

/** get classifier type
*
* @return classifier type GMNPSVM
Expand All @@ -70,6 +60,17 @@ class CGMNPSVM : public CMultiClassSVM
/** @return object name */
inline virtual const char* get_name() const { return "GMNPSVM"; }

protected:
/** train SVM
*
* @param data training data (parameter can be avoided if distance or
* kernel-based classifiers are used and distance/kernels are
* initialized with train data)
*
* @return whether training was successful
*/
virtual bool train_kernel_machine(CFeatures* data=NULL);

protected:
/** required for CMKLMulticlass
* stores the untransformed alphas of this algorithm
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/classifier/svm/GNPPSVM.cpp
Expand Up @@ -29,7 +29,7 @@ CGNPPSVM::~CGNPPSVM()
{
}

bool CGNPPSVM::train(CFeatures* data)
bool CGNPPSVM::train_kernel_machine(CFeatures* data)
{
ASSERT(kernel);
ASSERT(labels && labels->get_num_labels());
Expand Down

0 comments on commit 2399d29

Please sign in to comment.