enable_states="confusion")
// on balanced
e = cve(ds__)
tpr_1 = cve.states.confusion.stats["TPR"][1]
// on disbalanced
e = cve(ds_)
tpr_2 = cve.states.confusion.stats["TPR"][1]
// Set "1 C per label"
// recreate cvte since previous might have operated on copies
cve = CrossValidatedTransferError(TransferError(clf), NFoldSplitter(),
enable_states="confusion")
oldC = clf.params.C
// TODO: provide clf.params.C not with a tuple but dictionary
// with C per label (now order is deduced in a cruel way)
ratio = N.sqrt(float(spl[ds_.UL[0]])/spl[ds_.UL[1]])
clf.params.C = (-1/ratio, -1*ratio)
try:
// on disbalanced but with balanced C
e_ = cve(ds_)
// reassign C
clf.params.C = oldC
except:
clf.params.C = oldC
raise
tpr_3 = cve.states.confusion.stats["TPR"][1]
// Actual tests
if cfg.getboolean("tests", "labile", default="yes"):
self.failUnless(tpr_1 > 0.25,
msg="Without disballance we should have some "
"hits, but got TPR=%.3f" % tpr_1)
self.failUnless(tpr_2 < 0.25,
msg="With disballance we should have almost no "
"hits for minor, but got TPR=%.3f" % tpr_2)