17 using namespace shogun;
20 :m_maxiter(maxiter), m_codelen(codelen), m_pposone(pposone)
22 if (!check_probability(pposone))
23 SG_ERROR(
"invalid probability of +1");
28 void CECOCRandomDenseEncoder::init()
37 if (!check_probability(pposone))
38 SG_ERROR(
"probability of 0, +1 and -1 must sum to one");
51 int32_t best_dist = 0;
59 for (int32_t i=0; i < codelen; ++i)
61 for (int32_t j=0; j < num_classes; ++j)
72 for (int32_t i=0; i < codelen; ++i)
74 bool p1_occur =
false, n1_occur =
false;
75 for (int32_t j=0; j < num_classes; ++j)
76 if (codebook(i, j) == 1)
78 else if (codebook(i, j) == -1)
81 if (!p1_occur || !n1_occur)
92 int32_t min_dist = std::numeric_limits<int32_t>::max();
93 for (int32_t i=0; i < num_classes; ++i)
95 for (int32_t j=i+1; j < num_classes; ++j)
104 if (min_dist > best_dist)
106 best_dist = min_dist;
107 std::copy(codebook.
matrix, codebook.
matrix + codelen*num_classes,
117 return best_codebook;