% X: Data matrix (each row represents a data point)
% k: Number of clusters
% U_pre: Predefined membership value matrix (each column represents a data point and each row represents a cluster centers)
% lambda: The balance factor between the supervised and unsupervised parts in the loss function
% max_iter: Maximum number of iterations
% tol: Tolerance for convergence
addpath('private');
function [cluster_centers, U, obj_func_history] = ssfc(X, k, U_pre, options = [2.0, 100, 1e-5, 1])
## If ssfc was called with an incorrect number of arguments or
## if the arguments do not have the correct type, print an error
## and halt.
if ((nargin != 3) && (nargin != 4))
error ("ssfc requires 3 or 4 arguments\n");
elseif (!is_real_matrix (X))
error ("ssfc's first argument must be matrix of real numbers\n");
elseif (!(is_int (k) && (k > 1)))
error ("ssfc's second argument must be an integer greater than 1\n");
elseif (!(is_real_matrix(U_pre) && all(sum(matrix) <= 1) && size(U_pre, 1) == k))
error ("ssfc's third argument must be a matrix of real numbers where the sum of each column is <= 1 and the number of rows is k (the number of clusters\n");
elseif (!(isreal (options) && isvector (options)))
error ("ssfc's fourth argument must be a vector of real numbers\n");
endif
default_options = [2.0, 100, 1e-5, 1];
for i = 1:4
if ((length(options) < i) || isna(options(i)) || isnan(options(i)))
options(i) = default_options(i);
endif
endfor
lambda = options(1);
max_iterations = options(2);
epsilon = options(3);
display_intermediate_results = options(4);
## Call a private function to compute the output_precision
[cluster_centers, U, obj_func_history] = ssfc_private(X, k, U_pre, lambda, max_iterations, epsilon, display_intermediate_results);
endfunction
function [V, U, obj_func_history] = ssfc_private(X, k, U_pre, lambda, max_iterations, epsilon, display_intermediate_results)
# Initialize the prototypes and the calculation
V = init_cluster_prototypes(X, k);
obj_func_history = zeros(max_iterations);
convergence_criterion = epsilon + 1;
iteration = 0;
# Calculate a few numbers here to reduce redundant computation
k = rows(V);
n = rows(X);
sqr_dist = square_distance_matrix(X, V);
## Loop until the objective function is within tolerance or the
## maximum number of iterations has been reached
while (convergence_criterion > epsilon && ++iteration <= max_iterations)
V_previous = V;
U = update_cluster_membership_ssfc(V, X, lambda, k, n, sqr_dist, U_pre);
delta_U_2 = (U - U_pre) .^ 2
V = update_cluster_prototypes_ssfc(delta_U_2, X, k, U);
sqr_dist = square_distance_matrix(X, V);
obj_func_history(iteration) = compute_cluster_obj_fcn_ssfc(delta_U_2, sqr_dist, U, lambda);
if (display_intermediate_results)
printf("Iteration count = %d, Objective fcn = %8.6f\n", iteration, obj_func_history(iteration));
endif
convergence_criterion = compute_cluster_convergence(V, V_previous);
endwhile
## Remove extraneous entries from the tail of the objective function history
if (convergence_criterion <= epsilon)
obj_func_history = obj_func_history(1:iteration);
endif
endfunction
没有合适的资源?快使用搜索试试~ 我知道了~
半监督模糊聚类matlab代码.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共14个文件
m:14个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 165 浏览量
2024-05-21
21:36:03
上传
评论
收藏 19KB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 14 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/864ffdc5a26342a6add0026479aef1e5_matlab_dingdang.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
matlab科研助手
- 粉丝: 2w+
- 资源: 2416
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)