W3cubDocs

/scikit-learn

sklearn.utils.validation.check_symmetric

sklearn.utils.validation.check_symmetric(array, tol=1e-10, raise_warning=True, raise_exception=False) [source]

Make sure that array is 2D, square and symmetric.

If the array is not symmetric, then a symmetrized version is returned. Optionally, a warning or exception is raised if the matrix is not symmetric.

Parameters:
array : nd-array or sparse matrix

Input object to check / convert. Must be two-dimensional and square, otherwise a ValueError will be raised.

tol : float

Absolute tolerance for equivalence of arrays. Default = 1E-10.

raise_warning : boolean (default=True)

If True then raise a warning if conversion is required.

raise_exception : boolean (default=False)

If True then raise an exception if array is not symmetric.

Returns:
array_sym : ndarray or sparse matrix

Symmetrized version of the input array, i.e. the average of array and array.transpose(). If sparse, then duplicate entries are first summed and zeros are eliminated.

© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.utils.validation.check_symmetric.html