sklvq.distances.SquaredEuclidean
- class sklvq.distances.SquaredEuclidean[source]
Squared Euclidean distance
- 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: np.ndarray, model: GLVQ) np.ndarray[source]
- Computes the squared Euclidean distance:

with
a prototype and
a sample.
- 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
The 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: np.ndarray, model: GLVQ, i_prototype: int) np.ndarray[source]
Computes the gradient of the squared 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
The GLVQ model instance.
- i_prototypeint
Index of the prototype to compute the gradient for.
- Returns:
- gradientndarray with shape (n_samples, n_features)
The gradient of the prototype with respect to every sample in the data.