Mapper
Mapper documentation
gale.mapper
- gale.mapper.bootstrap_mapper_params(X: ndarray, f: ndarray, resolutions: list, gains: list, distances: list, clusterer=AgglomerativeClustering(linkage='single', n_clusters=None), ci=0.95, n=30, n_jobs=1) dict[source]
Bootstraps the data to figure out the best Mapper parameters through a greedy search.
- Parameters
X (np.ndarray) – Array of data. For GALE, this is the feature attribution output (n x k), where there are n samples with k feature attributions each.
f (np.ndarray) – Filter (lens) function. For GALE, the predicted probabilities are the lens function.
resolutions (list) – List of resolutions to test.
gains (list) – List of gains to test.
distances (list) – If using AgglomerativeClustering, this sets the distance threshold as (X.max() - X.min())*thresh.
clusterer (sklearn.base.ClusterMixin, optional) – Clustering method from sklearn. Defaults to AgglomerativeClustering(n_clusters=None, linkage=”single”).
ci (float, optional) – Confidence interval to create. Defaults to 0.95.
n (int, optional) – Number of bootstraps to run. Defaults to 30.
n_jobs (int, optional) – Number of processes for multiprocessing. Defaults to CPU count. -1 for all cores.
- Returns
Dictionary containing the Mapper parameters found in a greedy search
- Return type
dict
- gale.mapper.bottleneck_distance(mapper_a: dict, mapper_b: dict) float[source]
Calculates the bottleneck distance between two Mapper outputs (denoted A and B)
- Parameters
mapper_a (dict) – Mapper A, from create_mapper
mapper_b (dict) – Mapper B, from create_mapper
- Returns
the bottleneck distance
- Return type
float
- gale.mapper.create_mapper(X: ndarray, f: ndarray, resolution: int, gain: float, dist_thresh: float, clusterer=AgglomerativeClustering(linkage='single', n_clusters=None)) dict[source]
Runs Mapper on given some data, a filter function, and resolution + gain parameters.
- Parameters
X (np.ndarray) – Array of data. For GALE, this is the feature attribution output (n x k), where there are n samples with k feature attributions each.
f (np.ndarray) – Filter (lens) function. For GALE, the predicted probabilities are the lens function.
resolution (int) – Resolution (how wide each window is)
gain (float) – Gain (how much overlap between windows)
dist_thresh (float) – If using AgglomerativeClustering, this sets the distance threshold as (X.max() - X.min())*thresh. Ignored if clusterer is not AgglomerativeClustering
clusterer (sklearn.base.ClusterMixin, optional) – Clustering method from sklearn. Defaults to AgglomerativeClustering(n_clusters=None, linkage=”single”).
- Returns
Dictionary containing the Mapper output
- Return type
dict