https://github.com/tensorly/tensorly
Revision 1bb217a077d6fa1d507f963a60da81adfd099d79 authored by Jean Kossaifi on 14 July 2017, 03:03:33 UTC, committed by GitHub on 14 July 2017, 03:03:33 UTC
Improving partial_svd by omitting full svd matrices when possible
Tip revision: 1bb217a077d6fa1d507f963a60da81adfd099d79 authored by Jean Kossaifi on 14 July 2017, 03:03:33 UTC
Merge pull request #7 from chubei/master
Merge pull request #7 from chubei/master
Tip revision: 1bb217a
_higher_order_moment.py
from ._khatri_rao import khatri_rao
# Author: Jean Kossaifi
# License: BSD 3 clause
def higher_order_moment(matrix, order=3):
"""Higher order moment of a matrix of observations
Computes the higher moment of order `order` of `matrix`
Each row of `matrix` represents a samples
(i.e. an observation)
Parameters
----------
matrix : 2D-array
array of shape (n_samples, n_features)
i.e. each row is a sample
order : int, optional
order of the moment to compute
"""
matrix = matrix - matrix.mean(axis=0)
n_features = matrix.shape[-1]
t = khatri_rao([matrix.T] * order).mean(axis=1)
return t.reshape([n_features] * order)
Computing file changes ...