14 #include <shogun/lib/external/gpdt.h> 15 #include <shogun/lib/external/gpdtsolve.h> 27 :
CSVM(C, k, lab), model(NULL)
36 bool CGPBTSVM::train_machine(
CFeatures* data)
47 SG_ERROR(
"Number of training vectors does not match number of labels\n")
55 SG_INFO(
"%d trainlabels\n", prob.ell)
59 prob.maxmw =
kernel->get_cache_size();
61 prob.preprocess_size = -1;
62 prob.projection_projector = -1;
67 if (prob.chunk_size < 2) prob.chunk_size = 2;
68 if (prob.q <= 0) prob.q = prob.chunk_size / 3;
69 if (prob.q < 2) prob.q = 2;
70 if (prob.q > prob.chunk_size) prob.q = prob.chunk_size;
71 prob.q = prob.q & (~1);
76 SG_INFO("\nTRAINING PARAMETERS:\n")
77 SG_INFO("\tNumber of training documents: %d\n", prob.ell)
78 SG_INFO("\tq: %d\n", prob.chunk_size)
80 SG_INFO("\tC: %lf\n", prob.c_const)
81 SG_INFO("\tkernel type: %d\n", prob.ker_type)
82 SG_INFO("\tcache size: %dMb\n", prob.maxmw)
83 SG_INFO("\tStopping tolerance: %lf\n", prob.delta)
86 if (prob.preprocess_size == -1)
87 prob.preprocess_size = (int32_t) ( (
float64_t)prob.chunk_size * 1.5 );
89 if (prob.projection_projector == -1)
91 if (prob.chunk_size <= 20) prob.projection_projector = 0;
92 else prob.projection_projector = 1;
96 solution = SG_MALLOC(
float64_t, prob.ell);
97 prob.gpdtsolve(solution);
107 for (i = 0; i < prob.ell; i++)
109 if (solution[i] > prob.DELTAsv)
112 if (solution[i] > (prob.c_const - prob.DELTAsv)) bsv++;
119 SG_INFO(
"SV: %d BSV = %d\n", num_sv, bsv)
121 for (i = 0; i < prob.ell; i++)
123 if (solution[i] > prob.DELTAsv)
135 #endif //USE_GPL_SHOGUN
virtual bool init(CFeatures *lhs, CFeatures *rhs)
virtual ELabelType get_label_type() const =0
The class Labels models labels, i.e. class assignments of objects.
virtual int32_t get_num_labels() const =0
virtual int32_t get_num_vectors() const =0
void set_bias(float64_t bias)
bool set_alpha(int32_t idx, float64_t val)
void set_objective(float64_t v)
bool set_support_vector(int32_t idx, int32_t val)
all of classes and functions are contained in the shogun namespace
bool get_linadd_enabled()
The class Features is the base class of all feature objects.
A generic Support Vector Machine Interface.
Binary Labels for binary classification.
bool create_new_model(int32_t num)