import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pandas import DataFrame
import kmapper as km
import sklearn
d = {'x': np.cos(np.arange(1,100)), 'y': np.sin(np.arange(1,100))}
df=DataFrame(data=d)
mapper = km.KeplerMapper(verbose=2)
lens = mapper.fit_transform(df)
complex = mapper.map(lens,df,
clusterer=sklearn.cluster.DBSCAN(eps=0.1, min_samples=5),
nr_cubes=10, overlap_perc=0.5)
mapper.visualize(complex, path_html="/home/dhananjay/kepler-mapper/keplermapper-fig8-xaxis.html",
title="fig8-xaxis")
..Composing projection pipeline length 1:
Projections: sum
Distance matrices: False
Scalers: MinMaxScaler(copy=True, feature_range=(0, 1))
..Projecting on data shaped (99, 2)
..Projecting data using: sum
..Scaling with: MinMaxScaler(copy=True, feature_range=(0, 1))
Mapping on data shaped (99, 2) using lens shaped (99, 1)
Minimal points in hypercube before clustering: 1
Creating 10 hypercubes.
There are 19 points in cube_0 / 10
Found 0 clusters in cube_0
There are 10 points in cube_1 / 10
Found 0 clusters in cube_1
There are 9 points in cube_2 / 10
Found 0 clusters in cube_2
There are 11 points in cube_3 / 10
Found 0 clusters in cube_3
There are 28 points in cube_4 / 10
Found 0 clusters in cube_4
There are 17 points in cube_5 / 10
Found 0 clusters in cube_5
There are 9 points in cube_6 / 10
Found 0 clusters in cube_6
There are 9 points in cube_7 / 10
Found 0 clusters in cube_7
There are 12 points in cube_8 / 10
Found 0 clusters in cube_8
There are 14 points in cube_9 / 10
Found 0 clusters in cube_9
Created 0 edges and 0 nodes in 0:00:00.020664.
kmapper/kmapper.py:133: FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead
X = np.sum(X, axis=1).reshape((X.shape[0], 1))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-42-d130d74910ae> in <module>()
12 # Visualize it
13 mapper.visualize(complex, path_html="/home/dhananjay/kepler-mapper/keplermapper-fig8-xaxis.html",
---> 14 title="fig8-xaxis")
15
/home/dhananjay/kepler-mapper/kmapper/kmapper.pyc in visualize(self, graph, color_function, custom_tooltips, custom_meta, path_html, title, save_file, inverse_X, inverse_X_names, projected_X, projected_X_names)
438 """
439
--> 440 color_function = init_color_function(graph, color_function)
441 json_graph = dict_to_json(
442 graph, color_function, inverse_X, inverse_X_names, projected_X, projected_X_names, custom_tooltips)
/home/dhananjay/kepler-mapper/kmapper/visuals.pyc in init_color_function(graph, color_function)
9 # If no color_function provided we color by row order in data set
10 # Reshaping to 2-D array is required for sklearn 0.19
---> 11 n_samples = np.max([i for s in graph["nodes"].values() for i in s]) + 1
12 if color_function is None:
13 color_function = np.arange(n_samples).reshape(-1, 1)
/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.pyc in amax(a, axis, out, keepdims)
2270
2271 return _methods._amax(a, axis=axis,
-> 2272 out=out, **kwargs)
2273
2274
/usr/local/lib/python2.7/dist-packages/numpy/core/_methods.pyc in _amax(a, axis, out, keepdims)
24 # small reductions
25 def _amax(a, axis=None, out=None, keepdims=False):
---> 26 return umr_maximum(a, axis, None, out, keepdims)
27
28 def _amin(a, axis=None, out=None, keepdims=False):
**ValueError: zero-size array to reduction operation maximum which has no identity**