Skip to content

Commit

Permalink
Moved train to train_machine in AveragedPerceptron and OnlineLibLinear
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed May 23, 2012
1 parent 7bbda1c commit 495a859
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/shogun/classifier/AveragedPerceptron.cpp
Expand Up @@ -30,7 +30,7 @@ CAveragedPerceptron::~CAveragedPerceptron()
{
}

bool CAveragedPerceptron::train(CFeatures* data)
bool CAveragedPerceptron::train_machine(CFeatures* data)
{
ASSERT(m_labels);
ASSERT(m_labels->get_label_type() == LT_BINARY);
Expand Down
22 changes: 12 additions & 10 deletions src/shogun/classifier/AveragedPerceptron.h
Expand Up @@ -49,16 +49,6 @@ class CAveragedPerceptron : public CLinearMachine
*/
virtual inline EMachineType get_classifier_type() { return CT_AVERAGEDPERCEPTRON; }

/** train 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 learn rate of gradient descent training algorithm
inline void set_learn_rate(float64_t r)
{
Expand All @@ -74,6 +64,18 @@ class CAveragedPerceptron : public CLinearMachine
/** @return object name */
inline virtual const char* get_name() const { return "AveragedPerceptron"; }

protected:

/** train 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_machine(CFeatures* data=NULL);

protected:
/** learning rate */
float64_t learn_rate;
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/classifier/svm/OnlineLibLinear.cpp
Expand Up @@ -56,7 +56,7 @@ COnlineLibLinear::~COnlineLibLinear()
{
}

bool COnlineLibLinear::train(CFeatures* data)
bool COnlineLibLinear::train_machine(CFeatures* data)
{
if (data)
{
Expand Down
22 changes: 12 additions & 10 deletions src/shogun/classifier/svm/OnlineLibLinear.h
Expand Up @@ -49,16 +49,6 @@ class COnlineLibLinear : public COnlineLinearMachine
/** Destructor */
virtual ~COnlineLibLinear();

/**
* Train classifier
*
* @param data Training data, can be avoided if already
* initialized with it
*
* @return Whether training was successful
*/
virtual bool train(CFeatures* data=NULL);

/**
* Set C1 and C2 constants
*
Expand Down Expand Up @@ -98,6 +88,18 @@ class COnlineLibLinear : public COnlineLinearMachine
/** @return Object name */
inline virtual const char* get_name() const { return "OnlineLibLinear"; }

protected:

/**
* Train classifier
*
* @param data Training data, can be avoided if already
* initialized with it
*
* @return Whether training was successful
*/
virtual bool train_machine(CFeatures* data=NULL);

private:
/** Set up parameters */
void init();
Expand Down

0 comments on commit 495a859

Please sign in to comment.