fuzzyclust.incomplete.partial_distances#

fuzzyclust.incomplete.partial_distances(X, V)[source]#

Squared partial distances of (incomplete) samples to prototypes.

For a sample \(\mathbf{x}_k\) with the indicator \(I_{kj}=1\) when feature \(j\) is observed and \(I_k=\sum_j I_{kj}\) observed features, the partial distance of Dixon (1979) is the squared Euclidean distance over the observed features, rescaled to the full dimension \(n\),

\[D^2_{ik} = \frac{n}{I_k}\sum_{j=1}^{n} I_{kj}\,(x_{kj}-v_{ij})^2 .\]

For a complete sample it is the ordinary squared Euclidean distance.

Parameters:
Xarray_like of shape (n_samples, n_features)

Samples; missing values are NaN.

Varray_like of shape (n_clusters, n_features)

Prototypes (complete).

Returns:
d2ndarray of shape (n_samples, n_clusters)

Examples

>>> import numpy as np
>>> from fuzzyclust.incomplete import partial_distances
>>> X = np.array([[0.0, 0.0], [1.0, np.nan]])
>>> partial_distances(X, np.array([[1.0, 1.0]]))
array([[2.],
       [0.]])