def converter_stochasticproximityembedding_modular (data_fname, k):
	try:
		from modshogun import RealFeatures,StochasticProximityEmbedding, SPE_GLOBAL, SPE_LOCAL, CSVFile
		
		features = RealFeatures(CSVFile(data_fname))
			
		converter = StochasticProximityEmbedding()
		converter.set_target_dim(1)
		converter.set_nupdates(40)
		# Embed with local strategy
		converter.set_k(k)
		converter.set_strategy(SPE_LOCAL)
		converter.embed(features)
		# Embed with global strategy
		converter.set_strategy(SPE_GLOBAL)
		converter.embed(features)

		return features
	except ImportError:
		print('No Eigen3 available')
示例#2
0
def converter_stochasticproximityembedding_modular (data_fname, k):
	try:
		from modshogun import RealFeatures,StochasticProximityEmbedding, SPE_GLOBAL, SPE_LOCAL, CSVFile

		features = RealFeatures(CSVFile(data_fname))

		converter = StochasticProximityEmbedding()
		converter.set_target_dim(1)
		converter.set_nupdates(40)
		# Embed with local strategy
		converter.set_k(k)
		converter.set_strategy(SPE_LOCAL)
		converter.embed(features)
		# Embed with global strategy
		converter.set_strategy(SPE_GLOBAL)
		converter.embed(features)

		return features
	except ImportError:
		print('No Eigen3 available')
示例#3
0
def visualize_spe(features, labels):
    from modshogun import StochasticProximityEmbedding, SPE_GLOBAL

    converter = StochasticProximityEmbedding()
    converter.set_strategy(SPE_GLOBAL)
    converter.set_k(10)
    converter.set_target_dim(2)
    converter.set_nupdates(40)

    embedding = converter.embed(features)

    plot_data(embedding.get_feature_matrix(), labels.get_labels())
    pyplot.show()
示例#4
0
def visualize_spe(features,labels):
	from modshogun import StochasticProximityEmbedding, SPE_GLOBAL

	converter = StochasticProximityEmbedding()
	converter.set_strategy(SPE_GLOBAL)
	converter.set_k(10)
	converter.set_target_dim(2)
	converter.set_nupdates(40);

	embedding = converter.embed(features)

	plot_data(embedding.get_feature_matrix(),labels.get_labels())
	pyplot.show()
pylab.title('Original 3D Helix')

# Create features instance
features = RealFeatures(X)

# Create Stochastic Proximity Embedding converter instance
converter = StochasticProximityEmbedding()

# Set target dimensionality
converter.set_target_dim(2)
# Set strategy
converter.set_strategy(SPE_GLOBAL)

# Compute SPE embedding
embedding = converter.embed(features)

X = embedding.get_feature_matrix()

fig.add_subplot(2, 2, 2)

pylab.plot(X[0, y1], X[1, y1], 'ro')
pylab.plot(X[0, y2], X[1, y2], 'go')

pylab.title('SPE with global strategy')

# Compute a second SPE embedding with local strategy
converter.set_strategy(SPE_LOCAL)
converter.set_k(12)
embedding = converter.embed(features)
示例#6
0
pylab.title('Original 3D Helix')

# Create features instance
features = RealFeatures(X)

# Create Stochastic Proximity Embedding converter instance
converter = StochasticProximityEmbedding()

# Set target dimensionality
converter.set_target_dim(2)
# Set strategy
converter.set_strategy(SPE_GLOBAL)

# Compute SPE embedding
embedding = converter.embed(features)

X = embedding.get_feature_matrix()

fig.add_subplot(2, 2, 2)

pylab.plot(X[0, y1], X[1, y1], 'ro')
pylab.plot(X[0, y2], X[1, y2], 'go')

pylab.title('SPE with global strategy')

# Compute a second SPE embedding with local strategy
converter.set_strategy(SPE_LOCAL)
converter.set_k(12)
embedding = converter.embed(features)