为什么explained_variance_ratio_fromTruncatedSVD不像 from 那样按降序排列PCA?根据我的经验,列表的第一个元素似乎始终是最低的,然后在第二个元素处,值会跳升,然后从那里按降序排列。为什么是explained_variance_ratio_[0]< explained_variance_ratio_[1]( > explained_variance_ratio_[2]> explained_variance_ratio_[3]…)?这是否意味着第二个“组件”实际上解释了最多的差异(而不是第一个)?
explained_variance_ratio_
TruncatedSVD
PCA
explained_variance_ratio_[0]
explained_variance_ratio_[1]
explained_variance_ratio_[2]
explained_variance_ratio_[3]
重现行为的代码:
from sklearn.decomposition import TruncatedSVD n_components = 50 X_test = np.random.rand(50,100) model = TruncatedSVD(n_components=n_components, algorithm = 'randomized') model.fit_transform(X_test) model.explained_variance_ratio_
如果您首先缩放数据,那么我认为解释的方差比率将按降序排列:
from sklearn.decomposition import TruncatedSVD from sklearn.preprocessing import StandardScaler n_components = 50 X_test = np.random.rand(50,100) scaler = StandardScaler() X_test = scaler.fit_transform(X_test) model = TruncatedSVD(n_components=n_components, algorithm = 'randomized') model.fit_transform(X_test) model.explained_variance_ratio_