掩模数组的特征值(NumPy)

时间:2013-01-26 12:04:51

标签: python numpy scipy pandas

如何计算被屏蔽的NumPy数组的特征值和特征向量(对于未屏蔽的数组,这可以通过scipy.linalg.eig实现)。


编辑:

事实证明你毕竟可以做到这一点。

# a list of numpy matrices
import numpy as np
import numpy.ma as npma

import numpy.matlib as npm
import scipy as sp
import scipy.linalg as splin

import pandas as pd

# read in numpy data
import urllib
dataURL = 'http://archive.ics.uci.edu/ml/machine-learning-databases/arrhythmia/arrhythmia.data'
dataFile = urllib.urlopen(dataURL)

# read in the data as a NumPy dataset
aArr = np.genfromtxt(dataFile, dtype = np.float,
                         delimiter = ',', missing_values = '?')

aArrMasked = npma.masked_array(aArr, np.isnan(aArr))
aArrMaskedCenter = aArrMasked - npma.mean(aArrMasked, axis=0)
print splin.eig(npma.cov(aArrMaskedCenter)) 

0 个答案:

没有答案