kmapper.Cover

class kmapper.Cover(n_cubes=10, perc_overlap=0.5, limits=None, verbose=0)[source]

Helper class that defines the default covering scheme

It calculates the cover based on the following formula for overlap. (https://arxiv.org/pdf/1706.00204.pdf)

             |cube[i] intersection cube[i+1]|
overlap = --------------------------------------
                      |cube[i]|
Parameters
  • n_cubes (int) – Number of hypercubes along each dimension. Sometimes referred to as resolution.

  • perc_overlap (float) – Amount of overlap between adjacent cubes calculated only along 1 dimension.

  • limits (Numpy Array (n_dim,2)) – (lower bound, upper bound) for every dimension If a value is set to np.float(‘inf’), the bound will be assumed to be the min/max value of the dimension Also, if limits == None, the limits are defined by the maximum and minimum value of the lens for all dimensions. i.e. [[min_1, max_1], [min_2, max_2], [min_3, max_3]]

Example

>>> import numpy as np
>>> from kmapper.cover import Cover
>>> data = np.random.random((100,2))
>>> cov = Cover(n_cubes=15, perc_overlap=0.75)
>>> cube_centers = cov.fit(data)
>>> cov.transform_single(data, cube_centers[0])
array([[0.3594448 , 0.07428465],
       [0.14490332, 0.01395559],
       [0.94988668, 0.03983579],
       [0.73517978, 0.09420806],
       [0.16903735, 0.06901085],
       [0.81578595, 0.10708731],
       [0.26923572, 0.12216203],
       [0.89203167, 0.0711279 ],
       [0.80442115, 0.10220901],
       [0.33210782, 0.04365007],
       [0.52207707, 0.05892861],
       [0.26589744, 0.08502856],
       [0.02360067, 0.1263653 ],
       [0.29855631, 0.01209373]])
>>> hyper_cubes = cov.transform(data, cube_centers)
__init__(n_cubes=10, perc_overlap=0.5, limits=None, verbose=0)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([n_cubes, perc_overlap, limits, …])

Initialize self.

fit(data)

Fit a cover on the data.

fit_transform(data)

transform(data[, centers])

Find entries of all hypercubes.

transform_single(data, center[, i])

Compute entries of data in hypercube centered at center