sklvq.distances.Euclidean¶
-
class
sklvq.distances.Euclidean[source]¶ Euclidean distance function
Class that holds the euclidean distance function and its gradient.
- 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.
Notes
Compatible with the
GLVQalgorithm (only).-
__call__(data: numpy.ndarray, model: GLVQ) → numpy.ndarray[source]¶ - Computes the Euclidean distance:

with
a prototype and
a sample.
- Parameters
- datandarray with shape (n_samples, n_features)
The data for which the distances to the prototypes of the model need to be computed.
- modelGLVQ
A GLVQ model instance, containing the prototypes.
- Returns
- ndarray with shape (n_samples, n_prototypes)
Evaluation of the distance between each sample and prototype of the model.
-
gradient(data: numpy.ndarray, model: GLVQ, i_prototype: int) → numpy.ndarray[source]¶ Computes the gradient of the euclidean distance with respect to a single prototype:

- 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.
- modelGLVQ
A GLVQ model instance.
- i_prototypeint
Index of the prototype to compute the gradient for.
- Returns
- ndarray with shape (n_samples, n_features)
The gradient of the prototype with respect to every sample in the data.