Skip to content

Commit

Permalink
move regression .h functions to .cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Oct 8, 2011
1 parent 9b410c9 commit 884c74a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 24 deletions.
5 changes: 5 additions & 0 deletions src/shogun/regression/svr/LibSVR.cpp
Expand Up @@ -35,6 +35,11 @@ CLibSVR::~CLibSVR()
SG_FREE(model);
}

EClassifierType CLibSVR::get_classifier_type()
{
return CT_LIBSVR;
}

bool CLibSVR::train_machine(CFeatures* data)
{
ASSERT(kernel);
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/regression/svr/LibSVR.h
Expand Up @@ -68,7 +68,7 @@ class CLibSVR : public CSVM
*
* @return classifie type LIBSVR
*/
virtual inline EClassifierType get_classifier_type() { return CT_LIBSVR; }
virtual EClassifierType get_classifier_type();

/** @return object name */
inline virtual const char* get_name() const { return "LibSVR"; }
Expand Down
33 changes: 33 additions & 0 deletions src/shogun/regression/svr/SVRLight.cpp
Expand Up @@ -59,6 +59,16 @@ CSVRLight::CSVRLight()
{
}

/** default destructor */
CSVRLight::~CSVRLight()
{
}

EClassifierType CSVRLight::get_classifier_type()
{
return CT_SVRLIGHT;
}

bool CSVRLight::train_machine(CFeatures* data)
{
//certain setup params
Expand Down Expand Up @@ -360,6 +370,29 @@ void* CSVRLight::update_linear_component_linadd_helper(void *params_)
return NULL ;
}

int32_t CSVRLight::regression_fix_index(int32_t i)
{
if (i>=num_vectors)
i=2*num_vectors-1-i;

return i;
}

int32_t CSVRLight::regression_fix_index2(
int32_t i, int32_t num_vectors)
{
if (i>=num_vectors)
i=2*num_vectors-1-i;

return i;
}

float64_t CSVRLight::compute_kernel(int32_t i, int32_t j)
{
i=regression_fix_index(i);
j=regression_fix_index(j);
return kernel->kernel(i, j);
}

void CSVRLight::update_linear_component(
int32_t* docs, int32_t* label, int32_t *active2dnum, float64_t *a,
Expand Down
29 changes: 6 additions & 23 deletions src/shogun/regression/svr/SVRLight.h
Expand Up @@ -75,13 +75,13 @@ class CSVRLight: public CSVMLight
CSVRLight(float64_t C, float64_t epsilon, CKernel* k, CLabels* lab);

/** default destructor */
virtual ~CSVRLight() { }
virtual ~CSVRLight();

/** get classifier type
*
* @return classifier type SVRLIGHT
*/
virtual inline EClassifierType get_classifier_type() { return CT_SVRLIGHT; }
virtual EClassifierType get_classifier_type();

/** SVR learn */
void svr_learn();
Expand Down Expand Up @@ -201,41 +201,24 @@ class CSVRLight: public CSVMLight
* @param i i
* @return fix index
*/
inline int32_t regression_fix_index(int32_t i)
{
if (i>=num_vectors)
i=2*num_vectors-1-i;

return i;
}
int32_t regression_fix_index(int32_t i);

/** regression fix index2
*
* @param i i
* @param num_vectors number of vectors
* @return fix index
*/
static inline int32_t regression_fix_index2(
int32_t i, int32_t num_vectors)
{
if (i>=num_vectors)
i=2*num_vectors-1-i;

return i;
}
static int32_t regression_fix_index2(
int32_t i, int32_t num_vectors);

/** compute kernel at given index
*
* @param i index i
* @param j index j
* @return kernel value at i,j
*/
inline virtual float64_t compute_kernel(int32_t i, int32_t j)
{
i=regression_fix_index(i);
j=regression_fix_index(j);
return kernel->kernel(i, j);
}
virtual float64_t compute_kernel(int32_t i, int32_t j);

/** train regression
*
Expand Down

0 comments on commit 884c74a

Please sign in to comment.