Ejemplo n.º 1
0
def embed(filename='words.dat'):
	print 'loading'
	words = []
	with open(filename) as f:
		words.extend([str.rstrip() for str in f.readlines()])
	print 'loaded', words

	converter = KernelLocallyLinearEmbedding()
	converter.set_k(20)
	converter.set_target_dim(2)
	converter.parallel.set_num_threads(1)
	embedding = converter.embed_kernel(word_kernel(words)).get_feature_matrix()
	return embedding,words
Ejemplo n.º 2
0
def embed(filename='words.dat'):
    print 'loading'
    words = []
    with open(filename) as f:
        words.extend([str.rstrip() for str in f.readlines()])
    print 'loaded', words

    converter = KernelLocallyLinearEmbedding()
    converter.set_k(20)
    converter.set_target_dim(2)
    converter.parallel.set_num_threads(1)
    embedding = converter.embed_kernel(word_kernel(words)).get_feature_matrix()
    return embedding, words
Ejemplo n.º 3
0
def converter_kernellocallylinearembedding_modular(data_fname, k):
    try:
        from modshogun import RealFeatures, KernelLocallyLinearEmbedding, LinearKernel, CSVFile

        features = RealFeatures(CSVFile(data_fname))

        kernel = LinearKernel()

        converter = KernelLocallyLinearEmbedding(kernel)
        converter.set_target_dim(1)
        converter.set_k(k)
        converter.apply(features)

        return features
    except ImportError:
        print('No Eigen3 available')
def converter_kernellocallylinearembedding_modular (data_fname,k):
	try:
		from modshogun import RealFeatures, KernelLocallyLinearEmbedding, LinearKernel, CSVFile

		features = RealFeatures(CSVFile(data_fname))

		kernel = LinearKernel()

		converter = KernelLocallyLinearEmbedding(kernel)
		converter.set_target_dim(1)
		converter.set_k(k)
		converter.apply(features)

		return features
	except ImportError:
		print('No Eigen3 available')