學習目標:
matlab降維工具包
提取碼:m6dj
里面含有兩個壓縮包,解壓后的檔案含有:
drtoolbox(1)有工具箱的使用說明pdf和工具箱的下載包:

matlab的資料是接下來演示的資料集:

學習內容:
1、 資料匯入
解壓后有四個MATLAB Data,直接雙擊匯入Matlbel中,其中trainX對應unnamed,trainY對應unnamed1,testX對應unname2,testY對應unname3.這里是一個分類資料集(像trainY就是四類1,2,3,4),并且是高位資料集(trainX就是152個樣本量,但是有153個屬性),


2、 pdf說明書
當時學習這個工具箱的時候找到了這本書《An Introduction to Dimensionality Reduction Using Matlab》,里面詳細說明了工具箱包含的降維方法的理論原理并且有實際例子,非常適合小白學習:

3、 方法演示
方法演示我創建了一個實施腳本hign.mlx:

1.利用intrinsic_dim(X, 'MLE')來查看此方法建議你降維至第幾維
X = unnamed;%資料每個樣本為一行,
labels = unnamed1;
no_dims = round(intrinsic_dim(X, 'MLE'));
disp(['MLE estimate of intrinsic dimensionality: ' num2str(no_dims)]);
這里建議降維至2維,
2.選用合適的方法
不同的降維方法適用于不同的資料集,詳細學習請見《An Introduction to Dimensionality Reduction Using Matlab》,下面演示Laplacian降維和MDS降維,它們都是降至3維的演示:
X = unnamed;%資料每個樣本為一行,
labels = unnamed1;
no_dims = round(intrinsic_dim(X, 'MLE'));
%disp(['MLE estimate of intrinsic dimensionality: ' num2str(no_dims)]);
%[mappedX1, mapping] = compute_mapping(X, 'Laplacian', no_dims);
[mappedX3, mapping3] = compute_mapping(X, 'Laplacian',3);
colormap(jet)
figure, scatter3(mappedX3(:,1), mappedX3(:,2), mappedX3(:,3),30, labels);
%figure, scatter(mappedX1(:,1), mappedX1(:,2),30, labels);
%xlim([-0.3,0.2]);
%ylim([-0.2,0.2]);
%zlim([-0.04,0.022]);
title('Result of Laplacian');

X = unnamed;%資料每個樣本為一行,
labels = unnamed1;
no_dims = round(intrinsic_dim(X, 'MLE'));
%disp(['MLE estimate of intrinsic dimensionality: ' num2str(no_dims)]);
[mappedX1, mapping] = compute_mapping(X, 'MDS', 3);
%colormap(jet)
figure, scatter3(mappedX1(:,1), mappedX1(:,2), mappedX1(:,3),30, labels);
%figure, scatter(mappedX1(:,1), mappedX1(:,2),30, labels);
%xlim([-0.3,0.2]);
%ylim([-0.3,0.2]);
%zlim([-0.4,0.22]);
title('Result of MDS');

3.資料匯出
資料便是上述代碼中[mappedX1, mapping] = compute_mapping(X, 'MDS', 3);的mappedX1.
學習總結
這個降維雖然好用,但是主觀性非常強,本次演示的資料其實降維效果不好,最后進一步做分類器的時候效果很差,嘗試嘗試各種降維方式也是受益匪淺,但是還需慎用,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/259827.html
標籤:其他
上一篇:字串API自定義實作
