-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoisy_circle.py
More file actions
41 lines (32 loc) · 818 Bytes
/
noisy_circle.py
File metadata and controls
41 lines (32 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import numpy as np
import sys
from mapper import Mapper
def noisy_circle(points=100, noise=0.1):
"""
Generates points of a noisy circle (with radius 1).
"""
# Generate circle coordinates.
d = np.linspace(0, 2 * np.pi, points, endpoint=False)
x = np.cos(d)
y = np.sin(d)
z = np.zeros(points)
# Add Gaussian noise.
x = np.random.normal(x, noise)
y = np.random.normal(y, noise)
return np.vstack((x, y, z)).T
points = noisy_circle()
print(points.shape)
mapper = Mapper(
coordinate=1,
bins=3,
clustering_function="agglomerative",
linkage="average",
distance=1.5,
)
graph = mapper.fit(points)
mapper.plot_vertices()
mapper.plot_intervals()
mapper.plot_clusters()
mapper.plot_graph()
mapper.plot_graph_in_plane()
mapper.plot_persistence_homology()