📄 intersection_reclassification.m
字号:
function sampleLabels = intersection_reclassification(X, sampleLabels,subspaceNumber);% Set constant valuesK_NEAREST_NEIGHBOR = 1;[ambientDimension, sampleNumber]=size(X);method = K_NEAREST_NEIGHBOR;if method == K_NEAREST_NEIGHBOR KConstant = 5; % Create distance matrix distanceMatrix = zeros(sampleNumber, sampleNumber); for sampleIndex=1:sampleNumber for index=sampleIndex+1:sampleNumber distanceMatrix(sampleIndex,index)=norm(X(:,sampleIndex)-X(:,index)); end % Assign an artifial value for the sample itself so that it will % never be its own neighbor. distanceMatrix(sampleIndex, sampleIndex)=inf; end distanceMatrix = distanceMatrix + distanceMatrix.'; % For each sample, find the nearest KConstant neighbors for sampleIndex=1:sampleNumber [ignored, index]= sort(distanceMatrix(:,sampleIndex)); neighborLabels=sampleLabels(index(1:KConstant)); for subspaceIndex=1:subspaceNumber neighborWeight = sum(neighborLabels==subspaceIndex); if neighborWeight>KConstant/2 sampleLabels(sampleIndex)=subspaceIndex; break; end end endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -