SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MulticlassOneVsRestStrategy.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2012 Chiyuan Zhang
8  * Copyright (C) 2012 Chiyuan Zhang
9  */
10 
14 
15 using namespace shogun;
16 
19 {
20 }
21 
23 {
24  for (int32_t i=0; i < m_orig_labels->get_num_labels(); ++i)
25  {
26  if (((CMulticlassLabels*) m_orig_labels)->get_int_label(i)==m_train_iter)
27  ((CBinaryLabels*) m_train_labels)->set_label(i, +1.0);
28  else
29  ((CBinaryLabels*) m_train_labels)->set_label(i, -1.0);
30  }
31 
32  // increase m_train_iter *after* setting labels
34 
35  return SGVector<int32_t>();
36 }
37 
39 {
42 
43  return SGVector<float64_t>::arg_max(outputs.vector, 1, outputs.vlen);
44 }
45 
47 {
48  float64_t* outputs_ = SG_MALLOC(float64_t, outputs.vlen);
49  int32_t* indices_ = SG_MALLOC(int32_t, outputs.vlen);
50  for (int32_t i=0; i<outputs.vlen; i++)
51  {
52  outputs_[i] = outputs[i];
53  indices_[i] = i;
54  }
55  CMath::qsort_backward_index(outputs_,indices_,outputs.vlen);
56  SGVector<index_t> result(n_outputs);
57  for (int32_t i=0; i<n_outputs; i++)
58  result[i] = indices_[i];
59  SG_FREE(outputs_);
60  SG_FREE(indices_);
61  return result;
62 }
63 

SHOGUN Machine Learning Toolbox - Documentation