scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
procrustes(data1, data2)

Each input matrix is a set of points or vectors (the rows of the matrix). The dimension of the space is the number of columns of each matrix. Given two identically sized matrices, procrustes standardizes both such that:

Procrustes (, ) then applies the optimal transform to the second matrix (including scaling/dilation, rotations, and reflections) to minimize $M^{2}=\sum(data1-data2)^{2}$ , or the sum of the squares of the pointwise differences between the two input datasets.

This function was not designed to handle datasets with different numbers of datapoints (rows). If two data sets have different dimensionality (different number of columns), simply add columns of zeros to the smaller of the two.

Notes

Parameters

data1 : array_like

Matrix, n rows represent points in k (columns) space :None:None:`data1` is the reference data, after it is standardised, the data from :None:None:`data2` will be transformed to fit the pattern in :None:None:`data1` (must have >1 unique points).

data2 : array_like

n rows of data in k space to be fit to :None:None:`data1`. Must be the same shape (numrows, numcols) as data1 (must have >1 unique points).

Raises

ValueError

If the input arrays are not two-dimensional. If the shape of the input arrays is different. If the input arrays have zero columns or zero rows.

Returns

mtx1 : array_like

A standardized version of :None:None:`data1`.

mtx2 : array_like

The orientation of :None:None:`data2` that best fits :None:None:`data1`. Centered, but not necessarily $tr(AA^{T}) = 1$ .

disparity : float

$M^{2}$ as defined above.

Procrustes analysis, a similarity test for two data sets.

See Also

scipy.linalg.orthogonal_procrustes
scipy.spatial.distance.directed_hausdorff

Another similarity test for two data sets

Examples

>>> from scipy.spatial import procrustes

The matrix b is a rotated, shifted, scaled and mirrored version of a here:

>>> a = np.array([[1, 3], [1, 2], [1, 1], [2, 1]], 'd')
... b = np.array([[4, -2], [4, -4], [4, -6], [2, -6]], 'd')
... mtx1, mtx2, disparity = procrustes(a, b)
... round(disparity) 0.0
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.spatial._procrustes.procrustes

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/spatial/_procrustes.py#15
type: <class 'function'>
Commit: