Example #1
0
 def __call__(self, start, length, slicelen):
     assert start >= 0
     slicelen = min(length, slicelen)
     iostream = open(self.path, "rb")
     buf = np.empty(slicelen, dtype=self.dtype)
     itemsize = buf.dtype.itemsize
     iostream.seek(itemsize * start)
     state = (buf, iostream, start, length, slicelen)
     return Seq.from_next(state, next_data_chunk)
Example #2
0
    def __call__(self, start, length, slicelen):
        assert start >= 0 and start < len(self.vector)
        length = min(length, len(self.vector) - start)
        slicelen = min(length, slicelen)
        state = start, length, slicelen

        def f(from_to):
            return self.vector[from_to[0]:from_to[1]]

        return Seq.map(f, Seq.from_next(state, next_slice_indices))
Example #3
0
def growtree(factors, gcovariate, hcovariate, fm, eta, maxdepth, lambda_, gamma, minh, slicelen):

    length = len(gcovariate)
    maxnodecount = 2 ** maxdepth
    nodeids = np.zeros(length, dtype=np.uint8) if maxnodecount <= np.iinfo(np.uint8).max else np.zeros(length, dtype=np.uint16)

    loss0 = np.finfo(np.float32).max
    nodes0 = [LeafNode((0.0, 0.0), True, {f : np.full(len(f.levels), True) for f in factors}, loss0)]
    
    state0 = TreeGrowState(nodeids, nodes0, factors, gcovariate, hcovariate, gamma, lambda_, minh, slicelen)
    layers = Seq.tolist(Seq.take(Seq.from_next(state0, nextlayer), maxdepth))
    predict(state0.nodes, nodeids, fm, eta, lambda_)
    return layers, fm
Example #4
0
 def slicer(start, length, slicelen):
     length = min(self._length - start, length)
     slicelen = min(length, slicelen)
     buf = np.ones(slicelen, dtype = np.uint8)
     return Seq.map((lambda x: buf[x[0]:x[1]]), Seq.from_next((start, length, slicelen), ch.next_slice_indices))