資源簡介
計算Local outlier factor的matlab實現(xiàn),附帶有例子。
代碼片段和文件信息
function?lof?=?LOF(dist)
K=10;
m=size(dist1);?????????????????%m為對象數(shù),dist為兩兩之間的距離
distance?=?zeros(mm);
num?=?zeros(mm);???????????????%distance?和num用來記錄排序后的順序,和對象編號順序
kdistance?=?zeros(m1);?????????%計算每個對象的kdistance
count??=?zeros(m1);????????????%k鄰域的對象數(shù)
reachdist?=?zeros(mm);?????????%計算兩兩之間的reachable-distance
lrd?=?zeros(m1);
lof?=?zeros(m1);
%計算k-distance
for?i=1:m?
????[distance(i:)num(i:)]=sort(dist(i:)‘a(chǎn)scend‘);
????kdistance(i)=distance(iK+1);?
????count(i)?=?-1;%自己的距離為0,要去掉自己
????for?j?=?1:m
????????if?dist(ij)<=kdistance(i)
????????????count(i)?=?count(i)+1;
????????end
????end
end
????
for?i?=?1:m
????for?j=1:i-1
????????reachdist(ij)?=?max(dist(ij)kdistance(j));
????????reachdist(ji)?=?reachdist(ij);
????end
end
for?i?=?1:m
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1511??2016-04-25?21:57??LOF.m
?????文件?????????221??2016-05-19?11:07??test.m
?????文件???????76836??2016-05-19?11:07??test.mat
- 上一篇:PSINS
- 下一篇:D2D-underlay-power-control-
評論
共有 條評論