sklvq.distances.LocalAdaptiveSquaredEuclidean¶
-
class
sklvq.distances.LocalAdaptiveSquaredEuclidean[source]¶ Local adaptive squared Euclidean distance
Class that holds the localized adaptive squared Euclidean distance function and its gradient as described in [1] and [2].
- Parameters
- force_all_finite{True, False, “allow-nan”}
Parameter to indicate that NaNLVQ distance variant should be used. If true no nans are allowed. If False or “allow-nan” nans are allowed.
See also
Notes
Compatible with the
LGMLVQalgorithm (only).References
[1] Schneider, P. (2010). Advanced methods for prototype-based classification. Groningen.
[2] Schneider, P., Biehl, M., & Hammer, B. (2009). Adaptive Relevance Matrices in Learning Vector Quantization. Neural Computation, 21(12), 3532–3561.
-
__call__(data: numpy.ndarray, model: LGMLVQ) → numpy.ndarray[source]¶ Computes the local variant of the adaptive squared Euclidean distance:

with
depending on the localization setting of the model and
. The localization can be either per
prototype or per class, see the documentation of LGMLVQ.- Parameters
- datandarray with shape (n_samples, n_features)
The data for which the distance gradient to the prototypes of the model need to be computed.
- modelLGMLVQ
A LGMLVQ model instance, containing the prototypes and relevance matrices.
- Returns
- ndarray with shape (n_samples, n_prototypes)
Evaluation of the distance between each sample in the data and prototype of the model.
-
gradient(data: numpy.ndarray, model: LGMLVQ, i_prototype: int) → numpy.ndarray[source]¶ Computes the gradient of the localized adaptive squared euclidean distance function with respect to a specified prototype:

and implicitly coupled omega matrix (per element):

- Parameters
- datandarray with shape (n_samples, n_features)
The X for which the distance gradient to the prototypes of the model need to be computed.
- modelLGMLVQ
The LGMLVQ model instance, containing the prototypes and relevance matrices.
- i_prototypeint
An integer index value of the relevant prototype
- Returns
- ndarray with shape (n_samples, n_features + n_omega_elements)
The gradient of the prototype and omega matrix with respect to each data sample.