日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab中CH指标聚类评价指标,MATLAB聚类有效性评价指标(外部)

發布時間:2023/12/1 循环神经网络 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab中CH指标聚类评价指标,MATLAB聚类有效性评价指标(外部) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

MATLAB聚類有效性評價指標(外部)

作者:凱魯嘎吉 - 博客園?http://www.cnblogs.com/kailugaji/

更多內容,請看標簽:MATLAB、聚類

前提:數據的真實標簽已知!

1. 歸一化互信息(Normalized Mutual information)

定義

程序

function MIhat = nmi(A, B)

%NMI Normalized mutual information

% A, B: 1*N;

if length(A) ~= length(B)

error('length( A ) must == length( B)');

end

N = length(A);

A_id = unique(A);

K_A = length(A_id);

B_id = unique(B);

K_B = length(B_id);

% Mutual information

A_occur = double (repmat( A, K_A, 1) == repmat( A_id', 1, N ));

B_occur = double (repmat( B, K_B, 1) == repmat( B_id', 1, N ));

AB_occur = A_occur * B_occur';

P_A= sum(A_occur') / N;

P_B = sum(B_occur') / N;

P_AB = AB_occur / N;

MImatrix = P_AB .* log(P_AB ./(P_A' * P_B)+eps);

MI = sum(MImatrix(:));

% Entropies

H_A = -sum(P_A .* log(P_A + eps),2);

H_B= -sum(P_B .* log(P_B + eps),2);

%Normalized Mutual information

MIhat = MI / sqrt(H_A*H_B);

結果

>> A = [1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3];

>> B = [1 2 1 1 1 1 1 2 2 2 2 3 1 1 3 3 3];

>> MIhat = nmi(A, B)

MIhat =

0.3646

2. Rand統計量(Rand index)

定義

程序

function [AR,RI,MI,HI]=RandIndex(c1,c2)

%RANDINDEX - calculates Rand Indices to compare two partitions

% ARI=RANDINDEX(c1,c2), where c1,c2 are vectors listing the

% class membership, returns the "Hubert & Arabie adjusted Rand index".

% [AR,RI,MI,HI]=RANDINDEX(c1,c2) returns the adjusted Rand index,

% the unadjusted Rand index, "Mirkin's" index and "Hubert's" index.

if nargin < 2 || min(size(c1)) > 1 || min(size(c2)) > 1

error('RandIndex: Requires two vector arguments')

return

end

C=Contingency(c1,c2);%form contingency matrix

n=sum(sum(C));

nis=sum(sum(C,2).^2);%sum of squares of sums of rows

njs=sum(sum(C,1).^2);%sum of squares of sums of columns

t1=nchoosek(n,2);%total number of pairs of entities

t2=sum(sum(C.^2));%sum over rows & columnns of nij^2

t3=.5*(nis+njs);

%Expected index (for adjustment)

nc=(n*(n^2+1)-(n+1)*nis-(n+1)*njs+2*(nis*njs)/n)/(2*(n-1));

A=t1+t2-t3;%no. agreements

D= -t2+t3;%no. disagreements

if t1==nc

AR=0;%avoid division by zero; if k=1, define Rand = 0

else

AR=(A-nc)/(t1-nc);%adjusted Rand - Hubert & Arabie 1985

end

RI=A/t1;%Rand 1971%Probability of agreement

MI=D/t1;%Mirkin 1970%p(disagreement)

HI=(A-D)/t1;%Hubert 1977%p(agree)-p(disagree)

function Cont=Contingency(Mem1,Mem2)

if nargin < 2 || min(size(Mem1)) > 1 || min(size(Mem2)) > 1

error('Contingency: Requires two vector arguments')

return

end

Cont=zeros(max(Mem1),max(Mem2));

for i = 1:length(Mem1)

Cont(Mem1(i),Mem2(i))=Cont(Mem1(i),Mem2(i))+1;

end

程序中包含了四種聚類度量方法:Adjusted Rand index、Rand index、Mirkin index、Hubert index。

結果

>> A = [1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3];

>> B = [1 2 1 1 1 1 1 2 2 2 2 3 1 1 3 3 3];

>> [AR,RI,MI,HI]=RandIndex(A,B)

AR =

0.2429

RI =

0.6765

MI =

0.3235

HI =

0.3529

3. 參考文獻

(simple) Tool for estimating the number of clusters

Mutual information and Normalized Mutual information 互信息和標準化互信息

Evaluation of clustering

總結

以上是生活随笔為你收集整理的matlab中CH指标聚类评价指标,MATLAB聚类有效性评价指标(外部)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。