0

如何计算掩码 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)) 
4

0 回答 0