[译]sklearn.decomposition.TruncatedSVD
作者:互联网
class sklearn.decomposition.TruncatedSVD(n_components=2, algorithm=’randomized’, n_iter=5, random_state=None, tol=0.0)
采用阶段奇异值分解SVD降维。
与PCA相比,这种方式再计算SVD之前不指定数据中心。这意味着他可以有效的处理scipy.sparse稀疏矩阵。
特别的, truncated SVD作用于sklearn.feature_extraction.text向量化后返回的 term count/tf-idf矩阵。在这种情况下又被成为LSA( latent semantic analysis)
这种估计支持两种算法:快速随机SVD;更有效的用ARPACK 作为本征求解的朴素算法。
Parameters | 数据类型 | 意义 |
---|---|---|
n_components | int, default = 2 | 目标输出维度,必须少于特征维数,默认数据是为了可视化;对于LSA推荐100 |
algorithm | string, default = “randomized” | SVD求解用,arpack或者randomized |
n_iter | int, optional (default 5) | randomized SVD solver的迭代次数,ARPACK不可用 |
random_state | int, RandomState instance or None, optional, default = None | int:随机数发生器种子 RandomState instance:random_state是随机数发生器 None:np.random采用的RandomState实例 |
tol | float, optional | ARPACK的公差 0:machine precision randomized SVD solver忽略 |
Attributes | 数据类型 | 意义 |
---|---|---|
components_ | array, shape (n_components, n_features) | |
explained_variance_ | array, shape (n_components,) | 公差 |
explained_variance_ratio_ | array, shape (n_components,) | |
singular_values_ | array, shape (n_components,) | 每个选定components的奇异值 |
Method | 意义 |
---|---|
fit (self, X[, y]) |
通过X拟合LSI |
fit_transform (self, X[, y]) |
Fit LSI model to X and perform dimensionality reduction on X. |
get_params (self[, deep]) |
Get parameters for this estimator. |
inverse_transform (self, X) |
Transform X back to its original space. |
set_params (self, **params) |
Set the parameters of this estimator. |
transform (self, X) |
Perform dimensionality reduction on X. |
标签:None,SVD,random,shape,decomposition,components,TruncatedSVD,self,sklearn 来源: https://blog.csdn.net/The_Time_Runner/article/details/93621908