24小时热门版块排行榜    

查看: 2677  |  回复: 0

samggyy

金虫 (小有名气)

[求助] Matlab如何使用绘图画出3D SVM的decision boundary?

RT,Matlab中可以画出二维的SVM的decision boundary,代码如下,

    load fisheriris;
   
    features = meas(1:100,;
    featureSelcted = features(1:100,1:2);
    groundTruthGroup = species(1:100);
   
   
    svmStruct = svmtrain(featureSelcted, groundTruthGroup, ...
        'Kernel_Function', 'rbf', 'boxconstraint', Inf, 'showplot', true, 'Method', 'QP');
    svmClassified = svmclassify(svmStruct,featureSelcted,'showplot',true);

如果使用三维的特征,即把代码改为featureSelcted = features(1:100,1:3); 无法出一个三维的超平面了。思路可能是:

cubeXMin = min(featureSelcted(:,1))-0.5;
cubeYMin = min(featureSelcted(:,2))-0.5;
cubeZMin = min(featureSelcted(:,3))-0.5;

cubeXMax = max(featureSelcted(:,1))+0.5;
cubeYMax = max(featureSelcted(:,2))+0.5;
cubeZMax = max(featureSelcted(:,3))+0.5;

cubeMesh = meshgrid(cubeXMin:0.5:cubeXMax,cubeYMin:0.5:cubeYMax,cubeZMin:0.5:cubeZMax);

sv = svmStruct.SupportVectors;
alphaHat = svmStruct.Alpha;
bias = svmStruct.Bias;
kfun = svmStruct.KernelFunction;
kfunargs = svmStruct.KernelFunctionArgs;

f = (feval(kfun,sv,cubeMesh,kfunargs{:})'*alphaHat() + bias;

decisionBoundary = sign(f);
decisionBoundaryInd = find(decisionBoundary==0);

figure,
scatter3(featureSelcted(:,1),featureSelcted(:,2),featureSelcted(:,3));
surf(decisionBoundaryInd);

但是不知道怎么完成,请教有没有人知道怎么做的。谢谢!


有一个用R写的例子:
http://stackoverflow.com/questio ... -svm-fit-hyperplane

还有两篇论文中也有做到:
http://www.sciencedirect.com/sci ... i/S0304394010006324
http://www.mathematica-journal.c ... ation-with-kernels/
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 samggyy 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 288求调剂,一志愿华南理工大学071005 +4 ioodiiij 2026-03-17 4/200 2026-03-18 12:36 by Linda Hu
[考研] 0854,计算机类招收调剂 +3 胡辣汤放糖 2026-03-15 6/300 2026-03-18 12:09 by 上岸上岸……..
[考研] 0703化学336分求调剂 +6 zbzihdhd 2026-03-15 7/350 2026-03-18 09:53 by zhukairuo
[考博] 26博士申请 +3 1042136743 2026-03-17 3/150 2026-03-17 23:30 by 轻松不少随
[基金申请] 被我言中:新模板不强调格式了,假专家开始管格式了 +4 beefly 2026-03-14 4/200 2026-03-17 22:04 by 黄鸟于飞Chao
[考研] 材料专硕326求调剂 +6 墨煜姒莘 2026-03-15 7/350 2026-03-17 17:10 by ruiyingmiao
[考研] 290求调剂 +6 孔志浩 2026-03-12 11/550 2026-03-17 14:41 by 周舟舟77
[考研] 一志愿南京大学,080500材料科学与工程,调剂 +4 Jy? 2026-03-16 4/200 2026-03-17 11:02 by gaoqiong
[考研] 302求调剂 +4 小贾同学123 2026-03-15 8/400 2026-03-17 10:33 by 小贾同学123
[考研] 0854控制工程 359求调剂 可跨专业 +3 626776879 2026-03-14 9/450 2026-03-16 17:42 by 626776879
[考研] 070300化学学硕求调剂 +6 太想进步了0608 2026-03-16 6/300 2026-03-16 16:13 by kykm678
[考研] 085600调剂 +5 漾漾123sun 2026-03-12 6/300 2026-03-16 15:58 by 漾漾123sun
[考研] 22408总分284求调剂 +3 InAspic 2026-03-13 3/150 2026-03-15 11:10 by zhq0425
[考研] 本科南京大学一志愿川大药学327 +3 麦田耕者 2026-03-14 3/150 2026-03-14 20:04 by 外星文明
[考研] 中科大材料专硕319求调剂 +3 孟鑫材料 2026-03-13 3/150 2026-03-14 18:10 by houyaoxu
[考研] 复试调剂 +3 呼呼?~+123456 2026-03-14 3/150 2026-03-14 16:53 by WTUChen
[考研] 材料与化工(0856)304求B区调剂 +6 邱gl 2026-03-12 7/350 2026-03-13 23:24 by 邱gl
[考研] 求材料调剂 085600英一数二总分302 前三科235 精通机器学习 一志愿哈工大 +4 林yaxin 2026-03-12 4/200 2026-03-13 22:04 by 星空星月
[考研] [0860]321分求调剂,ab区皆可 +4 宝贵热 2026-03-13 4/200 2026-03-13 22:01 by 星空星月
[考研] 308求调剂 +3 是Lupa啊 2026-03-12 3/150 2026-03-13 14:30 by 求调剂zz
信息提示
请填处理意见