SVMshow
SVMshow
% http://www.peteryu.ca/tutorials/matlab/visualize_decision_boundaries % load RankData
% NumTrain =200; load RankData2 lambda = 20;
rho = 1;
c1 =10;
c2 =10;
epsilon = 0.2;
result=[]; ker = 'lin';
sigma = 1/50;
par = NonLinearDualSVORIM(X, y, c1, c2, epsilon, rho, ker, sigma); % set up the domain over which you want to visualize the decision
% boundary
xrange = [-5 5];
yrange = [-5 5];
% step size for how finely you want to visualize the decision boundary.
inc = 0.1;
% generate grid coordinates. this will be the basis of the decision
% boundary visualization.
[x1, x2] = meshgrid(xrange(1):inc:xrange(2), yrange(1):inc:yrange(2));
% size of the (x, y) image, which will also be the size of the
% decision boundary image that is used as the plot background.
image_size = size(x1) xy = [x1(:) x2(:)]; % make (x,y) pairs as a bunch of row vectors.
%xy = [reshape(x, image_size(1)*image_size(2),1) reshape(y, image_size(1)*image_size(2),1)] % loop through each class and calculate distance measure for each (x,y)
% from the class prototype. % calculate the city block distance between every (x,y) pair and
% the sample mean of the class.
% the sum is over the columns to produce a distance for each (x,y)
% pair.
d = [];
for k=1:max(y)
d(:,k) = decisionfun(xy, par, X,y,k,epsilon, ker,sigma)';
end
[~,idx] = min(abs(d),[],2) % reshape the idx (which contains the class label) into an image.
decisionmap = reshape(idx, image_size); figure; %show the image
imagesc(xrange,yrange,decisionmap);
hold on;
set(gca,'ydir','normal'); % colormap for the classes:
% class 1 = light red, 2 = light green, 3 = light blue
cmap = [1 0.8 0.8; 0.95 1 0.95; 0.9 0.9 1]
colormap(cmap); % label the axes.
xlabel('x1');
ylabel('x2'); imagesc(xrange,yrange,decisionmap); % plot the class training data. color = {'r.','go','b*','r.','go','b*'};
for i=1:max(y)
plot(X(y==i,1),X(y==i,2), color{i});
hold on
end
% include legend
legend('Class 1', 'Class 2', 'Class 3','Location','NorthOutside', ...
'Orientation', 'horizontal'); hold on;
set(gca,'ydir','normal');
SVMshow的更多相关文章
随机推荐
- 如何在PADS的封装中做非金属化孔
在设置封装的pads stacks的页面里,diameter,drill,plated三个项目(盘外径60mil,孔30mil) diameter:60,drill:30,plated:checked ...
- poj 1654 Area (多边形求面积)
链接:http://poj.org/problem?id=1654 Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: ...
- 利用EL表达式+JSTL在客户端取得数据 示例
<%@page import="cn.gbx.domain.Address"%> <%@page import="cn.gbx.domain.User& ...
- Flex打印功能FlexPrintJob调用
收藏下很详细的学习资料 http://wenku.baidu.com/view/b3d4f40702020740be1e9bf8.html import mx.printing.FlexPrintJo ...
- iOS - OC NSDate 时间
前言 NSDate @interface NSDate : NSObject <NSCopying, NSSecureCoding> NSDate 用来表示公历的 GMT 时间(格林威治时 ...
- iOS - Swift NSKeyedArchiver 数据归档
前言 public class NSKeyedArchiver : NSCoder public class NSKeyedUnarchiver : NSCoder 在 OC 语言中,归档是一个过程, ...
- iOS - UIControl
前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIControl : UIView @available(iOS 2.0, *) public class UIC ...
- java的重修之路
一.内存管理 java里的声明分引用与基本数据类型. 数组: java里new一个对象数组为 person[] A; A = new person[4]; person[0] = new pers ...
- JavaScript 点击图片放大功能
<!doctype html> <html> <head> <meta charset="utf-8" /> <title&g ...
- LCM兼容
1.project-1998-trunk-bootable-bootloader-lk-project: 复制zaw1998aa_platform.mk为zaw2000aa_platform.mk ...