def converter_locallylinearembedding_modular(data,k): from shogun.Features import RealFeatures from shogun.Converter import LocallyLinearEmbedding features = RealFeatures(data) converter = LocallyLinearEmbedding() converter.set_target_dim(1) converter.set_k(k) converter.apply(features) return features
def converter_locallylinearembedding_modular(data, k): from shogun.Features import RealFeatures from shogun.Converter import LocallyLinearEmbedding features = RealFeatures(data) converter = LocallyLinearEmbedding() converter.set_target_dim(1) converter.set_k(k) converter.apply(features) return features
def preprocessor_dimensionreductionpreprocessor_modular(data, k): from shogun.Features import RealFeatures from shogun.Preprocessor import DimensionReductionPreprocessor from shogun.Converter import LocallyLinearEmbedding features = RealFeatures(data) converter = LocallyLinearEmbedding() converter.set_k(k) preprocessor = DimensionReductionPreprocessor(converter) preprocessor.init(features) preprocessor.apply_to_feature_matrix(features) return features
def converter_locallylinearembedding_modular(data, k): try: from shogun.Features import RealFeatures from shogun.Converter import LocallyLinearEmbedding features = RealFeatures(data) converter = LocallyLinearEmbedding() converter.set_target_dim(1) converter.set_k(k) converter.apply(features) return features except ImportError: print('No Eigen3 available')
def converter_locallylinearembedding_modular (data,k): try: from shogun.Features import RealFeatures from shogun.Converter import LocallyLinearEmbedding features = RealFeatures(data) converter = LocallyLinearEmbedding() converter.set_target_dim(1) converter.set_k(k) converter.apply(features) return features except ImportError: print('No Eigen3 available')
import numpy numpy.random.seed(40) tt = numpy.genfromtxt('../../data/toy/swissroll_color.dat', unpack=True).T X = numpy.genfromtxt('../../data/toy/swissroll.dat', unpack=True).T N = X.shape[1] converters = [] from shogun.Converter import LocallyLinearEmbedding lle = LocallyLinearEmbedding() lle.set_k(9) converters.append((lle, "LLE with k=%d" % lle.get_k())) from shogun.Converter import MultidimensionalScaling mds = MultidimensionalScaling() converters.append((mds, "Classic MDS")) lmds = MultidimensionalScaling() lmds.set_landmark(True) lmds.set_landmark_number(20) converters.append( (lmds, "Landmark MDS with %d landmarks" % lmds.get_landmark_number())) from shogun.Converter import Isomap cisomap = Isomap() cisomap.set_k(9) converters.append((cisomap, "Isomap with k=%d" % cisomap.get_k())) from shogun.Converter import DiffusionMaps from shogun.Kernel import GaussianKernel dm = DiffusionMaps() dm.set_t(2)
import numpy numpy.random.seed(40) tt = numpy.genfromtxt('../../../../data/toy/swissroll_color.dat',unpack=True).T X = numpy.genfromtxt('../../../../data/toy/swissroll.dat',unpack=True).T N = X.shape[1] converters = [] from shogun.Converter import LocallyLinearEmbedding lle = LocallyLinearEmbedding() lle.set_k(9) converters.append((lle, "LLE with k=%d" % lle.get_k())) from shogun.Converter import MultidimensionalScaling mds = MultidimensionalScaling() converters.append((mds, "Classic MDS")) lmds = MultidimensionalScaling() lmds.set_landmark(True) lmds.set_landmark_number(20) converters.append((lmds,"Landmark MDS with %d landmarks" % lmds.get_landmark_number())) from shogun.Converter import Isomap cisomap = Isomap() cisomap.set_k(9) converters.append((cisomap,"Isomap with k=%d" % cisomap.get_k())) from shogun.Converter import DiffusionMaps from shogun.Kernel import GaussianKernel dm = DiffusionMaps() dm.set_t(20) kernel = GaussianKernel(100,1.0)