elif kernel == "ODDST": print "Using ST kernel" Vectorizer = ODDSTVectorizer(r=max_radius, l=la, normalization=normalization) elif kernel == "NSPDK": print "Using NSPDK kernel, lambda parameter interpreted as d" Vectorizer = NSPDKVectorizer(r=max_radius, d=int(la), normalization=normalization) else: print "Unrecognized kernel" m = 4000 d = 1 features = Vectorizer.transform(g_it.graphs) #Parallel ,njobs featnew = [] print "examples, features", features.shape for i in xrange(features.shape[0]): exCMS = CountMinSketch(m, d) ex = features[i][0] #W=csr_matrix(ex) rows, cols = ex.nonzero() dot = 0.0 for row, col in zip(rows, cols): #((row,col), ex[row,col]) #print col, ex[row,col] #dot+=WCMS[col]*ex[row,col]
print "Using WL fast subtree kernel" Vectorizer = WLVectorizer(r=max_radius, normalization=normalization) elif kernel == "ODDST": print "Using ST kernel" Vectorizer = ODDSTVectorizer(r=max_radius, l=la, normalization=normalization) elif kernel == "NSPDK": print "Using NSPDK kernel, lambda parameter interpreted as d" Vectorizer = NSPDKVectorizer(r=max_radius, d=int(la), normalization=normalization) else: print "Unrecognized kernel" features = Vectorizer.transform(g_it.graphs) target_array = np.array(g_it.target) #features, target_array = #print km print "original shape", features.shape print "features loaded, hashing..." featuresCMS = [0] * features.shape[0] for i in xrange(features.shape[0]): generateCMS(featuresCMS, features[i][0], i) #pool = multiprocessing.Pool(processes=4) #pool.map(generateCMS, features[i][0],i) # pool.close() # pool.join() # exCMS=CountMinSketch(m,d) #