资源简介
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语言的垃圾邮件分类
- 下一篇:激光通过大气湍流的影响
相关资源
- 非线性SVM算法-matlab实现
- SVM工具箱(matlab中运行)
- matlab版的车牌识别程序
- SVM的回归预测分析——上证指数开盘
- 印章识别matlab代码
- ibsvm-3.21
- 果蝇参数寻优FOA-LSSVM的完整程序
- 利用WOA算法优化libsvm中SVDD算法的参数
- svm支持向量机与nbc朴素贝叶斯算法比
- SVM的matlab代码
- 混凝土抗压强度预测_SVM_Matlab_归一_
- 基于SVM的回归预测分析
- libsvm数据格式转换程序
- 基于SVM的matlab车牌识别
- hog+svm图像二分类
- 基于PCA和SVM的人脸识别.zip
- 《MATLAB 神经网络30个案例分析》所有
- SVM分类与回归的matlab代码
- 基于LABVIEW和MATLAB混合编程障碍物识别
- svm 支持向量机 回归 预测
- libsvm - 支持多类别分类的svm工具箱m
- K均值聚类算法,图像处理,GUI,mat
- 经典SVM算法的MATLAB程序
- 蚁群优化SVM系数
- SVM-KM Matlab源程序
- 模式识别课程作业 基于svm的人脸识别
- 谱聚类算法对数据点进行分类
- MATLAB的SVM安装包drtoolbox_libsvm-3.17
- SVM算法对MNIST数据集分类
- 遗传算法优化支持向量机GASVM
评论
共有 条评论