Appendix A
API reference
This appendix lists every public class and function of graphclust, module by module, with the first sentence of its docstring. The lists are generated from the __all__ attribute of each module by book/build_api_appendix.py, so they are complete by construction; the full signatures, parameters, and attributes are in the online documentation and in the docstrings (help(graphclust.TRNMap)). All estimators follow the scikit-learn conventions summarized in section 1.5; the notation of the docstrings is that of table 1.1.
A.1 graphclust.graphs: Graphs from data
|
Name | Kind |
Description |
|
|
||
|
competitive_hebbian_graph | function |
Induced Delaunay triangulation by competitive Hebbian learning (Martinetz 1993) |
|
connect_components | function |
Join the connected components of a graph by its shortest inter-component edges |
|
delaunay_graph | function |
Delaunay triangulation as a graph (practical up to about six dimensions) |
|
edges_of | function |
Undirected edge list (edges, weights) of a symmetric sparse graph (each edge once, i < j) |
|
epsilon_graph | function |
-neighborhood graph: samples closer than eps are linked |
|
gabriel_graph | function |
Gabriel graph: are linked when the ball with diameter contains no other samp |
|
geodesic_distances | function |
All-pairs shortest-path (graph, geodesic) distances with Dijkstra’s algorithm |
|
knn_graph | function |
Symmetric -nearest-neighbor graph |
|
knn_indices | function |
Indices and distances of the k nearest neighbors of every sample (the sample itself excluded) |
|
minimum_spanning_tree | function |
Euclidean minimal spanning tree (symmetric) of the samples or of a given weighted graph |
|
mutual_knn_graph | function |
Mutual -nearest-neighbor graph: an edge only if each sample is among the other’s neighbors |
|
nearest_neighbor_graph | function |
Nearest neighbor graph (NNG): every sample is linked to its single nearest neighbor |
|
neighborhood_chain | function |
Edge counts of NNG, MST, RNG, Gabriel graph and Delaunay triangulation, and whether each is contained in the next (for 2-D or 3-D data) |
|
relative_neighborhood_graph | function |
Relative neighborhood graph (Toussaint): are linked when no third sample is closer to both of them than they are to each ot |
|
shared_neighbor_counts | function |
Number of shared -nearest neighbors for every pair |
|
to_networkx | function |
Convert a sparse adjacency matrix to a Graph (edge attribute weight) |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.2 graphclust.vq: Vector quantization and topology learning
|
Name | Kind |
Description |
|
|
||
|
BaseTopologyLearner | class |
Common interface of the vector quantizers and topology learners |
|
DynamicTopologyRepresentingNetwork | class |
Dynamic topology representing network (DTRN; Si, Lin and Vuong 2000) |
|
GrowWhenRequired | class |
Grow when required network (GWR; Marsland, Shapiro and Nehmzow 2002) |
|
GrowingNeuralGas | class |
Growing neural gas (GNG; Fritzke 1995) |
|
LBG | class |
Linde–Buzo–Gray vector quantizer: k-means with codebook splitting |
|
NeuralGas | class |
Neural gas vector quantization (Martinetz and Schulten 1991) |
|
TopologyRepresentingNetwork | class |
Topology representing network (TRN; Martinetz and Schulten 1994) |
|
WeightedIncrementalNetwork | class |
Weighted incremental neural network (WINN; Muhammed 2004) |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.3 graphclust.cluster: Graph-based clustering
|
Name | Kind |
Description |
|
|
||
|
DensityPeaks | class |
Clustering by fast search and find of density peaks (Rodriguez and Laio 2014) |
|
FuzzyNeighborhoodClustering | class |
Hierarchical clustering on the fuzzy neighborhood distance |
|
GraphCommunityClustering | class |
Community detection on a neighborhood graph (PhenoGraph-style pipeline) |
|
HDBSCANStar | class |
HDBSCAN* (Campello, Moulavi and Sander 2013; 2015): density clustering from a spanning tree |
|
HybridMSTGG | class |
Hybrid minimal spanning tree – Gath–Geva clustering (Vathy-Fogarassy, Feil and Abonyi 2005) |
|
JarvisPatrick | class |
Jarvis–Patrick shared nearest neighbor clustering (1973) |
|
MSTClustering | class |
Minimal spanning tree clustering with Zahn’s inconsistent-edge criteria |
|
SharedNearestNeighborClustering | class |
Shared nearest neighbor density clustering (SNN; Ertöz, Steinbach and Kumar 2003) |
|
SpectralGraphClustering | class |
Normalized spectral clustering (Ng, Jordan and Weiss 2002) on a neighborhood graph |
|
fuzzy_neighborhood_similarity | function |
Transitive fuzzy neighborhood similarity (Vathy-Fogarassy, Kiss and Abonyi 2007) |
|
jaccard_knn_graph | function |
kNN graph re-weighted by the Jaccard index of the neighbor sets (PhenoGraph-style, Levine et al. 2015) |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.4 graphclust.fuzzy: Gath–Geva clustering
|
Name | Kind |
Description |
|
|
||
|
GathGeva | class |
Gath–Geva (fuzzy maximum likelihood estimates) clustering |
|
fuzzy_covariances | function |
Centers and fuzzy covariance matrices |
|
fuzzy_hypervolume | function |
Fuzzy hypervolume (Gath and Geva 1989); smaller is better |
|
labels_to_membership | function |
Crisp labels to a 0/1 membership matrix of shape (n_samples, n_clusters) |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.5 graphclust.validity: Cluster validity
|
Name | Kind |
Description |
|
|
||
|
clustering_rate | function |
Fraction of samples in correctly matched clusters (Hungarian matching of the labels) |
|
dbcv | function |
Density-based clustering validation (DBCV; Moulavi, Jaskowiak, Campello, Zimek and Sander 2014) |
|
dunn_mst_index | function |
Dunn-like index with MST diameters: |
|
eigengap | function |
Number of clusters suggested by the spectrum of a graph, and the eigenvalues |
|
fukuyama_sugeno | function |
Fukuyama–Sugeno index ; smaller is better |
|
fuzzy_hypervolume | function |
Fuzzy hypervolume (Gath and Geva 1989); smaller is better |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.6 graphclust.vat: Visual assessment of cluster tendency
|
Name | Kind |
Description |
|
|
||
|
ivat | function |
Improved VAT image: minimax (largest MST edge on the path) distances in VAT order |
|
vat | function |
Reordered dissimilarity image and the permutation |
|
vat_order | function |
VAT ordering (Prim’s order starting from an end point of the largest dissimilarity) and the MST edge weight by which every sample was attached (0 for the first) |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.7 graphclust.manifold: Mappings
|
Name | Kind |
Description |
|
|
||
|
CurvilinearComponentAnalysis | class |
Curvilinear component analysis (CCA; Demartines and Hérault 1997) and curvilinear distance analysis (CDA) |
|
DiffusionMap | class |
Diffusion maps (Coifman and Lafon 2006) |
|
GeodesicNLPNG | class |
Geodesic nonlinear projection neural gas (GNLP-NG; Estévez, Chong, Held and Pérez 2006) |
|
IncrementalGridGrowing | class |
Incremental grid growing (Blackmore and Miikkulainen 1993) |
|
Isomap | class |
Isomap (Tenenbaum, de Silva and Langford 2000) |
|
Isotop | class |
Isotop (Lee and Verleysen 2002, 2004) |
|
LaplacianEigenmap | class |
Laplacian eigenmaps (Belkin and Niyogi 2003) |
|
LocalityPreservingProjection | class |
Locality preserving projections (He and Niyogi 2003): a linear map that keeps neighbors close |
|
MetricMDS | class |
Metric multidimensional scaling |
|
NonMetricMDS | class |
Non-metric (ordinal) MDS (Kruskal 1964): preserves the rank order of the dissimilarities |
|
OnlineVisualizationNG | class |
Online visualization neural gas (OVI-NG; Estévez and Figueroa 2006) |
|
SammonMapping | class |
Sammon’s nonlinear mapping (1969) |
|
SelfOrganizingMap | class |
Kohonen’s self-organizing map (batch training) |
|
TRNMap | class |
Topology representing network map (Vathy-Fogarassy, Kiss and Abonyi 2008) |
|
UMAPEmbedding | class |
Uniform manifold approximation and projection (UMAP; McInnes, Healy and Melville 2018), NumPy implementation |
|
classical_mds | function |
Classical (Torgerson) MDS of a distance matrix |
|
tsne | function |
t-distributed stochastic neighbor embedding (van der Maaten and Hinton 2008) via scikit-learn |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.8 graphclust.metrics: Quality of maps
|
Name | Kind |
Description |
|
|
||
|
auc_rnx | function |
Area under the curve with logarithmic K axis, |
|
coranking_matrix | function |
Co-ranking matrix (Lee and Verleysen 2009) |
|
lcmc_curve | function |
Local continuity meta-criterion (Chen and Buja 2009) |
|
mapping_quality | function |
All distance- and neighborhood-preservation measures of a map in one dictionary |
|
mds_stress | function |
Normalized metric MDS stress |
|
qnx_curve | function |
, the average overlap of the K-ary neighborhoods, |
|
residual_variance | function |
Residual variance (Tenenbaum et al. 2000) |
|
rnx_curve | function |
: neighborhood preservation rescaled so that a random map scores 0 |
|
sammon_stress | function |
Sammon stress |
|
topographic_error | function |
Share of samples whose two nearest nodes are not adjacent in the map graph (Kiviluoto 1996) |
|
topographic_product | function |
Topographic product of Bauer and Pawelzik (1992) between node vectors and their map positions |
|
trustworthiness_continuity | function |
Trustworthiness and continuity (Venna and Kaski 2001) |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.9 graphclust.datasets: Data sets
|
Name | Kind |
Description |
|
|
||
|
load_boxlinecircle | function |
The original ’boxlinecircle’ data of Vathy-Fogarassy and Abonyi (; no labels) |
|
load_breast_cancer | function |
Wisconsin diagnostic breast cancer data (, 2 classes) as shipped with scikit-learn |
|
load_digits | function |
Handwritten digits (, 10 classes), a stand-in for the Semeion digits of the book |
|
load_iris | function |
Iris flowers (, 3 classes) |
|
load_wine | function |
Wine recognition data (, 3 cultivars) |
|
make_boxlinecircle | function |
A noisy cube, a bent line and a circle in 3-D (shapes of dimension 3, 1 and 1) |
|
make_chainlink | function |
ChainLink data: 75 points in 2-D – three compact clusters, two of which are joined by a chain of points |
|
make_curves | function |
Curves data: 267 points in 2-D forming four curved clusters of different size that nearly touch |
|
make_s_curve | function |
S-curve manifold (scikit-learn generator); y is the position along the curve |
|
make_swiss_roll | function |
Swiss roll manifold (scikit-learn generator); y is the position along the roll |
|
make_variety | function |
Variety data: 100 points in 2-D, clusters of 22 (dense, round), 26 (elongated) and 51 (sparse) points and one outlier |
|
minmax_scale | function |
Scale every feature to [0, 1] (constant features become 0) |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
A.10 graphclust.plotting: Plotting helpers
|
Name | Kind |
Description |
|
|
||
|
PALETTE | constant |
Okabe–Ito categorical palette used by all figures |
|
plot_component_planes | function |
Component planes: the map once per feature, nodes shaded by that feature of their codebook vector |
|
plot_decision_graph | function |
Density peaks decision graph (local density against distance to a denser sample) |
|
plot_dendrogram | function |
SciPy dendrogram of a linkage matrix with an optional cut line |
|
plot_embedding | function |
Scatter plot of a 2-D embedding colored by labels (or by a continuous value) |
|
plot_graph | function |
Draw a graph whose nodes have 2-D or 3-D positions; optional data cloud X in the background |
|
plot_partition | function |
Scatter plot of 2-D (or 3-D) data colored by cluster label (noise -1 in gray) |
|
plot_quality_curves | function |
Plot several quality curves (e.g. trustworthiness against k) given as {name: values} |
|
plot_vat | function |
Show a (i)VAT image: dark diagonal blocks are clusters |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||