def __init__(self, basemodel, pessimistic=True, predict_from_probabilities=False, use_sample_weighting=True, max_iter=3000, verbose=1): self.model = basemodel self.pessimistic = pessimistic self.predict_from_probabilities = predict_from_probabilities self.use_sample_weighting = use_sample_weighting self.max_iter = max_iter self.verbose = verbose self.it = 0 # iteration counter self.noimprovementsince = 0 # log likelihood hasn't improved since this number of iterations self.maxnoimprovementsince = 3 # threshold for iterations without improvements (convergence is assumed when this is reached) self.buffersize = 200 # buffer for the last few discriminative likelihoods (used to check for convergence) self.lastdls = [0] * self.buffersize # best discriminative likelihood and corresponding soft labels; updated during training self.bestdl = numpy.infty self.bestlbls = [] # unique id self.id = str(unichr(numpy.random.randint(26) + 97)) + str( unichr(numpy.random.randint(26) + 97))
def keySymToUniChar(keySym): # pragma: no cover i = Gdk.keyval_to_unicode(keySym) if i: UniChar = unichr(i) else: UniChar = '' return UniChar
def unichr(space, code): "Return a Unicode string of one character with the given ordinal." # XXX range checking! try: c = __builtin__.unichr(code) except ValueError: raise OperationError(space.w_ValueError, space.wrap("unichr() arg out of range")) return space.wrap(c)
def draw_glyph(self, img, codepoint): draw = Draw(img) draw.text((0, 0), unichr(codepoint), font=self.tt, fill='#000000') return img
__all__ = ['Mark', 'MarkedError', 'echoerr', 'NON_PRINTABLE'] import sys import re try: from __builtin__ import unichr except ImportError: unichr = chr # NOQA NON_PRINTABLE = re.compile('[^\t\n\x20-\x7E' + unichr(0x85) + (unichr(0xA0) + '-' + unichr(0xD7FF)) + (unichr(0xE000) + '-' + unichr(0xFFFD)) + ']') def repl(s): return '<x%04x>' % ord(s.group()) def strtrans(s): return NON_PRINTABLE.sub(repl, s.replace('\t', '>---')) class Mark: def __init__(self, name, line, column, buffer, pointer): self.name = name self.line = line self.column = column self.buffer = buffer self.pointer = pointer
def unichr(i): return __builtin__.unichr(i)
def unichr(space, w_code): "Return a Unicode string of one character with the given ordinal." # XXX range checking! return space.newunicode([__builtin__.unichr(space.int_w(w_code))])