MATLAB数据降维工具箱drtoolbox的安装过程及使用

最近想做数据降维的处理工作,接触到drtoolbox工具箱

感谢:http://blog.csdn.net/xiaowei_cqu 提供的博文,就文中的内容做些补充

 

The Matlab Toolbox for Dimensionality Reduction contains Matlab implementations of 38 techniques for dimensionality reduction and metric learning.

下载地址:

https://lvdmaaten.github.io/drtoolbox/code/drtoolbox.tar.gz

ThisMatlab toolbox implements 32 techniques for dimensionality reduction. Thesetechniques are all available through the COMPUTE_MAPPING function or trhoughthe GUI. The following techniques are available:

  •   Principal Component Analysis ('PCA')
  •   Linear Discriminant Analysis ('LDA')
  •   Multidimensional scaling ('MDS')
  •   Probabilistic PCA ('ProbPCA')
  •   Factor analysis ('FactorAnalysis')
  •   Sammon mapping ('Sammon')
  •   Isomap ('Isomap')
  •   Landmark Isomap ('LandmarkIsomap')
  •   Locally Linear Embedding ('LLE')
  •   Laplacian Eigenmaps ('Laplacian')
  •   Hessian LLE ('HessianLLE')
  •   Local Tangent Space Alignment ('LTSA')
  •   Diffusion maps ('DiffusionMaps')
  •   Kernel PCA ('KernelPCA')
  •   Generalized Discriminant Analysis('KernelLDA')
  •   Stochastic Neighbor Embedding ('SNE')
  •   Symmetric Stochastic Neighbor Embedding('SymSNE')
  •   t-Distributed Stochastic Neighbor Embedding('tSNE')
  •   Neighborhood Preserving Embedding ('NPE')
  •   Linearity Preserving Projection ('LPP')
  •   Stochastic Proximity Embedding ('SPE')
  •   Linear Local Tangent Space Alignment('LLTSA')
  •   Conformal Eigenmaps ('CCA', implemented asan extension of LLE)
  •   Maximum Variance Unfolding ('MVU',implemented as an extension of LLE)
  •   Landmark Maximum Variance Unfolding('LandmarkMVU')
  •   Fast Maximum Variance Unfolding ('FastMVU')
  •   Locally Linear Coordination ('LLC')
  •   Manifold charting ('ManifoldChart')
  •   Coordinated Factor Analysis ('CFA')
  •   Gaussian Process Latent Variable Model('GPLVM')
  •   Autoencoders using stack-of-RBMs pretraining('AutoEncoderRBM')
  •   Autoencoders using evolutionary optimization('AutoEncoderEA')

- 主成分分析( 'PCA')

- 线性判别分析( 'LDA')

- 多维定标( 'MDS')

- 概率PCA( 'ProbPCA')

- 因子分析( 'FactorAnalysis')

- 利用Sammon映射( '的Sammon')

- Isomap的CWME( 'Isomap的CWME')

- 地界标均匀映射( 'LandmarkIsomap')

- 局部线性嵌入( 'LLE')

- 拉普拉斯特征映射(“拉普拉斯”)

- 海森LLE( 'HessianLLE')

- 局部切空间排列(“LTSA”)

- 扩散地图( 'DiffusionMaps')

- 核PCA( 'KernelPCA')

- 广义判别分析( 'KernelLDA')

- 随机邻居嵌入( 'SNE')

- 对称随机邻居嵌入(“SymSNE”)

- 叔分布式随机邻居嵌入(“tSNE”)

- 保持近邻嵌入( 'NPE')

- 线性保持投影( 'LPP')

- 随机接近嵌入( 'SPE')

- 线性局部切空间排列(“LLTSA”)

- 共形特征映射(“CCA”,LLE的实施峨山扩展)

- 最大方差展开(“MVU”,作为LLE的扩展实现)

- 标最大方差展开(“LandmarkMVU”)

- 快速最大方差展开(“FastMVU”)

- 局部线性协调( 'LLC')

- 阀组图表( 'ManifoldChart')

- 协调因子分析( 'CFA')

- 高斯过程潜变量模型(“GPLVM”)

- 自动编码使用堆叠的-RBMS预训练( 'AutoEncoderRBM')

- 使用自动编码进化优化(“AutoEncoderEA”)

Furthermore,the toolbox contains 6 techniques for intrinsic dimensionality estimation.These techniques are available through the function INTRINSIC_DIM. Thefollowing techniques are available:

  •   Eigenvalue-based estimation ('EigValue')
  •   Maximum Likelihood Estimator ('MLE')
  •   Estimator based on correlation dimension('CorrDim')
  •   Estimator based on nearest neighborevaluation ('NearNb')
  •   Estimator based on packing numbers('PackingNumbers')
  •   Estimator based on geodesic minimum spanningtree ('GMST')

Inaddition to these techniques, the toolbox contains functions for prewhiteningof data (the function PREWHITEN), exact and estimate out-of-sample extension(the functions OUT_OF_SAMPLE and OUT_OF_SAMPLE_EST), and a function thatgenerates toy datasets (the function GENERATE_DATA).

Thegraphical user interface of the toolbox is accessible through the DRGUIfunction.

2.安装

