machine learning - Fast ICA using scikit learn- reconstruction error analysis -
i trying use fastica
procedure in scikitlearn. validation purposes tried understand difference between pca
, ica
based signal reconstruction.
the original number of observed signals 6 , tried use 3 reconstruction independent components . problem both ica
, pca
result in same reconstruction errors no matter norm use. can 1 throw light happening here.
the code below:
pca = pca(n_components=3) icamodel = fastica(n_components=3,whiten=true) data = trainingdatadict[yearspan][riskfactornames] pcr_dict[yearspan] = pd.dataframe(pca.fit_transform(data), columns=['pc1','pc2','pc3'],index=data.index) icr_dict[yearspan] = pd.dataframe(icamodel.fit_transform(data), columns=['ic1','ic2','ic3'],index=data.index) '------------------------inverse transform of ic , pcs -----------' pca_new_data_df = pd.dataframe(pca.inverse_transform(pcr_dict[yearspan]), columns =['f1','f2','f3'],index = data.index) ica_new_data_df = pd.dataframe(icamodel.inverse_transform(icr_dict[yearspan]), columns =['f1','f2','f3'],index = data.index)
below way measure reconstruction error
'-----------reconstruction errors------------------' print 'pca reconstruction error l2 norm:',np.sqrt((pca_new_data_df - data).apply(np.square).mean()) print 'ica reconstruction error l2 norm:',np.sqrt((ica_new_data_df - data).apply(np.square).mean()) print 'pca reconstruction error l1 norm:',(pca_new_data_df - data).apply(np.absolute).mean() print 'ica reconstruction error l1 norm:',(ica_new_data_df - data).apply(np.absolute).mean()
below description of tails of pc
, ic
s
pc stats : ('2003', '2005') kurtosis skewness pcr_1 -0.001075 -0.101006 pcr_2 1.057140 0.316163 pcr_3 1.067471 0.047946 ic stats : ('2003', '2005') kurtosis skewness icr_1 -0.221336 -0.204362 icr_2 1.499278 0.433495 icr_3 3.654237 0.072480
below results of reconstruction
pca reconstruction error l2 norm: sptr 0.000601 sptrmdcp 0.001503 ru20intr 0.000788 lbustruu 0.002311 lf98truu 0.001811 nddueafe 0.000135 dtype: float64 ica reconstruction error l2 norm : sptr 0.000601 sptrmdcp 0.001503 ru20intr 0.000788 lbustruu 0.002311 lf98truu 0.001811 nddueafe 0.000135
even l1
norms same. bit confused!
Comments
Post a Comment