Note
Go to the end to download the full example code.
Basic Use¶
Generating data¶

Projecting our data¶
projection = data[:, 0]
plt.scatter(data[:, 0], data[:, 1], label="data")
plt.scatter(projection, np.zeros_like(projection), label="projection")
plt.legend()
plt.show()

Covering our data¶
import zen_mapper as zm
cover, _ = zm.width_balanced_cover(
n_elements=3,
percent_overlap=0.4,
data=projection,
)
for i, c in enumerate(cover):
plt.scatter(
projection[c],
np.full_like(c, i),
label=f"Cover element: {i + 1}",
)
plt.legend()
plt.show()

Pulling back¶

Defining a clusterer¶
from sklearn.cluster import AgglomerativeClustering
sk = AgglomerativeClustering(
linkage="single",
n_clusters=None,
distance_threshold=0.2,
)
clusterer = zm.sk_learn(sk)
Computing the mapper graph¶
Visualizing the mapper graph¶

Total running time of the script: (0 minutes 0.291 seconds)