24小时热门版块排行榜    

Znn3bq.jpeg
查看: 2683  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料334求调剂 +21 Eecho# 2026-04-03 21/1050 2026-04-08 22:55 by 猪会飞
[考研] 324求调剂 +17 想上学求调 2026-04-03 17/850 2026-04-08 20:04 by 我减肥1
[考研] 277求调剂 +4 考研调剂lxh 2026-04-06 6/300 2026-04-08 10:40 by 逆水乘风
[考研] 288环境专硕,求调材料方向 +35 lllllos 2026-04-04 39/1950 2026-04-07 23:24 by 一只好果子?
[考研] 305求调剂 +3 77Qi 2026-04-07 3/150 2026-04-07 23:18 by jp9609
[考研] 334分机械专硕求调剂 +3 蛋花紫菜汤 2026-04-03 3/150 2026-04-07 14:49 by 逍遥cocoa
[考研] 316求调剂 +7 yyx想调剂 2026-04-05 7/350 2026-04-07 14:31 by shdgaomin
[考研] 材料工程302分求调剂 +13 zyx上岸! 2026-04-04 13/650 2026-04-07 11:14 by 诗与自由
[论文投稿] Decision: Revise for Editor还会送审吗 100+3 CccccccccFD 2026-04-04 5/250 2026-04-07 10:58 by 北京莱茵润色
[考研] 生物与医药求调剂 +7 heguanhua 2026-04-05 8/400 2026-04-06 18:41 by macy2011
[考研] 材料调剂 +5 小刘同学吖吖 2026-04-06 5/250 2026-04-06 18:34 by sherry_1901
[考研] 0857大类环境工程B区求调剂 +3 龚禹铭 2026-04-05 3/150 2026-04-06 10:22 by 蓝云思雨
[考研] 生物与医药调剂 +4 十七sa 2026-04-05 4/200 2026-04-05 20:05 by lys0704
[考研] 工科08-机械专硕-求调剂 +3 雷欧飞踢 2026-04-02 3/150 2026-04-05 18:49 by 蓝云思雨
[考研] 能动调剂326专硕 +4 wan112233 2026-04-04 4/200 2026-04-04 22:47 by yu221
[考研] 一志愿0817化学工程与技术,求调剂 +24 我不是只因 2026-04-02 28/1400 2026-04-04 15:15 by dongzh2009
[考研] 求调剂 +4 压力??大 2026-04-03 4/200 2026-04-03 21:36 by 啵啵啵0119
[考研] 0705理学294求调剂 +3 成果成果cg5 2026-04-03 3/150 2026-04-03 14:04 by simons1972
[考研] 数一英一285求调剂 +7 AZMK 2026-04-03 9/450 2026-04-03 13:03 by ms629
[考研] 279求调剂 +6 qazplm0852 2026-04-02 6/300 2026-04-03 10:03 by 蓝云思雨
信息提示
请填处理意见