from skspec import *
ts=tsload('rundata.pickle')
specplot(ts)
<matplotlib.axes.AxesSubplot at 0x407e150>
ts.reference=0
absplot(ts)
/usr/local/EPD/lib/python2.7/site-packages/pandas/core/frame.py:3576: FutureWarning: rename with inplace=True will return None from pandas 0.11 onward " from pandas 0.11 onward", FutureWarning)
<matplotlib.axes.AxesSubplot at 0x7f54d00c5290>
ts=ts.ix[400.0:700.0]
absplot(ts)
<matplotlib.axes.AxesSubplot at 0x66989d0>
from pcakernel import PCA
help(PCA)
Help on class PCA in module pcakernel: class PCA(__builtin__.object) | PCA object to perform Principal Component Analysis. | | Methods defined here: | | __init__(self, k=None, kernel=False, extern=False, index=None) | Constructor. | | arguments: | * k: number of principal components to compute. 'None' | (default) means that all components are computed. | * kernel: perform PCA on kernel matrices (default is False) | * extern: use extern product to perform PCA (default is | False). Use this option when the number of samples | is much smaller than the number of features. | | Notes: | * All data will be mean-cenetered. Np subroutines (eg np.cov()) | do this in all cases except for the extern_pca() method, which | does this automatically. | | fit(self, X) | Performs PCA on the data array X. | arguments: | * X: 2D numpy array. In case the array represents a kernel | matrix, X should be symmetric. Otherwise each row | represents a sample and each column represents a | feature. | | transform(self, X, whiten=False) | Project data on the principal components. If the whitening | option is used, components will be normalized to that they | have the same contribution. | | arguments: | * X: 2D numpy array of data to project. | * whiten: (default is False) all components are normalized | so that they have the same contribution. | | returns: | * prX : projection of X on the principal components. | | Notes: In the case of Kernel PCA, X[i] represents the value | of the kernel between sample i and the j-th sample used | at train time. Thus, if fit was called with a NxN kernel | matrix, X should be a MxN matrix. | | The projection in the kernel case is made to be equivalent | to the projection in the linear case. | | X.T = U * S * v.T | C = 1/(N-1) * X.T * X | X.T * X = U*S^2*U.T | K = X * X.T = v*S^2*v.T | | U = X.T * v * S^(-1) | | The projection with PCA is : | X' = X * U | X' = X * X.T * v * S^(-1) | X' = K * v * S^(-1) | | For whiten PCA : | X' = X * U * S^(-1) * sqrt(N-1) | X' = X * X.T * v * S^(-1) * S^(-1) * sqrt(N-1) | X' = K * S^(-2) * sqrt(N-1) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined)
pc=PCA(ts)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-14-9aff029652f4> in <module>() 1 x=PCA(ts) ----> 2 x.fit(ts._df.values) /home/hugadams/Dropbox/skspec/Master/skspec/core/pcakernel.pyc in fit(self, X) 206 else : 207 pca_func = pca --> 208 self.eigen_values_,self.eigen_vectors_ = pca_func(X,self._k) 209 210 if self._kernel : /home/hugadams/Dropbox/skspec/Master/skspec/core/pcakernel.pyc in pca(data, k) 59 cov = np.cov(data.T) 60 ### kw "which" means return largest magnitude k eigenvalues ---> 61 w,u = eigs(cov,k = k,which = 'LM') 62 # return w[::-1],u[:,::-1] 63 return w,u #(No need to reverse w,u because eigs does it using 'LM') /usr/local/EPD/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.pyc in eigs(A, k, M, sigma, which, v0, ncv, maxiter, tol, return_eigenvectors, Minv, OPinv, OPpart) 1203 n = A.shape[0] 1204 -> 1205 if k <= 0 or k >= n: 1206 raise ValueError("k must be between 1 and rank(A)-1") 1207 /usr/local/EPD/lib/python2.7/site-packages/skspec/pandas_utils/metadframe.pyc in __nonzero__(self) 212 213 def __nonzero__(self): --> 214 return self._df.__nonzero__() 215 216 def __contains__(self, x): /usr/local/EPD/lib/python2.7/site-packages/pandas/core/frame.py in __nonzero__(self) 585 586 def __nonzero__(self): --> 587 raise ValueError("Cannot call bool() on DataFrame.") 588 589 def _need_info_repr_(self): ValueError: Cannot call bool() on DataFrame.