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)
42 ASSERT(m_labels && m_labels->get_num_labels())
46 if (m_labels->get_num_labels() != data->get_num_vectors())
47 SG_ERROR(
"Number of training vectors does not match number of labels\n")
48 kernel->init(data, data);
52 prob.KER=
new sKernel(kernel, lab.
vlen);
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;
63 prob.c_const = get_C1();
64 prob.chunk_size = get_qpsize();
65 prob.linadd = get_linadd_enabled();
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++;
116 create_new_model(num_sv);
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)
125 set_support_vector(k, i);
126 set_alpha(k++, solution[i]*((
CBinaryLabels*) m_labels)->get_label(i));
135 #endif //USE_GPL_SHOGUN
The class Labels models labels, i.e. class assignments of objects.
void set_objective(float64_t v)
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
A generic Support Vector Machine Interface.
Binary Labels for binary classification.