sklearn.manifold.LocallyLinearEmbedding

class sklearn.manifold.LocallyLinearEmbedding(*, n_neighbors=5, n_components=2, reg=0.001, eigen_solver='auto', tol=1e-06, max_iter=100, method='standard', hessian_tol=0.0001, modified_tol=1e-12, neighbors_algorithm='auto', random_state=None, n_jobs=None)

[源码]

局部线性嵌入

用户指南中阅读更多内容。

参数 说明
n_neighbors integer
每个点要考虑的邻居数量。
n_components integer
流形的坐标数
reg float
正则化常数,乘以距离的局部协方差矩阵的轨迹。
eigen_solver string, {‘auto’, ‘arpack’, ‘dense’}
自动:算法将尝试为输入数据选择最佳方法
arpack use arnoldi iteration in shift-invert mode.
对于此方法,M可以是稠密矩阵,稀疏矩阵或一般线性式子。警告:由于某些问题,ARPACK可能不稳定。最好尝试几个随机种子以检查结果。
dense use standard dense matrix operations for the eigenvalue
分解。对于此方法,M必须为数组或矩阵类型。对于大问题应避免使用此方法。
tol float, optional
如果eigen_solver==’dense’,则不使用“arpack”方法的容差。
max_iter integer
arpack求解器的最大迭代次数。如果eigen_solver =='dense',则不使用。
method string (‘standard’, ‘hessian’, ‘modified’ or ‘ltsa’)
standard use the standard locally linear embedding algorithm. see
参考参考文献[1]
hessian use the Hessian eigenmap method. This method requires
n_neighbors > n_components * (1 + (n_components + 1) / 2
参见参考文献[2]
modified use the modified locally linear embedding algorithm.
参见参考文献[3]
ltsa use local tangent space alignment algorithm
参见参考文献[4]
hessian_tol float, optional
Hessian特征映射方法的公差。仅在method == 'hessian'这种情况下使用
modified_tol float, optional
修正的LLE方法的公差。仅在method == 'hessian'这种情况下使用
neighbors_algorithm string [‘auto’,’brute’,’kd_tree’,’ball_tree’]
用于最近邻居搜索的算法,传递给邻居。NearestNeighbors实例
random_state int, RandomState instance, default=None
eigen_solver=='arpack' 时确定随机数生成器 。在多个函数调用之间传递int以获得可重复的结果。请参阅:term: Glossary <random_state>.
n_jobs int or None, optional (default=None)
用于进行计算的CPU数量。 None除非在joblib.parallel_backend环境中,否则表示1 。 undefined表示使用所有处理器。有关更多详细信息,请参见词汇表
属性 说明
embedding_ array-like, shape [n_samples, n_components]
存储嵌入向量
reconstruction_error_ float
与重建相关的错误 embedding_
nbrs_ NearestNeighbors object
存储最近的邻居实例,包括BallTree或KDtree(如果适用)。

参考文献

1 Roweis, S. & Saul, L. Nonlinear dimensionality reduction by locally linear embedding. Science 290:2323 (2000).

2 Donoho, D. & Grimes, C. Hessian eigenmaps: Locally linear embedding techniques for high-dimensional data. Proc Natl Acad Sci U S A. 100:5591 (2003).

3 Zhang, Z. & Wang, J. MLLE: Modified Locally Linear Embedding Using Multiple Weights. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.70.382

4 Zhang, Z. & Zha, H. Principal manifolds and nonlinear dimensionality reduction via tangent space alignment. Journal of Shanghai Univ. 8:406 (2004)

实例

>>> from sklearn.datasets import load_digits
>>> from sklearn.manifold import LocallyLinearEmbedding
>>> X, _ = load_digits(return_X_y=True)
>>> X.shape
(179764)
>>> embedding = LocallyLinearEmbedding(n_components=2)
>>> X_transformed = embedding.fit_transform(X[:100])
>>> X_transformed.shape
(1002)
方法 说明
fit(X[, y]) 计算数据X的嵌入向量
fit_transform(X[, y]) 计算数据X的嵌入向量并变换X。
get_params([deep]) 获取此估计量的参数。
set_params(**params) 设置此估算量的参数。
transform(X) 将新点转换为嵌入空间。
__init__(*, n_neighbors=5, n_components=2, reg=0.001, eigen_solver='auto', tol=1e-06, max_iter=100, method='standard', hessian_tol=0.0001, modified_tol=1e-12, neighbors_algorithm='auto', random_state=None, n_jobs=None)

[源码]

初始化self, 请参阅help(type(self))以获得准确的说明。

fit(X, y=None)

[源码]

计算数据X的嵌入向量

参数 说明
X array-like of shape [n_samples, n_features]
训练集。
y Ignored
返回值 说明
self returns an instance of self.
fit_transform(X, y=None)

[源码]

计算数据X的嵌入向量并变换X。

参数 说明
X array-like of shape [n_samples, n_features]
训练集。
y Ignored
返回值 说明
X_new array-like, shape (n_samples, n_components)
get_params(deep=True)

[源码]

获取此估计量的参数。

参数 说明
deep bool, default=True
如果为True,则将返回此估算量和作为估算量的所包含子对象的参数。
返回值 说明
params mapping of string to any
映射到其值的参数名。
set_params(**params)

[源码]

设置此估算量的参数。

该方法适用于简单估计量以及嵌套对象(例如pipelines)。后者具有形式的参数。<component>__<parameter>以便可以更新嵌套对象的每个组件。

参数 说明
**params dict
估算量参数。
返回值
self object
估算量实例。
transform(X)

[源码]

将新点转换为嵌入空间。

参数 说明
X array-like of shape (n_samples, n_features)
返回值 说明
X_new array, shape = [n_samples, n_components]

由于此方法执行缩放,因此不建议将其与非缩放不变的方法(例如SVM)一起使用.