fuzzyclust.relational.relational_distances#
- fuzzyclust.relational.relational_distances(R, V, beta=0.0)[source]#
Squared relational distances of the training objects to relational prototypes.
\[d^2_{ik}=(\mathbf{R}\mathbf{v}_i)_k-\tfrac12\,\mathbf{v}_i\T\mathbf{R}\mathbf{v}_i +\tfrac{\beta}{2}\norm{\mathbf{e}_k-\mathbf{v}_i}^2 ,\]where \(\mathbf{v}_i\in\mathbb{R}^N\) sums to one and \(\mathbf{e}_k\) is the \(k\)-th unit vector. The last term is the effect of the \(\beta\)-spread \(\mathbf{R}_\beta=\mathbf{R}+\beta(\mathbf{1}\mathbf{1}\T-\mathbf{I})\) (Hathaway and Bezdek, 1994), computed without forming \(\mathbf{R}_\beta\).
- Parameters:
- Returns:
- d2
ndarrayofshape(n_samples,n_clusters)
- d2
Examples
>>> import numpy as np >>> from fuzzyclust.relational import relational_distances >>> R = np.array([[0.0, 1.0, 4.0], [1.0, 0.0, 1.0], [4.0, 1.0, 0.0]]) # points 0, 1, 2 on a line >>> V = np.array([[0.5, 0.5, 0.0]]) # prototype at 0.5 >>> relational_distances(R, V).ravel() array([0.25, 0.25, 2.25])