findsvandbsv.m

来自「这个是支持向量聚类机用matlab编译的主程序和部分子程序」· M 代码 · 共 55 行

M
55
字号
%=====================================================================
%%	FindSVandBSV
%	------------
%%	Parameters:   %		Samples - The matrix hold the data points.
%		beta    - The vector of the Lagrangian multipliers. 
%       C       - Defines the fraction of points which are allowed%                 to become outliers.%                 (p = 1/CN where N is the the total sampels number).%                   %	Return Value:%		SV      - This matrix holds the Support vectors.
%       nof_SV  - The number of Support vectors produced.%		BSV     - This matrix holds the outliers.
%       nof_BSV - The number of outliers produced.%       %%   Finds the support vectors and outliers (Bounded Support Vectors)
%	of a cluster.
%
%=====================================================================function [SV,nof_SV,BSV,nof_BSV] = FindSVandBSV(Samples,beta,C)[attr,N] = size(Samples);% initializationBSV = zeros(attr,N);SV = zeros(attr,N);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 sizesBSV = BSV(:, 1:nof_BSV);SV = SV(:,1:nof_SV);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?