示例#1
0

This example generates a Mapper built from a point-cloud sampled from a 3D model of a cat.

`Visualization of the cat mapper <../../_static/cat.html>`_


"""

import numpy as np
import sklearn
import kmapper as km

data = np.genfromtxt('data/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="output/cat.html")

km.draw_matplotlib(graph)

import matplotlib.pyplot as plt
plt.show()
示例#2
0
    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.4))

# Create the visualizations (increased the graph_gravity for a tighter graph-look.)
print("Output graph examples to html")
# Tooltips with image data for every cluster member
mapper.visualize(graph,
                 title="Handwritten digits Mapper",
                 path_html="output/digits_custom_tooltips.html",
                 color_values=labels,
                 custom_tooltips=tooltip_s)
# Tooltips with the target y-labels for every cluster member
mapper.visualize(graph,
                 title="Handwritten digits Mapper",
                 path_html="output/digits_ylabel_tooltips.html",
                 custom_tooltips=labels)

# Matplotlib examples
km.draw_matplotlib(graph, layout="spring")
plt.show()
示例#3
0
 def test_nx_input(self, mapper):
     draw_matplotlib(km.to_networkx(mapper))
                       copy=True,
                       preference=None,
                       affinity='euclidean',
                       verbose=False))

##############################################################################################################
###creacion de las vizualizaciones(Incrementado el graph_gravity para una apariencia gráfica más ajustada.)###
##############################################################################################################
print("Output: Grafo de ejemplo para HTML")

### Tooltip con datos de imagen para cada miembro del cluster
mapper.visualize(
    graph,
    title="Algoritmo Mapper en digitos escritos a mano",
    path_html=
    "C:\\Users\ServW10\Documents\Spyder Projects\Mapper_AffinityPropagation_dataCluster.html",
    #color_function=labels,
    custom_tooltips=tooltip_s)

### Toolptips con el target y-labels para cada miembro del cluster
mapper.visualize(
    graph,
    title="Algoritmo Mapper en digitos escritos a mano",
    path_html=
    "C:\\Users\ServW10\Documents\Spyder Projects\Mapper_AffinityPropagation_labelsCluster.html",
    custom_tooltips=y)

# Matplotlib ejemplo para mostrar en consola y comparar
km.draw_matplotlib(graph)  #, layout="spring"
plt.show()
示例#5
0
 def test_mapper_input(self, mapper):
     draw_matplotlib(mapper)