Пример #1
0
import numpy as np
from dyneusr import DyNeuGraph
from dyneusr.datasets import make_trefoil
from kmapper import KeplerMapper
from sklearn.decomposition import PCA

# Generate synthetic dataset
import tadasets
X = tadasets.sphere(n=500, r=1)

# Sort by first column
inds = np.argsort(X[:, 0])
X = X[inds].copy()
y = np.arange(X.shape[0])

# Generate shape graph using KeplerMapper
mapper = KeplerMapper(verbose=1)
lens = mapper.fit_transform(X, projection=PCA(2))
graph = mapper.map(lens, X, nr_cubes=6, overlap_perc=0.5)

# Visualize the shape graph using DyNeuSR's DyNeuGraph 
dG = DyNeuGraph(G=graph, y=y)
dG.visualize('dyneusr2D_sphere.html', template='2D', static=True, show=True)
Пример #2
0
 def test_r(self):
     r = 23
     s = tadasets.sphere(r=r)
     rs = np.fromiter((norm(p) for p in s), np.float64)
     assert np.all(rs <= r + 1e-5)
     assert np.all([r - 1e-5 <= rx <= r + 1e-5 for rx in rs])
Пример #3
0
 def test_ambient(self):
     s = tadasets.sphere(n=200, r=3, ambient=15)
     assert s.shape == (200, 15)
Пример #4
0
 def test_n(self):
     s = tadasets.sphere(n=543)
     assert s.shape[0] == 543