@@ -0,0 +1,2176 @@
+# encoding=utf-8%0Aimport scipy.sparse as sp%0Aimport numpy as np%0Adef _load_svmlight_file(f, n_feature ,  mini_batch=200000):%0A%0A    data = %5B%5D%0A    indices = %5B%5D%0A    indptr = %5B0%5D%0A    query = %5B%5D%0A    aidbuf  =%5B%5D%0A%0A    labels = %5B%5D%0A%0A%0A    qid_prefix='qid'%0A    COLON = ':'%0A%0A    lnum = 0%0A%0A    for line in f:%0A        # skip comments%0A        line_parts = line.split()%0A        if len(line_parts) == 0:%0A            continue%0A%0A        target, qid, aid, features = line_parts%5B0%5D, line_parts%5B1%5D, line_parts%5B2%5D, line_parts%5B3:%5D%0A%0A        labels.append (  float(target) )%0A%0A        prev_idx = -1%0A        n_features = len(features)%0A        if n_features and features%5B0%5D.startswith(qid_prefix):%0A            _, value = features%5B0%5D.split(COLON, 1)%0A%0A%0A            query.append( int(value) )%0A            features.pop(0)%0A            n_features -= 1%0A%0A        _, value = qid.split(COLON, 1)%0A        query.append(int(value))%0A        _, value = aid.split(COLON, 1)%0A        aidbuf.append(int(value))%0A%0A%0A%0A%0A%0A        for i in xrange(0, n_features):%0A            idx_s, value = features%5Bi%5D.split(COLON, 1)%0A            idx = int(idx_s)%0A%0A            if idx %3C= prev_idx:%0A                raise ValueError(%22Feature indices in SVMlight/LibSVM data %22%0A                                 %22file should be sorted and unique.%22)%0A%0A            indices.append(idx)%0A%0A            data.append(float(value))%0A%0A            prev_idx = idx%0A        indptr.append(len(data))%0A        lnum +=1%0A%0A        if lnum %3E= mini_batch :%0A%0A            shape =(lnum, n_feature)%0A%0A            X = sp.csr_matrix((data, indices, indptr), shape)%0A            X.sort_indices()%0A%0A            yield ( X , np.array(labels), query, aidbuf)%0A            # clear data%0A            lnum = 0%0A%0A            data = %5B%5D%0A            indices = %5B%5D%0A            indptr = %5B0%5D%0A            query = %5B%5D%0A            labels = %5B%5D%0A            aidbuf = %5B%5D%0A    if lnum %3E 0:%0A        #%E5%B0%BE%E5%B7%B4%E4%B8%8A%E7%9A%84%E6%95%B0%E6%8D%AE%E5%85%B1%E4%BA%AB.%0A        shape = (lnum, n_feature)%0A%0A        X = sp.csr_matrix((data, indices, indptr), shape)%0A        X.sort_indices()%0A%0A        yield (X, np.array(labels), query, aidbuf)%0A%0A        lnum = 0%0A%0A        data = %5B%5D%0A        indices = %5B%5D%0A        indptr = %5B0%5D%0A        query = %5B%5D%0A        labels = %5B%5D%0A        aidbuf = %5B%5D%0A%0A%0A%0A%0A%0A

Create utils/utils.py