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
ofshape(n_samples,n_features) Samples; missing values are
NaN.- Varray_like
ofshape(n_clusters,n_features) Prototypes (complete).
- Xarray_like
- Returns:
- d2
ndarrayofshape(n_samples,n_clusters)
- d2
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.]])