Skip to content

Commit

Permalink
use get and set in SVM class
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeLing committed Mar 15, 2017
1 parent 6400d84 commit 06f601d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/shogun/classifier/svm/SVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,26 @@ void CSVM::set_defaults(int32_t num_sv)
SG_ADD(&m_linear_term, "linear_term", "Linear term in qp.",
MS_NOT_AVAILABLE);

callback=NULL;
mkl=NULL;
set_callback_function(NULL, NULL);

svm_loaded=false;
set_loaded_status(false);

epsilon=1e-5;
tube_epsilon=1e-2;
set_epsilon(1e-5);
set_tube_epsilon(1e-2);

nu=0.5;
C1=1;
C2=1;
set_nu(0.5);
set_C(1,1);

objective=0;
set_objective(0);

qpsize=41;
use_bias=true;
use_shrinking=true;
use_batch_computation=true;
use_linadd=true;
set_qpsize(41);
set_bias_enabled(true);
set_linadd_enabled(true);
set_shrinking_enabled(true);
set_batch_computation_enabled(true);

if (num_sv>0)
create_new_model(num_sv);
if (num_sv>0)
create_new_model(num_sv);
}

bool CSVM::load(FILE* modelfl)
Expand Down Expand Up @@ -194,7 +192,7 @@ bool CSVM::load(FILE* modelfl)
line_number++;
}

svm_loaded=result;
set_loaded_status(result);
SG_RESET_LOCALE;
return result;
}
Expand Down Expand Up @@ -270,10 +268,10 @@ float64_t CSVM::compute_svm_primal_objective()

if (m_labels && kernel)
{
float64_t C2_tmp=C1;
float64_t C2_tmp=get_C1();
if(C2>0)
{
C2_tmp=C2;
C2_tmp=get_C2();
}

for (int32_t i=0; i<n; i++)
Expand Down
15 changes: 15 additions & 0 deletions src/shogun/classifier/svm/SVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@ class CSVM : public CKernelMachine
return objective;
}

/** check if svm been loaded
*
* @return if svm_loaded is true
*/
inline bool get_loaded_status() { return svm_loaded; }

/** set svm loaded status
*
* @loaded if svm been loaded
*/
inline void set_loaded_status(bool loaded)
{
svm_loaded = loaded;
};

/** set callback function svm optimizers may call when they have a new
* (small) set of alphas
*
Expand Down

0 comments on commit 06f601d

Please sign in to comment.