apollon.som.neighbors module

apollon/som/neighbors.py

Neighborhood computations

Functions:

gaussian N-Dimensional Gausian neighborhood.

apollon.som.neighbors.check_bounds(shape: Tuple[int, int], point: Tuple[int, int])bool

Return True if point is valid index in shape.

Parameters
  • shape – Shape of two-dimensional array.

  • point – Two-dimensional coordinate.

Returns

True if point is within shape else False.

apollon.som.neighbors.direct_rect_nb(shape: Tuple[int, int], point: Tuple[int, int])Tuple[List[int], List[int]]

Return the set of direct neighbours of point given rectangular topology.

Parameters
  • shape – Shape of two-dimensional array.

  • point – Two-dimensional coordinate.

Returns

Advanced index of points in neighbourhood set.

apollon.som.neighbors.gauss_kern(nhb, r)
apollon.som.neighbors.gaussian(grid, center, radius)

Compute n-dimensional Gaussian neighbourhood.

Gaussian neighborhood smoothes the array.

Params:

grid Array of n-dimensional indices. center Index of the neighborhood center. radius Size of neighborhood.

apollon.som.neighbors.is_neighbour(cra: numpy.ndarray, crb: numpy.ndarray, grid: numpy.ndarray, metric: str)numpy.ndarray

Compute neighbourship between each coordinate in units_a abd units_b on grid.

Parameters
  • cra – (n x 2) array of grid coordinates.

  • crb – (n x 2) array of grid coordinates.

  • grid – SOM grid array.

  • metric – Name of distance metric function.

Returns

One-dimensional boolean array. True in position n means that the points cra[n] and crb[n] are direct neighbours on grid regarding metric.

apollon.som.neighbors.mexican(grid, center, radius)

Compute n-dimensional Mexcican hat neighbourhood.

Mexican hat neighborhood smoothes the array.

Params:

grid Array of n-dimensional indices. center Index of the neighborhood center. radius Size of neighborhood.

apollon.som.neighbors.neighborhood(grid, metric='sqeuclidean')

Compute n-dimensional cityblock neighborhood.

The cityblock neighborhood is a star-shaped area around center.

Params:

grid: Array of n-dimensional indices. metric: Distance metric.

Returns

Pairwise distances of map units.

apollon.som.neighbors.rect(grid, center, radius)

Compute n-dimensional Chebychev neighborhood.

The Chebychev neighborhood is a square-shaped area around center.

Params:

grid Array of n-dimensional indices. center Index of the neighborhood center. radius Size of neighborhood.

Returns

Two-dimensional array of in

apollon.som.neighbors.star(grid, center, radius)

Compute n-dimensional cityblock neighborhood.

The cityblock neighborhood is a star-shaped area around center.

Params:

grid Array of n-dimensional indices. center Index of the neighborhood center. radius Size of neighborhood.

Returns: