def _calculate_whitening_transformation_matrix(self, sample_from_prior):
samples_vec = sp.asarray([self._dict_to_to_vect(x)
for x in sample_from_prior])
# samples_vec is an array of shape nr_samples x nr_features
means = samples_vec.mean(axis=0)
centered = samples_vec - means
covariance = centered.T.dot(centered)
w, v = la.eigh(covariance)
self._whitening_transformation_matrix = (
v.dot(sp.diag(1. / sp.sqrt(w))).dot(v.T))
评论列表
文章目录