def test1(x): """Basic usage""" # instantiate a Mapper object """lmapper example usage""" filter = Eccentricity(exponent=2, metric="euclidean") cover = KeplerCover(nintervals=30, overlap=0.4) cluster = Linkage(method='single', metric='euclidean', cutoff=FirstGap(0.05)) mapper = lm.Mapper(data=x, filter=filter, cover=cover, cluster=cluster) mapper.fit(skeleton_only=True) """change of clustering algorithm""" newcluster = Linkage(method='single', metric='euclidean', cutoff=FirstGap(0.1)) mapper.set_params(cluster=newcluster) mapper.fit() mapper.plot() """change of clustering algorithm""" cluster = Linkage(method='single', metric='euclidean', cutoff=FirstGap(0.2)) mapper.set_params(cluster=cluster) mapper.fit() """change of filter using a string argument""" mapper.set_params(filter='Projection') mapper.fit() """change of all parameters using a string argument""" mapper.set_params(filter='Projection', cover='UniformCover', cluster='Linkage') mapper.fit() return mapper
def test(x): """Basic usage""" # instantiate a Mapper object start = time.time() filter = Projection(ax=2) cover = KeplerCover(nintervals=25, overlap=0.4) cluster = Linkage(method='single', metric='euclidean', cutoff=FirstGap(0.05)) mapper = lm.Mapper(data=x, filter=filter, cover=cover, cluster=cluster) mapper.fit(skeleton_only=True).plot() print('Martino mapper: {0:.4f} sec'.format(time.time()-start)) start = time.time() mapper = km.KeplerMapper(verbose=2) projected_data = mapper.fit_transform(x, projection=[2]) graph = mapper.map( projected_data, x, nr_cubes=25, overlap_perc=0.4, clusterer=sklearn.cluster.AgglomerativeClustering(linkage='single')) print('Kepler mapper: {0:.4f} sec'.format(time.time()-start)) return 0
def __init__(self, method='single', metric='euclidean', cutoff=FirstGap(0.1)): self._method = method self._cutoff = cutoff self._metric = metric
def main(): data = cat() filter = Projection(ax=0) cover = UniformCover(nintervals=15, overlap=0.4) cutoff = FirstGap(0.05) cluster = Linkage(method='single', metric="euclidean", cutoff=cutoff) mapper = lm.Mapper(data=data, filter=filter, cover=cover, cluster=cluster) mapper.fit() mapper.plot()
def test(x): """Basic usage""" # instantiate a Mapper object start = time.time() filter = Eccentricity(nthreads=1) cover = KeplerCover(nintervals=25, overlap=0.4) cluster = Linkage(method='single', metric='euclidean', cutoff=FirstGap(0.05)) mapper = lm.Mapper(data=x, filter=filter, cover=cover, cluster=cluster) mapper.fit(skeleton_only=True) print('1 thread: {0:.4f} sec'.format(time.time() - start)) start = time.time() filter = Eccentricity(nthreads=8) cover = KeplerCover(nintervals=25, overlap=0.4) cluster = Linkage(method='single', metric='euclidean', cutoff=FirstGap(0.05)) mapper = lm.Mapper(data=x, filter=filter, cover=cover, cluster=cluster) mapper.fit(skeleton_only=True) print('16 threads: {0:.4f} sec'.format(time.time() - start)) return 0
def test(x, y): """Basic usage""" # instantiate a Mapper object filter = Eccentricity(exponent=2, metric='correlation') cover = BalancedCover(nintervals=4, overlap=0.49) cluster = Linkage(method='average', metric='correlation', cutoff=FirstGap(0.01)) mapper = lm.Mapper(data=x, filter=filter, cover=cover, cluster=cluster) mapper.fit(skeleton_only=False) print("dimension = ", mapper.complex._dimension) predictor = mapp.BinaryClassifier(mapper=mapper, response_values=y, _lambda=0.015, a=0.5, beta=1) predictor.fit() # -------------------------- # predictor.plot_majority_votes() return predictor.leave_one_out(x)
def test(x, y): """Basic usage""" print(x.shape) # instantiate a Mapper object filter = Projection(ax=2) cover = UniformCover(nintervals=25, overlap=0.4) cluster = Linkage(method='single', metric='euclidean', cutoff=FirstGap(0.05)) mapper = lm.Mapper(data=x, filter=filter, cover=cover, cluster=cluster) mapper.fit(skeleton_only=True) print("dimension = ", mapper.complex._dimension) predictor = mapp.BinaryClassifier(mapper=mapper, response_values=y, _lambda=0.0, a=0.5, beta=2) predictor.fit() # .plot_majority_votes() return predictor.leave_one_out(x)