function [patterns, targets] = fuzzy_k_means(train_patterns, train_targets, Nmu, plot_on)
%Reduce the number of data points using the fuzzy k-means algorithm
%Inputs:
% train_patterns - Input patterns
% train_targets - Input targets
% Nmu - Number of output data points
% plot_on - Plot stages of the algorithm
%
%Outputs
% patterns - New patterns
% targets - New targets
if (nargin < 4),
plot_on = 0;
end
b = 2;
L = length(train_targets);
dist = zeros(Nmu,L);
label = zeros(1,L);
Dim = size(train_patterns,1);
%Initialize the mu's
mu = randn(Dim,Nmu);
mu = sqrtm(cov(train_patterns',1))*mu + mean(train_patterns')'*ones(1,Nmu);
old_mu = zeros(Dim,Nmu);
%Initialize the P's
P = randn(Nmu,L);
old_P = zeros(Nmu,L);
while ((sum(sum(abs(mu - old_mu) > 1e-5)) + sum(sum(abs(P - old_P) > 1e-5)) > 0)),
old_mu = mu;
old_P = P;
%Classify all the patterns to one of the mu's
for i = 1:Nmu,
dist(i,:) = sum((train_patterns - mu(:,i)*ones(1,L)).^2);
end
%Recompute P's
P = (1./dist).^(1/(b-1));
P = P ./ (ones(Nmu,1) * sum(P));
%Recompute the mu's
P = P.^b;
mu = (train_patterns * P') ./ (ones(Dim,1)*sum(P'));
%Plot centers during training
plot_process(mu, plot_on)
end
%Classify the patterns
[m,label] = max(P);
targets = zeros(1,Nmu);
Uc = unique(train_targets);
for i = 1:Nmu,
N = hist(train_targets(:,find(label == i)), Uc);
[m, max_l] = max(N);
targets(i) = Uc(max_l);
end
patterns = mu;
fuzzy_k_means.rar_K._fuzzy k means_k means_k-means 识别_k-means聚类分
版权申诉
86 浏览量
2022-09-24
05:30:23
上传
评论
收藏 793B RAR 举报
我虽横行却不霸道
- 粉丝: 72
- 资源: 1万+
最新资源
- 农村信用社联合社计算机信息系统投产与变更管理办.docx
- 农村信用社联合社计算机信息系统数据管理办法.docx
- 利用SPSS作临床效度分析线上计算网站介绍-医学研究部统计谘.(医学PPT课件).ppt
- 利用Zabbix监控mysqldump定时备份数据库状态.docx
- 利用计算机解决问题的基本过程.doc
- 化工铁路通信工程总结.doc
- 北京大学网络教育软件工程作业.docx
- 医药公司(连锁店)计算机操作规程未新系统的自行按照旧制修改-新系统过制的编号加修模版.doc
- 医药公司(连锁店)计算机系统操作规程模版.doc
- 医药连锁门店计算机系统的操作和管理程序未新系统的自行按照旧制修改-新系统过制的编号加修模版.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