queso_cluster.atoms.base#

file:

queso_cluster/atoms/base.py

lang:

python

synopsis:

author:

Sarah Riley <academic@sriley.dev>

Functions#

calcOptimization(k, data, decision[, threshold])

Calculates the set of k decisions with a convergence threshold

compute_bin(x, bin_edges)

concatSpectra(dataSquareLst)

Function to concatenate several channels of data into one array for clustering

get_bin_edges(bins, lim)

labelGluer(labels)

labelReorder(labels)

maximize(data, decisions, size)

minimize(data, decisions, size)

np_all_axis0(x)

np_all_axis1(x)

np_gradient(f)

Numba accelerated gradient

numba_histogram(a, bins, lim)

Numba accelerated histogram function

rotateArray(image, turns)

Rotates an array

similarityMetric(x, y[, type, ref])

startMax(data, k, decisions)

Heuristic k-means++.

startPlusPlus(data, k, decisions)

k-means++ initialization

Module Contents#

calcOptimization(k, data, decision, threshold=1e-06)[source]#

Calculates the set of k decisions with a convergence threshold

Parameters:
  • k (int) – The number of groups

  • data (ndarray) – The data to be clustered

  • decision (ndarray) – The previous iteration’s decisions

  • threshold (float, optional) – The convergence threshold

Raises:

ConvergenceError – If the convergence criteria cannot be evaulated or if the convergence criterion is not met after covergeLimit

Returns:

  • decision (ndarray) – The current iteration’s representative profiles

  • data_label (ndarray) – The labels for the data

compute_bin(x, bin_edges)[source]#
concatSpectra(dataSquareLst)[source]#

Function to concatenate several channels of data into one array for clustering

Parameters:

dataSquareLst (dask.array) – dask arrays containing spectral data to be concatenated

Returns:

Concatenated spectral profiles

Return type:

dask.array

get_bin_edges(bins, lim)[source]#
labelGluer(labels)[source]#
labelReorder(labels)[source]#
maximize(data, decisions, size)[source]#
minimize(data, decisions, size)[source]#
np_all_axis0(x)[source]#
np_all_axis1(x)[source]#
np_gradient(f)[source]#

Numba accelerated gradient

numba_histogram(a, bins, lim)[source]#

Numba accelerated histogram function

Parameters:
  • a (int) – detail

  • bins (int) – the number of bins in the histogram

  • lim (ndarray) – the top and bottom of the histogram

Returns:

  • hist (ndarray) – the histogram

  • bin_edges (ndarray) – 1D array of the bin edges

rotateArray(image, turns)[source]#

Rotates an array

Parameters:
  • image (ndarray) – 2D array to be rotated

  • turns (int) – Number of pi/2 turns to rotate

Returns:

Rotated array

Return type:

ndarray

similarityMetric(x, y, type='dist', ref=0)[source]#
startMax(data, k, decisions)[source]#

Heuristic k-means++. Rather than selecting from a distribution around the furtherest datapoint, this initialization simply selects the furtherest datapoint as the next representative

Parameters:
  • data (ndarray) – data pool for finding the initial representative profiles

  • k (int) – The number of clusters

  • decisions (ndarray) – Array containing the initial, randomly selected representative profile and empty slots for remaining profiles

Returns:

decisions – Array containing a full set of representative profiles

Return type:

ndarray

startPlusPlus(data, k, decisions)[source]#

k-means++ initialization

Parameters:
  • data (ndarray) – data pool for finding the initial representative profiles

  • k (int) – The number of clusters

  • decisions (ndarray) – Array containing the initial, randomly selected representative profile and empty slots for remaining profiles

Returns:

decisions – Array containing a full set of representative profiles

Return type:

ndarray