Python下的PPCA庫:pca-magic
Python下的PPCA庫,相比Scikit-Learn里的實現,該庫能更好的處理缺失數據,并基于另外的數據集進行插值。
Install via pip:
pip install ppca
Load in the data which should be arranged asn_samplesbyfeatures. As usual, you should make sure your data is stationary (take first differences if possible) and standardized.
from ppca import PPCA ppca = PPCA(data)
Fit the model with parameterdspecifying the number of components and verbose printing convergence output if required.
ppca.fit(d=100, verbose=True)
The model parameters and components will be attached to the ppca object.
variance_explained = ppca.var_exp components = ppca.X model_params = ppca.C
If you want the principal components, calltransform.
component_mat = ppca.transform()
Post fitting the model, save the model if you want.
ppca.save('mypcamodel') Load a model, post instantiating a PPCA object. This will make fitting/transforming much faster.
ppca.load('mypcamodel.npy')
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!