一.decomposition
1.简介:
该模块用于进行矩阵分解.其中大多数算法都可用于数据降维
2.使用
(1)类:
"字典学习"(Dictionary learning):class sklearn.decomposition.DictionaryLearning([n_components=None,alpha=1,max_iter=1000,tol=1e-08,fit_algorithm='lars',transform_algorithm='omp',transform_n_nonzero_coefs=None,transform_alpha=None,n_jobs=None,code_init=None,dict_init=None,verbose=False,split_sign=False,random_state=None,positive_code=False,positive_dict=False,transform_max_iter=1000])
#参数说明:
n_components:指定提取的字典元素数量;为int
alpha:指定"稀疏度控制参数"(Sparsity controlling parameter);为float
max_iter:指定最大迭代次数;为int
tol:指定最小误差(若误差小于该值,则停止);为float
fit_algorithm:指定用于学习的算法;为"lars"/"cd"
transform_algorithm:指定数据变换算法;为"lasso_lars"/"lasso_cd"/"lars"/"omp"/"threshold"
transform_n_nonzero_coefs:指定解的每1列中非0系数的数量;为int
#仅当algorithm="lars"/"omp"时使用;且当algorithm="omp"时,会被alpha覆盖
transform_alpha:If algorithm='lasso_lars'/'lasso_cd',alpha is the penalty applied to the L1 norm
If algorithm='threshold',alpha is the absolute value of the threshold below which coefficients will be squashed to zero
If algorithm='omp',alpha is the tolerance parameter:the value of the reconstruction error targeted
In this case,it overrides n_nonzero_coefs
n_jobs:指定要运行的并行计算数量;为int
code_init,dict_init:分别指定代码/字典的初始值(用于"热重启"(warm restart));均为n_components×n_features array
verbose:指定是否输出进度信息;为bool
split_sign:指定是否将稀疏特征向量分割为其负部分和正部分的连接;为bool
#为True可提供下游分类器的性能
random_state:指定使用的随机数;为int/RandomState instance/None
positive_code:,positive_dict:分别指定在寻找代码/字典时是否加强积极性;均为bool
transform_max_iter:指定最大迭代次数;为int
#仅当algorithm="lasso_cd"/"lasso_lars"时使用
######################################################################################################################
"因子分析"(Factor Analysis;FA):class sklearn.decomposition.FactorAnalysis([n_components=None,tol=0.01,copy=True,max_iter=1000,noise_variance_init=None,svd_method='randomized',iterated_power=3,rotation=None,random_state=0])
#参数说明:其他参数同class sklearn.decomposition.DictionaryLearning()
n_components:指定"隐空间"(latent space)的维度;为int/None(特征数量)
copy:指定是否一定创建数据的副本;为bool
noise_variance_init:指定各特征噪声方差的初始值;为array/None(np.ones(n_features))
svd_method:指定使用哪种SVD方法;为"lapack"/"randomized"
iterated_power:指定"幂次法"(power method)的迭代次数;为int
rotation:指定如何选择因子;为"varimax"/"quartimax"
######################################################################################################################
"快速独立成分分析"(Fast Independent Component Analysis;FastICA):class sklearn.decomposition.FastICA([n_components=None,algorithm='parallel',whiten=True,fun='logcosh',fun_args=None,max_iter=200,tol=0.0001,w_init=None,random_state=None])
#参数说明:其他参数同class sklearn.decomposition.DictionaryLearning()
n_components:指定要使用的样本数量;为int
algorithm:指定使用的算法;为"parallel"/"deflation"
whiten:指定是否进行白化;为bool
fun:指定用于近似"负熵"(neg-entropy)的"G函数"(G function)的函数形式;为"logcosh"/"exp"/"cube"/callable
fun_args:指定要传递给fun的其他参数;为dict
w_init:指定混合矩阵的初始值;为n_components×n_components ndarray
######################################################################################################################
"增量主成分分析"(Incremental principal components analysis;IPCA):class sklearn.decomposition.IncrementalPCA([n_components=None,whiten=False,copy=True,batch_size=None])
#参数说明:其他参数同class sklearn.decomposition.FastICA()
n_components:指定要保存的组件数量;为int
batch_size:指定"批"(batch)的大小;为int
#