這個工具箱的主頁以下,如今的最新版本是2013.3.21更新,版本v0.8.1b
這裏有兩個這個工具箱的簡單介紹:
【Matlab】數據降維工具箱drtoolbox
【Dimensionality Reduction】數據降維方法分類
下面稍詳細介紹一些這個工具箱。下載壓縮包,解壓后里面有一個Readme.txt文檔,裏面寫有工具箱的相關介紹,這裏作簡單翻譯吧。
安裝
把解壓後的文件夾放到$MATLAB_DIR/toolbox下,固然也能夠放到任意本身想放的路徑,而後打開matlab設置路徑Set Path,選擇'Add with subfolders...',選中drtoolbox,保存便可。
設置完成後,須要對函數作編譯,雖然一些壓縮包自帶一些編譯好的mex文件,但可能並不適合你的平臺,因此最好在本身電腦上完成編譯,方法是讓matlab進入drtoolbox文件,而後運行mexall命令。
特性
當前版本的工具箱包括34種數據降維技術,以下,這些能夠經過compute_mapping函數或GUI調用:
- 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') ---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')
- Locality Preserving Projection ('LPP') ---局部保留投影
- Stochastic Proximity Embedding ('SPE')
- Linear Local Tangent Space Alignment ('LLTSA')
- Conformal Eigenmaps ('CCA', implemented as an 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')
- Deep autoencoders ('Autoencoder')
- Neighborhood Components Analysis ('NCA')
- Maximally Collapsing Metric Learning ('MCML')
- Large Margin Nearest Neighhbor metric learning ('LMNN')
線性/非線性
線性降維是指經過降維所獲得的低維數據能保持高維數據點之間的線性關係。線性降維方法主要包括PCA、LDA、LPP(LPP實際上是Laplacian Eigenmaps的線性表示);非線性降維一類是基於核的,如KPCA,此處暫不討論,另外一類就是一般所說的流形學習:從高維採樣數據中恢復出低維流形結構(假設數據是均勻採樣於一個高維歐式空間中的低維流形),即找到高維空間中的低維流形,並求出相應的嵌入映射。非線性流形學習方法有:Isomap、LLE、Laplacian Eigenmaps、LTSA、MVU。
總體來講,線性方法計算塊,複雜度低,但對複雜的數據降維效果較差。
監督/非監督
監督式和非監督式學習的主要區別在於數據樣本是否存在類別信息。非監督降維方法的目標是在降維時使得信息的損失最小,如PCA、LPP、Isomap、LLE、Laplacian Eigenmaps、LTSA、MVU;監督式降維方法的目標是最大化類別間的辨別信,如LDA。事實上,對於非監督式降維算法,都有相應的監督式或半監督式方法的研究。
全局/局部
局部方法僅考慮樣品集合的局部信息,即數據點與臨近點之間的關係。局部方法以LLE爲表明,還包括Laplacian Eigenmaps、LPP、LTSA。
全局方法不只考慮樣本幾何的局部信息,和考慮樣本集合的全局信息,及樣本點與非臨近點之間的關係。全局算法有PCA、LDA、Isomap、MVU。
因爲局部方法並不考慮數據流形上相距較遠的樣本之間的關係,所以,局部方法沒法達到「使在數據流形上相距較遠的樣本的特徵也相距較遠」的目的。
如下是對一組三維數據(900樣本)降到一維,應用八種算法的時間對比:
另外,工具箱還提供6種技術作本質維度估計intrinsic dimensionality estimation以下,就是估計降到多少維較好。這些技術能夠利用intrinsic_dim函數調用。
- Eigenvalue-based estimation ('EigValue')
- Maximum Likelihood Estimator ('MLE')
- Estimator based on correlation dimension ('CorrDim')
- Estimator based on nearest neighbor evaluation ('NearNb')
- Estimator based on packing numbers ('PackingNumbers')
- Estimator based on geodesic minimum spanning tree ('GMST')
此外,工具箱還包括數據白化函數prewhiten、樣本外點外延的計算和估計out_of_sample(或out_of_sample_est)和產生測試數據集函數generate_data。這些方法和函數均可以經過GUI方便的調用,drgui能夠調出此GUI,以下,樣子比較粗糙,使用還算方便,工具箱具備的功能一目瞭然
用法
這個工具箱提供給用戶使用的接口函數都在與這個Readme文件同路徑的目錄,主要包括以下文件:(基本上面都提到過)
compute_mapping.m |
This function performs the specified dimension reduction technique on the specified data set. Type HELP COMPUTE_MAPPING to get details on supported techniques and on the parameters of the techniques. |
在指定的數據集上執行指定的降維技術。help compute_mapping能夠查看函數用法和參數選項。 |
drgui.m |
This function allows you to use some of the toolbox functionality via a graphical user interface. |
打開GUI,方便調用工具箱函數。 |
generate_data.m |
This function generates some artificial data sets such as the Swiss roll data set. |
產生一些人工數據集,如Swiss環數據。 |
intrinsic_dim.m |
This function performs intrinsic dimensionality estimation using the specified estimator on the specified data set. |
使用指定的估計器對指定的數據作本質維數估計。 |
mexall.m |
This function compiles all the MEX-files that are required to use the toolbox. Please run immediately after installation. |
編譯這個工具箱須要的全部mex文件。安裝後請先運行此函數。 |
out_of_sample.m |
This function takes as input a dimension reduction mapping and a set of new test points, and outputs the locations of the test points in the reduced space. This function is only supported by parametric and spectral techniques. |
以降維後的映射和新測試點爲輸入,輸出這些新測試點在降維空間中的位置,這個函數只支持參數化和譜分析技術的樣本外點外延。 |
out_of_sample_est.m |
This function takes as input a training set, a reduced version of that training set, and a set of new test points, and finds an approximate locations of the test points in the reduced space. Only use this function for techniques that do not support out-of-sample-extensions. |
以訓練集、維度下降後的訓練集和一些新測試點爲輸入來找到這些新測試點在低維空間的大概位置。這個函數只適用於那些不支持樣本外點外延的技術。 |
prewhiten.m |
This function whitens data, i.e., it makes it zero-mean, identity-covariance |
數據白化,即去均值、協方差單位化。 |
reconstruct_data.m |
This function computes reconstructions of reduced data for linear techniques and autoencoders. |
對線性技術和自編碼技術作降維數據重構。 |
test_toolbox.m |
This function runs a full test of all functionalities of the toolbox. |
快速對工具箱的全部函數作全測試。 |
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
運行結果以下
此工具箱全部函數均可以用在著名模式識別PRTools工具箱的數據集上(
http://prtools.org)。有關降維的更多選項能夠看compute_mapping的幫助,help compute_mapping;有關本質維數估計的更多信息能夠看intrinsic_dim的幫助,help intrinsic_dim。
使用中的問題
若是你在運行此工具箱的函數時,獲得某些文件不存在的錯誤,這多是由於一些mex函數被使用了。雖然工具箱提供了一些mex函數的編譯版本,但可能並不適合你的平臺,因此這個問題能夠經過運行mexall函數編譯所有mex函數來解決。這個命令也能夠解決Isomap算法最短路徑計算慢的問題。
若是在運行FastMVU算法時遇到有關CSDP的錯誤,這是因爲你平臺上的二進制CSDP丟失的緣故。能夠在網站
https://projects.coin-or.org/Csdp/上獲得二進制CSDP的發佈版本,將其放在drtoolbox/techniques文件夾下便可。注意確保不一樣平臺正確的文件名(csdp.exe for Windows, csdpmac for Mac OS X (PowerPC), csdpmaci for Mac OS X (Intel), and csdplinux for Linux)。
不少降維方法都要執行稀疏矩陣的譜分析。固然特徵值分析eigenanalysis是一個經常使用的方法,但大矩陣的特徵值分解可能會很耗時,因此工具箱提供了兩種特徵值分析方法:
- The original Matlab functions (based on Arnoldi methods)
- The JDQR functions (based on Jacobi-Davidson methods)
對於10000點之內的問題,建議使用Matlab setting,超過10000點,則JDQR值得一試。
1. When using the toolbox, the code quits saying that some function could not be found?
2. Next to reducing the dimensionality of my data, Isomap/LLE/Laplacian Eigenmaps/LTSA also reduced the number of data points? Where did these points go?
Isomap/LLE/Laplacian Eigenmaps/LTSA算法使用後,數據點數減小的問題。這個是基於鄰域圖的算法的廣泛行爲,這些算法把數據嵌入到相關連鄰域圖中,若是鄰域圖不相關連,則只嵌入最大關連成分,從而帶來數據點數的減小。你能夠經過mapping.conn_comp獲得嵌入數據點的次序,mapping由調用compute_mapping函數獲得。若是你不想丟失數據點,就不要用流形學習算法。
3. How do I provide label information to the supervised techniques/metric learners?
如何在監督學習中提供標籤信息。在監督學習算法中(LDA, NCA, MCML, and LMNN),能夠設置數據矩陣的第一列元素爲相應標籤,這些標籤必定要是數值型的。若是要嵌入測試數據,則在out_of_sample函數中使用無標籤的數據。
4. How do I project low-dimensional data back into the data space?
如何將低維數據映射回原空間。能反向映射的算法只有使用了線性技術、自編碼和GPLVM的算法,但這個功能工具箱如今還不提供。
5. Which techniques support an exact out-of-sample extension?
哪些方法支持準確的樣本外點外延。只有參數化降維技術,即學習獲得一個原數據空間和低維潛在空間的確切函數的算法,支持準確的樣本外點外延。全部的線性技術(PCA, LDA, NCA, MCML, LPP, and NPE)和自編碼技術支持準確外延。譜分析技術如Isomap, LLE, and Laplacian Eigenmaps,支持基於Nyström approximation的樣本外點外延估計。外延使用工具箱函數out_of_sample實現。
6. Which technique should I use to visualize high-dimensional data in a scatter plot?
哪些技術適合在散點圖上展現高維數據。t-SNE是最適合的算法;流形學習經常並不適於數據展現,由於它有協方差約束的問題;參數化技術一般也不適合展現,由於他們在數據和展現之間存在約束。
相關參考文獻
- L.J.P. van der Maaten, E.O. Postma, and H.J. van den Herik. Dimensionality Reduction: A Comparative Review. Tilburg University Technical Report, TiCC-TR 2009-005, 2009.
- L.J.P. van der Maaten and G.E. Hinton. Visualizing High-Dimensional Data Using t-SNE. Journal of Machine Learning Research 9(Nov):2579-2605, 2008.