Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nr_cubes_cover(self):
mapper = KeplerMapper()
with pytest.deprecated_call():
cover = Cover(nr_cubes=17) # strange number
assert cover.n_cubes == 17
def test_overlap_perc_cover(self):
mapper = KeplerMapper()
with pytest.deprecated_call():
cover = Cover(overlap_perc=17) # strange number
assert cover.perc_overlap == 17
# 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)
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()
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
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
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)
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