将下载好的drtoolbox工具包解压到指定目录:D:\MATLAB\R2014b\toolbox

找到' D:\MATLAB\R2012b\toolbox\local\pathdef.m'文件,打开,并把路径添加到该文件中,保存。

运行rehash toolboxcache 命令,完成工具箱加载

>>rehash toolboxcache

测试

>>what drtoolbox

 

3.工具箱说明

 

数据降维基本原理是将样本点从输入空间通过线性或非线性变换映射到一个低维空间,从而获得一个关于原数据集紧致的低维表示。

算法基本分类:

线性/非线性

线性降维是指通过降维所得到的低维数据能保持高维数据点之间的线性关系。线性降维方法主要包括PCA、LDA、LPP(LPP其实是LaplacianEigenmaps的线性表示);非线性降维一类是基于核的,如KPCA,此处暂不讨论;另一类就是通常所说的流形学习:从高维采样数据中恢复出低维流形结构(假设数据是均匀采样于一个高维欧式空间中的低维流形),即找到高维空间中的低维流形,并求出相应的嵌入映射。非线性流形学习方法有:Isomap、LLE、LaplacianEigenmaps、LTSA、MVU

整体来说,线性方法计算块,复杂度低,但对复杂的数据降维效果较差。

监督/非监督

监督式和非监督式学习的主要区别在于数据样本是否存在类别信息。非监督降维方法的目标是在降维时使得信息的损失最小,如PCA、LPP、Isomap、LLE、LaplacianEigenmaps、LTSA、MVU;监督式降维方法的目标是最大化类别间的辨别信,如LDA。事实上,对于非监督式降维算法,都有相应的监督式或半监督式方法的研究。

全局/局部

局部方法仅考虑样品集合的局部信息,即数据点与临近点之间的关系。局部方法以LLE为代表,还包括LaplacianEigenmaps、LPP、LTSA。

全局方法不仅考虑样本几何的局部信息,和考虑样本集合的全局信息,及样本点与非临近点之间的关系。全局算法有PCA、LDA、Isomap、MVU。

由于局部方法并不考虑数据流形上相距较远的样本之间的关系,因此,局部方法无法达到“使在数据流形上相距较远的样本的特征也相距较远”的目的。

4.工具箱使用

 

工具箱提供给用户使用的接口函数都在与这个Readme文件同路径的目录,主要包括如下文件:

 

 

使用实例:

clc  
clear  
close all  
  
% 产生测试数据  
[X, labels] = generate_data('helix', 2000);  
figure  
scatter3(X(:,1), X(:,2), X(:,3), 5, labels)  
title('Original dataset')  
drawnow  
  
% 估计本质维数  
no_dims = round(intrinsic_dim(X, 'MLE'));  
disp(['MLE estimate of intrinsic dimensionality: ' num2str(no_dims)]);  
  
% PCA降维  
[mappedX, mapping] = compute_mapping(X, 'PCA', no_dims);  
figure  
scatter(mappedX(:,1), mappedX(:,2), 5, labels)  
title('Result of PCA')  
  
% Laplacian降维  
[mappedX, mapping] = compute_mapping(X, 'Laplacian', no_dims, 7);  
figure  
scatter(mappedX(:,1), mappedX(:,2), 5, labels(mapping.conn_comp))  
title('Result of Laplacian Eigenmaps')  
drawnow  
  
% Isomap降维  
[mappedX, mapping] = compute_mapping(X, 'Isomap', no_dims);  
figure  
scatter(mappedX(:,1), mappedX(:,2), 5, labels(mapping.conn_comp))  
title('Result of Isomap')  
drawnow  

 

mappedX = compute_mapping(X, 'PCA', 1);  


具体参见说明文档。

在使用‘Isomap’算法时,会遇到错误如下:  

Invalid MEX-file C:\Program Files\MATLAB\R2010b\toolbox\drtoolbox\techniques\dijkstra.dll 找不到指定模块

发现相应路径中,dijkstra.dll的文件是在的,于是以为是环境变量或者Progam Files空格的问题,尝试修改均无效。

后来仔细阅读了源文件的注释才发现是编译版本问题。dijkstra函数是用C++实现的,需要用matlab的mex编译器编译成dll调用。虽然工具箱中已经有相应编译的dijkstra.dll,但不同版本的Matlab调用会遇到问题,需要重新编译。

在windows命令行cmd中,用cd命令更改路径到工具箱techniques路径下,运行命令:

  1. mex -O dijkstra.cpp  

编译出现错误:

1)   Cannot open include file 'iostream.h' : No such file or directory

      修改dijkstra.cpp中 include<iosteam.h>为<iosteam>

2) ‘cout’ : undeclared identifier       ‘cin’ : undeclared identifier 

      在dijsktra.cpp中加入一行 using namespace std;

编译成功之后,在techniques文件夹下出现dijkstra.mexw32或者dijkstra.mexw64 的文件(这个是根据自身系统而来),即为新编译的dll。我们可以修改之前的为dijkstra.dll.old,重命名dijkstra.mexw32/64为dijkstra.dll。

 

参考博客

  • http://blog.csdn.net/xiaowei_cqu/article/details/7515077
  • http://blog.csdn.net/jojozhangju/article/details/19329207
 
评论 32
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

uncle_ll

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值