4 using namespace shogun;
17 for (int32_t i=0; i<labels.
vlen; i++)
18 labels[i] = src[i]+threshold>=0 ? +1.0 : -1.0;
32 SG_SERROR(
"base_labels must be of dynamic type CBinaryLabels");
41 bool found_plus_one=
false;
42 bool found_minus_one=
false;
45 for (int32_t i=0; i<subset_size; i++)
54 SG_ERROR(
"%s%sNot a two class labeling label[%d]=%f (only +1/-1 "
55 "allowed)\n", context?context:
"", context?
": ":
"", i,
m_labels[real_i]);
61 SG_ERROR(
"%s%sNot a two class labeling - no positively labeled examples found\n",
62 context?context:
"", context?
": ":
"");
67 SG_ERROR(
"%s%sNot a two class labeling - no negatively labeled examples found\n",
68 context?context:
"", context?
": ":
"");
79 SG_DEBUG(
"entering CBinaryLabels::scores_to_probabilities()\n");
82 "confidences vector!\n",
get_name());
87 SG_DEBUG(
"counting number of positive and negative labels\n");
97 SG_DEBUG(
"%d pos; %d neg\n", prior1, prior0);
111 float64_t hiTarget=(prior1+1.0)/(prior1+2.0);
116 for (
index_t i=0; i<length; ++i)
130 for (
index_t i=0; i<length; ++i)
136 fval+=(t[i]-1)*fApB+CMath::log(1+
CMath::exp(fApB));
142 for (it=0; it<maxiter; ++it)
144 SG_DEBUG(
"Iteration %d, a=%f, b=%f, fval=%f\n", it, a, b, fval);
153 for (
index_t i=0; i<length; ++i)
191 while (stepsize>=minstep)
198 for (
index_t i=0; i<length; ++i)
204 newf+=(t[i]-1)*fApB+CMath::log(1+
CMath::exp(fApB));
208 if (newf<fval+0.0001*stepsize*gd)
216 stepsize=stepsize/2.0;
219 if (stepsize<minstep)
221 SG_WARNING(
"%s::scores_to_probabilities(): line search fails, A=%f, "
222 "B=%f, g1=%f, g2=%f, dA=%f, dB=%f, gd=%f\n",
223 get_name(), a, b, g1, g2, dA, dB, gd);
229 SG_WARNING(
"%s::scores_to_probabilities(): reaching maximal iterations,"
230 " g1=%f, g2=%f\n",
get_name(), g1, g2);
233 SG_DEBUG(
"fitted sigmoid: a=%f, b=%f\n", a, b);
243 SG_DEBUG(
"leaving CBinaryLabels::scores_to_probabilities()\n");