⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cluster_cost.m

📁 clustering_code ,Clustering Through Ranking On Manifolds Version 0.2 Copyright by Markus Breit
💻 M
字号:
function [cost_cc,clus_close,cc_on,cc_off,Y] = Cluster_Cost(F,dot_dist,num_classes,n,OPT)%% Clustering Through Ranking On Manifolds% Version 0.2%% Copyright by Markus Breitenbach and Gregory Z. Grudic% This code is for your personal and research use only.%% http://www.cs.colorado.edu/~grudic/% http://ucsu.colorado.edu/~breitenm/%% This software is provided "as is," without warranty of any kind, express% or implied.  In no event shall the authors be held liable% for any direct, indirect, incidental, special or consequential damages% arising out of the use of or inability to use this software.%% assign all n examples to a classY = zeros(n,num_classes);for i=1:n    ind_t = find(max(F(i,:)) == F(i,:));    Y(i,ind_t) = 1;endtot_num = n*n;clus_close = zeros(num_classes,num_classes);clus_count = zeros(num_classes,1);% within clusterfor i = 1:num_classes    ind_t = logical(Y(:,i));    tmp_d_m = dot_dist(ind_t,ind_t); % all dot_dist values of our class    [nt,mt] = size(tmp_d_m);	if nt==0		clus_close(i,i) = 0;	else	    off_diag_ind = find(eye(nt,nt)==0);	    on_diag_ind = find(eye(nt,nt)==1);	    clus_count(i) = length(on_diag_ind);	    if isempty(off_diag_ind)	        clus_close(i,i) = 0;	    else	        clus_close(i,i) = mean(tmp_d_m(off_diag_ind));	    end	end;end%outside clustersfor i = 2:num_classes    for j = 1:i        ind_ti = logical(Y(:,i));        ind_tj = logical(Y(:,j));        tmp_d_m = dot_dist(ind_ti,ind_tj);        if isempty(tmp_d_m)            clus_close(i,j) = 0;            clus_close(j,i) = 0;        else            [nt,mt] = size(tmp_d_m);            %off_diag_ind = find(eye(nt,nt)==0);            clus_close(i,j) = mean(tmp_d_m(:));            clus_close(j,i) = clus_close(i,j);        end    endendind_off_diag = find(eye(num_classes,num_classes)==0);ind_on_diag = find(eye(num_classes,num_classes)==1);cc_off = mean(clus_close(ind_off_diag));cc_on = mean(clus_close(ind_on_diag));if OPT == 1    cost_cc = cc_off-cc_on;else    return;end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -