matlab SVM新函数例子

matlab 介绍SVM新函数时有这样一个例子:Load Fisher's iris data set. Remove the sepal lengths and widths, and all observed setosa irises.
程序:
 
load fisheriris %我看了一下,fisheriris是matlab系统自带的fisheriris.csv文件,里面有5列数据,151行,
第1行是项目名称:SepalLength,SepalWidth,PetalLength,PetalWidth,Species,第2行以后是5.1,3.5,1.4,0.2,setosa;。。。。等等这样的数据。
load的意思是读入fisheriris这个文件到系统里。
inds = ~strcmp(species,'setosa');%  返回值inds是一个和species有相同size的logical array,ind的元素是1或0。

    把species中的每个元素和s做比较,如果一致,则对应位置的元素为1,否则,为0。

数据文件中species列下面是'setosa'的共有50行。再取反,应该就是一列向量,前50项是0,后面100项是1。



X = meas(inds,3:4);

y = species(inds);%处理好X,y

SVMModel = fitcsvm(X,y)%生成一个分类器
SVMModel = 

  ClassificationSVM
             ResponseName: 'Y'
    CategoricalPredictors: []
               ClassNames: {'versicolor'  'virginica'}
           ScoreTransform: 'none'
          NumObservations: 100
                    Alpha: [24×1 double]
                     Bias: -14.4149
         KernelParameters: [1×1 struct]
           BoxConstraints: [100×1 double]
          ConvergenceInfo: [1×1 struct]
          IsSupportVector: [100×1 logical]
                   Solver: 'SMO'

   
   
用类似classOrder = SVMModel.ClassNames 这样的命令可以看分类器的属性
classOrder =

  2×1 cell array

    'versicolor'
    'virginica'

The first class ('versicolor') is the negative class, and the second ('virginica') is the positive class. You can change the class order during
 training by using the 'ClassNames' name-value pair argument.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值