pca.m
来自「最新的模式识别分类工具箱,希望对朋友们有用!」· M 代码 · 共 33 行
M
33 行
function [features, targets, UW] = PCA(features, targets, dimension, region)%Reshape the data points using the principal component analysis%Inputs:% train_features - Input features% train_targets - Input targets% dimension - Number of dimensions for the output data points% region - Decision region vector: [-x x -y y number_of_points]%%Outputs% features - New features% targets - New targets% UW - Reshape martix% mf - Reshape means[r,c] = size(features);if (r < dimension), disp('Required dimension is larger than the data dimension.') disp(['Will use dimension ' num2str(r)]) dimension = r;end%Calculate cov matrix and the PCA matrixesQ = (features * features')/c;[V, D] = eig(Q);W = V(:,r-dimension+1:r)';U = Q*W'*inv(W*Q*W');%Calculate new featuresUW = U*W;features = UW*features;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?