Utility Functions
All utility functions are importable from NNSOM.utils:
from NNSOM.utils import preminmax, get_cluster_avg, get_perc_cluster
They are also re-exported at the top level of NNSOM.
Data normalization
Normalize input data row-wise to the range [-1, 1]. |
Topology geometry
Compute the 2-D hexagonal grid positions of SOM neurons. |
|
Compute shortest-path distances between all pairs of SOM neurons. |
|
Normalize neuron positions to the range [-1, 1] along each axis. |
|
Map normalized neuron positions into data space using a basis. |
|
Return the vertex offsets for drawing a unit hexagon. |
|
Return the vertex offsets for drawing the elongated diamond between two neurons. |
Coordinate transforms
Convert Cartesian coordinates to polar coordinates. |
|
Convert polar coordinates to Cartesian coordinates. |
|
Rotate 2-D coordinates by a given angle. |
Cluster data extraction
For each cluster, extract the corresponding data points. |
|
Return an object array whose elements are per-cluster feature values. |
|
Compute the mean feature value for each cluster. |
|
Count occurrences of each class in every cluster. |
|
Calculate the intersection sizes of each class with each neuron cluster. |
Class and label analysis
Return the class of the closest data point in each cluster. |
|
Return the majority class label for each cluster. |
|
Return the percentage of a target class in each cluster. |
|
Generate a colour label per cluster based on majority class membership. |
|
Calculate edge line widths per cluster based on class membership fraction. |
Error and misclassification analysis
Return indices of misclassified samples. |
|
Compute the percentage of misclassified samples in each cluster. |
|
Return TP, TN, FP, FN indices for a given class in a binary sense. |
|
Map each cluster's dominant class to its majority error type. |
Miscellaneous
Recursively flatten a nested list of numbers into a single list. |
|
Find the global minimum and maximum in a nested list. |
|
Create labelled matplotlib Button widgets in a sidebar. |
|
Calculate evenly-spaced button positions within a figure sidebar. |