How to use the kmapper.Cover function in kmapper

To help you get started, we’ve selected a few kmapper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scikit-tda / kepler-mapper / test / test_backwards.py View on Github external
def test_nr_cubes_cover(self):
        mapper = KeplerMapper()

        with pytest.deprecated_call():
            cover = Cover(nr_cubes=17)  # strange number

        assert cover.n_cubes == 17
github scikit-tda / kepler-mapper / test / test_backwards.py View on Github external
def test_overlap_perc_cover(self):
        mapper = KeplerMapper()

        with pytest.deprecated_call():
            cover = Cover(overlap_perc=17)  # strange number

        assert cover.perc_overlap == 17
github scikit-tda / kepler-mapper / examples / breast-cancer / breast-cancer.py View on Github external
# We create a custom 1-D lens with Isolation Forest
model = ensemble.IsolationForest(random_state=1729)
model.fit(X)
lens1 = model.decision_function(X).reshape((X.shape[0], 1))

# We create another 1-D lens with L2-norm
mapper = km.KeplerMapper(verbose=3)
lens2 = mapper.fit_transform(X, projection="l2norm")

# Combine both lenses to create a 2-D [Isolation Forest, L^2-Norm] lens
lens = np.c_[lens1, lens2]

# Create the simplicial complex
graph = mapper.map(lens,
                   X,
                   cover=km.Cover(n_cubes=15, perc_overlap=0.7),
                   clusterer=sklearn.cluster.KMeans(n_clusters=2,
                                                    random_state=1618033))

# Visualization
mapper.visualize(graph,
                 path_html="breast-cancer.html",
                 title="Wisconsin Breast Cancer Dataset",
                 custom_tooltips=y)
github scikit-tda / kepler-mapper / _downloads / f11bec4c8f11fa29129f75a61064b3ca / plot_horse.py View on Github external
import sklearn

import kmapper as km

data = np.genfromtxt('data/horse-reference.csv', delimiter=',')

mapper = km.KeplerMapper(verbose=2)


lens = mapper.fit_transform(data)


graph = mapper.map(lens,
                   data,
                   clusterer=sklearn.cluster.DBSCAN(eps=0.1, min_samples=5),
                   cover=km.Cover(30, 0.2))

mapper.visualize(graph,
                 path_html="output/horse.html",
                 custom_tooltips=np.arange(len(lens)))


km.drawing.draw_matplotlib(graph)
plt.show()
github scikit-tda / kepler-mapper / examples / cat / cat.py View on Github external
import numpy as np
import sklearn
import kmapper as km

data = np.genfromtxt('cat-reference.csv', delimiter=',')

mapper = km.KeplerMapper(verbose=2)


lens = mapper.fit_transform(data)

graph = mapper.map(lens,
                   data,
                   clusterer=sklearn.cluster.DBSCAN(eps=0.1, min_samples=5),
                   cover=km.Cover(n_cubes=15, perc_overlap=0.2))

mapper.visualize(graph,
                 path_html="cat_keplermapper_output.html")

# You may want to visualize the original point cloud data in 3D scatter too
"""
import matplotlib.pyplot as plt
github scikit-tda / kepler-mapper / examples / horse / horse.py View on Github external
import numpy as np
import sklearn
import kmapper as km

data = np.genfromtxt('horse-reference.csv', delimiter=',')

mapper = km.KeplerMapper(verbose=2)


lens = mapper.fit_transform(data)


graph = mapper.map(lens,
                   data,
                   clusterer=sklearn.cluster.DBSCAN(eps=0.1, min_samples=5),
                   cover=km.Cover(30, 0.2))

mapper.visualize(graph,
                 path_html="horse_keplermapper_output.html",
                 custom_tooltips=np.arange(len(lens)))

# You may want to visualize the original point cloud data in 3D scatter too
"""
import matplotlib.pyplot as plt
github scikit-tda / kepler-mapper / examples / digits / digits.py View on Github external
tooltip_s.append(img_tag)
    output.close()

tooltip_s = np.array(tooltip_s)  # need to make sure to feed it as a NumPy array, not a list

# Initialize to use t-SNE with 2 components (reduces data to 2 dimensions). Also note high overlap_percentage.
mapper = km.KeplerMapper(verbose=2)

# Fit and transform data
projected_data = mapper.fit_transform(data,
                                      projection=sklearn.manifold.TSNE())

# Create the graph (we cluster on the projected data and suffer projection loss)
graph = mapper.map(projected_data,
                   clusterer=sklearn.cluster.DBSCAN(eps=0.3, min_samples=15),
                   cover=km.Cover(35, 0.9))

# Create the visualizations (increased the graph_gravity for a tighter graph-look.)

# Tooltips with image data for every cluster member
mapper.visualize(graph,
                 path_html="keplermapper_digits_custom_tooltips.html",
                 custom_tooltips=tooltip_s)
# Tooltips with the target y-labels for every cluster member
mapper.visualize(graph,
                 path_html="keplermapper_digits_ylabel_tooltips.html",
                 custom_tooltips=labels)
github scikit-tda / kepler-mapper / examples / lion / lion.py View on Github external
import numpy as np
import sklearn
import kmapper as km

data = np.genfromtxt('lion-reference.csv', delimiter=',')

mapper = km.KeplerMapper(verbose=1)

lens = mapper.fit_transform(data)

graph = mapper.map(lens,
                   data,
                   clusterer=sklearn.cluster.DBSCAN(eps=0.1, min_samples=5),
                   cover=km.Cover(n_cubes=10, perc_overlap=0.2))

mapper.visualize(graph,
                 path_html="lion_keplermapper_output.html")

# You may want to visualize the original point cloud data in 3D scatter too
"""
import matplotlib.pyplot as plt