#SVM的使用

(结合具体代码说明,代码参考邹博老师的代码)

1、使用numpy中的loadtxt读入数据文件

data:鸢尾花数据

5.1,3.5,1.4,0.2,Iris-setosa

4.9,3.0,1.4,0.2,Iris-setosa

4.7,3.2,1.3,0.2,Iris-setosa

4.6,3.1,1.5,0.2,Iris-setosa

5.0,3.6,1.4,0.2,Iris-setosa

读取:

:path路径

:dtype读取类型

:delimiter分隔符

:converters- A dictionary mapping column number to a function that will parse the column string into the desired value. E.g., if column 0 is a date string: ``converters = {0: datestr2num}``. Converters can also be used to provide a default value for missing data (but see also genfromtxt): ``converters = {3: lambda s: float(s.strip() or 0)}``.

:Default None.

*data

[[5.1, 3.5, 1.4, 0.2, 0. ], [4.9, 3. , 1.4, 0.2, 0. ], [4.7, 3.2, 1.3, 0.2, 0. ], [4.6, 3.1, 1.5, 0.2, 0. ],[5. , 3.6, 1.4, 0.2, 0. ]]

2、数据分训练测试集

*split用法

def split(ary,indices_or_sections,axis = 0):

'''

Split an array into multiple sub-arrays.

'''

Parameters-------------

ary : ndarray---Array to be divided into sub-arrays.

indices_or_sections---int or 1-D array  If `indices_or_sections` is an integer, N, the array will be divided into N equal arrays along `axis`. If such a split is not possible,

an error is raised.

If `indices_or_sections` is a 1-D array of sorted integers, the entries indicate where along `axis` the array is split. For example,``[2, 3]`` would, for ``axis=0``, result in

ary[:2]

ary[2:3]

ary[3:]

If an index exceeds the dimension of the array along `axis`,an empty sub-array is returned correspondingly.

axis:int,optional---The axis along which to split,default is 0.

0按列分割,1按行分割

Return:sub-array:list of ndarrays

A list of sub-arrays

example:

3、训练SVM

kernel='linear'时,为线性核,C越大分类效果越好,但有可能出现过拟合;

kernel='rbf'时,为高斯核,gamma越小,分类界面越连续;gamma越大,分类界面越分散,分类效果越好(训练集),但是有可能会过拟合。

decision_function_shape='ovr'时(one v rest),即一个类别与其他类别进行划分;

decision_function_shape='ovo'时(one v one),即将类别两两之间进行划分,用二分类的方法模拟多分类的结果。

*准确率计算方式

机器学习--------SVM的更多相关文章

  1. 文本分类学习 (五) 机器学习SVM的前奏-特征提取(卡方检验续集)

    前言: 上一篇比较详细的介绍了卡方检验和卡方分布.这篇我们就实际操刀,找到一些训练集,正所谓纸上得来终觉浅,绝知此事要躬行.然而我在躬行的时候,发现了卡方检验对于文本分类来说应该把公式再变形一般,那样 ...

  2. 机器学习——SVM详解(标准形式,对偶形式,Kernel及Soft Margin)

    (写在前面:机器学习入行快2年了,多多少少用过一些算法,但由于敲公式太过浪费时间,所以一直搁置了开一个机器学习系列的博客.但是现在毕竟是电子化的时代,也不可能每时每刻都带着自己的记事本.如果可以掏出手 ...

  3. 程序员训练机器学习 SVM算法分享

    http://www.csdn.net/article/2012-12-28/2813275-Support-Vector-Machine 摘要:支持向量机(SVM)已经成为一种非常受欢迎的算法.本文 ...

  4. [机器学习]SVM原理

    SVM是机器学习中神一般的存在,虽然自深度学习以来有被拉下神坛的趋势,但不得不说SVM在这个领域有着举足轻重的地位.本文从Hard SVM 到 Dual Hard SVM再引进Kernel Trick ...

  5. [机器学习] SVM——Hinge与Kernel

    Support Vector Machine [学习.内化]--讲出来才是真的听懂了,分享在这里也给后面的小伙伴点帮助. learn from: https://www.youtube.com/wat ...

  6. 小刘的机器学习---SVM

    前言: 这是一篇记录小刘学习机器学习过程的随笔. 正文: 支持向量机(SVM)是一组用于分类, 回归和异常值检测的监督学习方法. 在分类问题中,SVM就是要找到一个同时离各个类别尽可能远的决策边界即最 ...

  7. 机器学习—SVM

    一.原理部分: 依然是图片~ 二.sklearn实现: import pandas as pd import numpy as np import matplotlib.pyplot as plt i ...

  8. 机器学习——SVM讲解

    支持向量机(Support Vector Machine) SVM是一类按监督学习方式对数据进行二元分类的广义线性分类器,决策边界是对学习样本求解的最大边距超平面.只需要知道,SVM是一个有监督的分类 ...

  9. 机器学习——SVM

    整理自: https://blog.csdn.net/woaidapaopao/article/details/77806273?locationnum=9&fps=1 带核的SVM为什么能分 ...

随机推荐

  1. IDEA中 GIT与SVN版本控制插件的切换

    https://www.cnblogs.com/yccmelody/p/7794220.html

  2. 软件测试-培训的套路-log3

    最新的套路!我是没了解过--下图中描述-log3 Dotest-董浩 但是我知道不管什么没有白吃的午餐而且还会给钱…如果真的有,请醒醒! 当然话又回来,套路不套路,关键看你是否需要:你如果需要我觉得是 ...

  3. 关于t,f test

    我也是佛了 这么基础的概念其实每次都会搞混一些 首先我们针对variance求一个estimator s 然后对于任意置信区间 (sample mean +- 你所需的置信百分比的t * SE(SE就 ...

  4. 强大的Resharp插件(转)

    使用VS有段时间了,一直深深的折服于其强大的功能.之前一直听说有Resharp这个工具,小猪一直也没有太在意.直到今天…… 下载安装: http://www.jetbrains.com/resharp ...

  5. 让你的Spring Boot应用快速运行在Docker上面

    前置条件: 1. 服务器(我这边是CentOS7)上已经安装了Docker(安装步骤很简单,可以参考我上一篇博客) 2.服务器上已经安装了Java和Maven 在满足以上条件后,我们就可以开始了: 1 ...

  6. ubuntu系统的teamviewer的安装及使用

    参考链接: 安装: https://blog.csdn.net/weixin_34613450/article/details/80541799 使用: https://jingyan.baidu.c ...

  7. mui slider禁止滑动

    网上方法: mui('.mui-slider').slider().setStopped(true); 实际使用 mui('.mui-slider').slider().stopped = true; ...

  8. spring-cloud-feign负载均衡组件

    Feign简介: Feign是一个声明式的Web服务客户端,使用Feign可使得Web服务客户端的写入更加方便.它具有可插拔注释支持,包括Feign注解和JAX-RS注解.Feign还支持可插拔编码器 ...

  9. Autofac使用

    创建用例类 创建接口 namespace MyIBLL { public interface IUserBLL { void AddUser(string name, string pass); } ...

  10. C. mathematican 的二进制

    题解: subtask1:爆搜,没状压dp的分 subtask2,3:统计有几个操作就好了,分治ntt优化 subtask4,5: 发现和操作顺序无关,然后我们考虑用分治ntt优化 每个的贡献是$n+ ...