资源简介
matlab编写的利用支持向量积完成聚类功能的小程序
代码片段和文件信息
% > -------------------------
% > Support Vector Clustring
%> 滕晓云2008.10
% > -------------------------
% > A non-parametric clustring algorithm based on support vector
% > approach.
% >
% > Reference:
% > A.Ben-HurD.HornH.T.Siegelmann and V.Vapnik.
% > Support Vector Clustring.
% >
% > Parameters:
% >
% > example - integer number coding the wanted Sample set.
% > C - Defines the fraction of points which are allowed
% > to become outliers.
% > (p = 1/CN where N is the the total sampels number).
% > q...each q value is a different width of the gaussian kernel.
clc;
clear;
%> 自己设置的参数
example_set=5;
C=1;
q=1;
% tem = rand(110);
%
% Samples = [2+tem2+tem12+tem12+tem;2+tem12+tem2+tem12+tem];
%
% % > Plot
%
%
% nof_samples = size(Samples2);
% classification = zeros(nof_samples1);
% Samples from a given example set:
tem = rand(15);
Samples = [2+tem2+tem2+tem2+tem6+tem6+tem6+tem6+tem10+tem10+tem10+tem10+tem14+tem14+tem14+tem14+tem;2+tem6+tem10+tem14+tem2+tem6+tem10+tem14+tem2+tem6+tem10+tem14+tem2+tem6+tem10+tem14+tem];
nof_samples = size(Samples2);
[attrN] = size(Samples);
% Preforms Support Vector Clustering
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
% > Calculates the Kernel Matrix here use Gaussian kernel
K = zeros(N);
for i = 1:N
for j = 1:N
% > Calculate the Gaussian Kernel for each data points‘ pair.
K(ij) = exp(-q * (Samples(:i)-Samples(:j))‘ * (Samples(:i)-Samples(:j)));
end
end
% > Finds the Lagrangian multipliers for the given constrains%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = ones(1N);
b = 1;
low_bound = zeros(N1);
up_bound = ones(N1) * C;
beta = quadprog(2*K -diag(K)[][] A b low_bound up_bound);
% > Finds the support vectors and outliers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BSV = zeros(attrN);
SV = zeros(attrN);
nof_BSV = 0;
nof_SV = 0;
for i = 1:N
% > BSV - outliers ( only when beta equlas C - the upper bound)
if beta(i) == C;
nof_BSV = nof_BSV + 1;
BSV(: nof_BSV) = Samples(:i);
% > SV - beta is between 0 and C
elseif beta(i) > 1e-6
% > epsilon
nof_SV = nof_SV + 1;
SV(:nof_SV) = Samples(:i);
end
end
% > Corrects the matrics sizes
BSV = BSV(: 1:nof_BSV);
SV = SV(:1:nof_SV);
% > Calcultes the radius of the sphere and the quadratic part of the distance equation from the sphere‘s center.
distance = zeros(nof_SV1);
quad = 0;
for i = 1:N
for j = 1:N
quad = quad + beta(i) * beta(j) * K(ij);
end
end
for i = 1:nof_SV
k = zeros(N1);
for j = 1:N
k(j) = exp(-q * (Samples(:j)-SV(:i))‘ * (Samples(:j)-SV(:i)));
end
kdiag = 1; %%%%%其实都是exp(-q * (SV(:i)-SV(:i))‘ * (SV(:i)-SV(:i)));
distance(i) = kdiag - 2*beta‘*k + quad;
end
R = max(distance);
% Finds the clusters assignments%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
adjacent =
- 上一篇:基于matlab语言的垃圾邮件分类
- 下一篇:激光通过大气湍流的影响
相关资源
- 支持向量机libsvm3.22工具箱编译完成
- matlab编程实现支持向量机的多分类
- svm多分类 matlab程序
- 模糊k均值聚类算法matlab实现
- 用MATLAB编写的svm源程序,可以实现支
- SVM+SMO实现代码
- libsvm-3.23支持向量机类库,matlab版,可
- matlab层次聚类算法
- SVM用于故障诊断的实现
- 支持向量机回归预测代码
- libsvm 程序集数据集
- pq pca svm 使用小波能量差提取信号
- awayline SVM ARMA 基于风速预测的风力发
- TWSVM(2) 借助(非线性)孪生支持向
- TWSVM
- SVM上证开盘指数预测
- Voice-recognition-using-mfcc-and-svm-Bitsforge
- svmplot 支持向量机的画图程序。能很好
- svm分类器的汉语声调识别
- SVM function available 可实现SVM函数曲线拟
- HOG 根据Dalal提出的HOG特征算法编写
- CROlib.mat 1.0.2
- 支持向量机SVM机器学习方法
- 基于半监督的svm的图像分类
- 计算聚类算法评价指标之一
- SVM的手写数字识别(Handwriting recogni
- 可以用的经典密度聚类算法(DBSCAN)
- PSO SVM SVM用于分类时的参数优化
- matlab编写的蛙跳聚类算法(SFLA)
- k-medoids聚类算法matlab源代码
评论
共有 条评论