KLFCM的matlab程序

时间: 2023-07-31 09:14:07 浏览: 46
以下是KLFCM的Matlab程序示例: ```matlab function [U, center, obj_fcn] = klfcm(data, cluster_n, options) % KLFCM - Knowledge-based Local Fuzzy C-Means Clustering % % Syntax: % [U, center, obj_fcn] = klfcm(data, cluster_n) % [U, center, obj_fcn] = klfcm(data, cluster_n, options) % % Inputs: % data - Data matrix. Each row represents a data point. % cluster_n - Number of clusters. % options - (optional) Struct that contains the algorithm options: % options.c - exponent for the matrix U (default 2) % options.m - fuzzifier for the matrix U (default 2) % options.e - minimum amount of improvement (default 1e-5) % options.maxit - maximum number of iterations (default 100) % options.display- display information on screen (true or false) % % Outputs: % U - Fuzzy partition matrix. Each element (i,j) represents the % degree of membership of the i-th point to the j-th cluster. % center - Cluster centers. Each row is a center. % obj_fcn- Objective function history. % % Example: % load iris % [U, center, obj_fcn] = klfcm(iris(:,1:4), 3); % plot(obj_fcn) % % Reference: % Bezdek, J.C., Ehrlich, R., Full, W. (1984). FCM: The fuzzy c-means % clustering algorithm. Computers & Geosciences, 10(2-3), 191-203. % % Li, C., Li, Y., Yang, X., & Liu, Y. (2012). Knowledge-based local fuzzy % c-means clustering algorithm. Journal of Software Engineering, 6(2), % 65-75. %% Check input if nargin < 2 error('At least two input arguments are required.'); end if nargin < 3 options = []; end % Default options options = default_options(options); %% Initialization obj_fcn = zeros(options.maxit, 1); [n, col] = size(data); U = rand(n, cluster_n); center = rand(cluster_n, col); % Normalize U sumU = sum(U, 2); sumU(sumU == 0) = eps; U = U ./ repmat(sumU, [1, cluster_n]); %% Main loop for i = 1:options.maxit % Calculate distances temp = zeros(n, cluster_n); for j = 1:cluster_n temp(:,j) = sqrt(sum((data - repmat(center(j,:), [n 1])).^2, 2)); end % Calculate new partition matrix temp = temp .^ (-2/(options.m-1)); U = temp ./ repmat(sum(temp, 2), [1, cluster_n]); % Calculate new centers center = (U .^ options.c)' * data ./ repmat(sum(U .^ options.c)', [1, col]); % Check termination criterion obj_fcn(i) = sum(sum((U.^options.c) .* (temp.^2))); if i > 1 if abs(obj_fcn(i) - obj_fcn(i-1)) < options.e break; end end % Normalize U sumU = sum(U, 2); sumU(sumU == 0) = eps; U = U ./ repmat(sumU, [1, cluster_n]); % Display information if options.display fprintf('Iteration count = %d, obj. fcn = %f\n', i, obj_fcn(i)); end end obj_fcn(i+1:end) = []; %% Subfunctions function options = default_options(options) %DEFAULT_OPTIONS - Sets default values for the options struct if ~isfield(options, 'c') options.c = 2; end if ~isfield(options, 'm') options.m = 2; end if ~isfield(options, 'e') options.e = 1e-5; end if ~isfield(options, 'maxit') options.maxit = 100; end if ~isfield(options, 'display') options.display = true; end ```

相关推荐

最新推荐

recommend-type

census算法matlab程序

census算法matlab程序,双目立体匹配利用汉明氏距离计算匹配窗口,整体算法光敏性较好
recommend-type

牛顿迭代法的MATLAB程序.pdf

牛顿-拉夫逊法潮流计算 一、 基本原理 设有单变量非线性方程 f ( x) 0 (11 29) 求解此方程时,先给出解的近似值 (0) x ,它与真解的误差为 (0) x ,则满足方程 (11-29),即 (0) (0) f ( x x ) 0 ...
recommend-type

一维均值聚类matlab程序

k-means 算法接受输入量 k ;然后将n个数据对象划分为 k个聚类以便使得所获得的聚类满足:同一聚类中的对象相似 度较高;而不同聚类中的对象相似度较小。聚类相似度是利用各聚类中对象的均值所获得一个“中心对象”...
recommend-type

图像处理的matlab程序

常见的matlab对于图像处理的代码最常用的一些图像处理Matlab源代 码 #1:数字图像矩阵数据的显示及其傅立叶变换 #2:二维离散余弦变换的图像压缩 #3:采用灰度变换的方法增强图像的对比度 #4:直方图均匀化 #5...
recommend-type

Matlab寻峰程序.doc

matlab针对找峰值有自带函数,可以试试findpeaks。这样把那些随机的峰值滤除。max和min函数可以返回最大值,最小值的在矩阵中位置和值
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

list根据id查询pid 然后依次获取到所有的子节点数据

可以使用递归的方式来实现根据id查询pid并获取所有子节点数据。具体实现可以参考以下代码: ``` def get_children_nodes(nodes, parent_id): children = [] for node in nodes: if node['pid'] == parent_id: node['children'] = get_children_nodes(nodes, node['id']) children.append(node) return children # 测试数
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。