21 register_parameters();
27 register_parameters();
30 void CMulticlassOneVsOneStrategy::register_parameters()
124 if (votes[i] > vote_max)
128 dec_val_max = dec_vals[i];
130 else if (votes[i] == vote_max)
132 if (dec_vals[i] > dec_val_max)
135 dec_val_max = dec_vals[i];
163 SG_ERROR(
"%s::rescale_output(): size(outputs) is not num_machines.\n",
get_name());
179 SG_ERROR(
"%s::rescale_outputs(): Unknown OVO probability heuristic type!\n",
get_name());
189 SG_ERROR(
"%s::rescale_heuris_price(): size(outputs) = %d != m_num_machines = %d\n",
201 new_outputs[j] += 1.0 / (outputs[m]+1E-12);
203 new_outputs[j] += 1.0 / (1.0-outputs[m]+1E-12);
206 new_outputs[j] = 1.0 / (new_outputs[j] - m_num_classes + 2);
212 for (int32_t i=0; i<new_outputs.
vlen; i++)
213 outputs[i] = new_outputs[i] / norm;
221 SG_ERROR(
"%s::rescale_heuris_hastie(): size(outputs) = %d != m_num_machines = %d\n",
233 new_outputs[j] += outputs[m];
235 new_outputs[j] += 1.0-outputs[m];
238 new_outputs[j] *= 2.0 / (m_num_classes * (m_num_classes - 1));
239 new_outputs[j] += 1E-10;
248 prev_outputs = new_outputs.
clone();
251 mu[m] = new_outputs[indx1[m]] / (new_outputs[indx1[m]] + new_outputs[indx2[m]]);
273 new_outputs[j] *= numerator / denominator;
277 for (int32_t i=0; i<new_outputs.
vlen; i++)
278 new_outputs[i] /= norm;
281 for (int32_t i=0; i<new_outputs.
vlen; i++)
282 prev_outputs[i] -= new_outputs[i];
285 SG_DEBUG(
"[Hastie's heuristic] gap = %.12f\n", gap);
288 for (int32_t i=0; i<new_outputs.
vlen; i++)
289 outputs[i] = new_outputs[i];
297 SG_ERROR(
"%s::rescale_heuris_hamamura(): size(outputs) = %d != m_num_machines = %d\n",
309 new_outputs[j] *= outputs[m];
311 new_outputs[j] *= 1-outputs[m];
314 new_outputs[j] += 1E-10;
319 for (int32_t i=0; i<new_outputs.
vlen; i++)
320 outputs[i] = new_outputs[i] / norm;
virtual SGVector< int32_t > train_prepare_next()
int32_t m_train_pair_idx_2
2nd index of current submachine being trained
double norm(double *v, double p, int n)
void rescale_heuris_hamamura(SGVector< float64_t > outputs, const SGVector< int32_t > indx1, const SGVector< int32_t > indx2)
CMulticlassLabels * m_orig_labels
original multiclass labels
virtual int32_t get_num_labels() const
virtual void train_start(CMulticlassLabels *orig_labels, CBinaryLabels *train_labels)
int32_t m_train_pair_idx_1
1st index of current submachine being trained
static T sum(T *vec, int32_t len)
return sum(vec)
SGVector< int32_t > m_num_samples
number of samples per machine
static int32_t arg_max(T *vec, int32_t inc, int32_t len, T *maxv_ptr=NULL)
return arg_max(vec)
CMulticlassOneVsOneStrategy()
int32_t m_num_classes
number of classes in this problem
Multiclass Labels for multi-class classification.
void rescale_heuris_hastie(SGVector< float64_t > outputs, const SGVector< int32_t > indx1, const SGVector< int32_t > indx2)
int32_t m_train_iter
index of current iterations
virtual const char * get_name() const
virtual void rescale_outputs(SGVector< float64_t > outputs)
SGVector< T > clone() const
static void fill_vector(T *vec, int32_t len, T value)
virtual bool train_has_more()
void rescale_heuris_price(SGVector< float64_t > outputs, const SGVector< int32_t > indx1, const SGVector< int32_t > indx2)
all of classes and functions are contained in the shogun namespace
CBinaryLabels * m_train_labels
labels used to train the submachines
int32_t m_num_machines
number of machines
Binary Labels for binary classification.
class MulticlassStrategy used to construct generic multiclass classifiers with ensembles of binary cl...
virtual SGVector< int32_t > train_prepare_next()
void resize_vector(int32_t n)
static T qsq(T *x, int32_t len, float64_t q)
|| x ||_q^q
virtual void train_start(CMulticlassLabels *orig_labels, CBinaryLabels *train_labels)
EProbHeuristicType get_prob_heuris_type()
static T abs(T a)
return the absolute value of a number
virtual int32_t decide_label(SGVector< float64_t > outputs)