资源简介
借助(非线性)孪生支持向量机,来解决二分类问题。
代码片段和文件信息
function [ ] = ker_contour(kerXv)
% 绘制contour
xaxis = 1;
yaxis = 2;
aspect = 0;
mag = 0.1;
input = zeros(1size(X2));% 一行两列,元素全为0
[mn]=size(v);
m=max(mn);
alpha=v(1:m-1);
bias=v(m);
d=floor(m/2);
xmin = min(X(:xaxis)); xmax = max(X(:xaxis));
ymin = min(X(:yaxis));ymax = max(X(:yaxis));
xa = (xmax - xmin); ya = (ymax - ymin);
if (~aspect)
if (0.75*abs(xa) < abs(ya))
offadd = 0.5*(ya*4/3 - xa);
xmin = xmin - offadd - mag*0.5*ya; xmax = xmax + offadd + mag*0.5*ya;
ymin = ymin - mag*0.5*ya; ymax = ymax + mag*0.5*ya;
else
offadd = 0.5*(xa*3/4 - ya);
xmin = xmin - mag*0.5*xa; xmax = xmax + mag*0.5*xa;
ymin = ymin - offadd - mag*0.5*xa; ymax = ymax + offadd + mag*0.5*xa;
end
else
xmin = xmin - mag*0.5*xa; xmax = xmax + mag*0.5*xa;
ymin = ymin - mag*0.5*ya;ymax = ymax + mag*0.5*ya;
end
set(gca‘XLim‘[xmin xmax]‘YLim‘[ymin ymax]);
X=X‘;
% 绘制函数值
[xy] = meshgrid(xmin:(xmax-xmin)/d:xmaxymin:(ymax-ymin)/d:ymax);
z = bias*ones(size(x));
for x1 = 1 : size(x1)
for y1 = 1 : size(x2)
input(xaxis) = x(x1y1); input(yaxis) = y(x1y1);
z(x1y1) = z(x1y1)+ker_Gaussian(inputXker)*alpha;
end
end
shading interp
% 绘制康托图的边界
contour(xyz[00]‘k‘); % 绘制值为零的等高线
hold on
contour(xyz[-1 -1]‘k:‘) % 绘制值为-1的等高线
contour(xyz[1 1]‘k:‘) % 绘制值为1的等高线
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5748 2012-09-03 18:32 ker_Main.m
文件 1535 2012-05-21 18:05 N_n.mat
文件 1548 2012-05-21 18:05 N_p.mat
文件 1253 2012-05-31 20:13 twinsvm_ker_train.m
文件 1597 2012-06-05 22:10 ker_contour.m
文件 234 2012-05-24 18:36 ker_Gaussian.m
----------- --------- ---------- ----- ----
11915 6
- 上一篇:TWSVM
- 下一篇:pcnn脉冲耦合神经网络的图像分割
评论
共有 条评论