您现在的位置:首页 >> ★免费资源 >> 源码下载 >> 内容

MATLAB代做-python代做-FPGA代做- SVM

时间:2019-6-1 3:42:21 点击:

  核心提示:MATLAB代做-python代做-FPGA代做- SVM...
load wine_SVM; data = [wine(:,1), wine(:,2)]; groups = ismember(wine_labels,1); % not familiar with ismember? help... help... [train, test] = crossvalind('holdOut',groups); % not familiar with crossvalind? help... help... %train and test here are logical format train_wine = data(train,:); train_wine_labels = groups(train,:); train_wine_labels = double( train_wine_labels ); %in the usage of libsvm, the label vector and instance matrix must be %double. So we have to transfer the format of labels in this case. test_wine = data(test,:); test_wine_labels = groups(test,:); test_wine_labels = double( test_wine_labels ); train_wine = normalization(train_wine',1); test_wine = normalization(test_wine',1); train_wine = train_wine'; test_wine = test_wine'; % bestcv = 0; % for log2c = -5:5, % for log2g = -5:5, % cmd = ['-v 5 -c ', num2str(2^log2c), ' -g ', num2str(2^log2g)]; % cv = svmtrain(train_wine_labels, train_wine, cmd); % if (cv >= bestcv), % bestcv = cv; bestc = 2^log2c; bestg = 2^log2g; % end % end % end % fprintf('%g %g %g (best c=%g, g=%g, rate=%g)\n', log2c, log2g, cv, bestc, bestg, bestcv); % cmd = ['-c ', num2str(bestc), ' -g ', num2str(bestg)]; % model = svmtrain(train_wine_labels, train_wine, cmd); model = svmtrain(train_wine_labels, train_wine, '-c 1 -g 0.07'); [predict_label, accuracy] = svmpredict(test_wine_labels, test_wine, model); %plot visualization for train_wine % w = model.SVs' * model.sv_coef; % b = -model.rho; [mm,mn] = size(model.SVs); figure; hold on; [m,n] = size(train_wine); for run = 1:m if train_wine_labels(run) == 1 h1 = plot( train_wine(run,1),train_wine(run,2),'r+' ); else h2 = plot( train_wine(run,1),train_wine(run,2),'g*' ); end for i = 1:mm if model.SVs(i,1)==train_wine(run,1) && model.SVs(i,2)==train_wine(run,2) h3 = plot( train_wine(run,1),train_wine(run,2),'o' ); end end end legend([h1,h2,h3],'1','0','Support Vectors'); hold off; 联系:highspeedlogic QQ :1224848052 微信:HuangL1121 邮箱:1224848052@qq.com 网站:http://www.mat7lab.com/ 网站:http://www.hslogic.com/ 微信扫一扫:

Tags:SVM 
作者:SVM 来源:SVM
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做(www.hslogic.com) © 2019 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment