主流监督式机器学习分类算法
主流监督式机器学习分类算法的性能比较
姓名:欧阳qq 学号:169559
摘要:机器学习是未来解决工程实践问题的一个重要思路。本文采比较了目前监督式学习中几种主流的分类算法(决策树、SVM、贝叶斯、KNN、随机森林、AdaBoost)对UCI波形数据集的分类效果。利用Python的Skilearn开源包搭建分类器,以UCI波形数据集中的前3000个样本作为训练集,后2000个作为测试集,分别在有噪声和无噪声条件下进行分类测试。测试结果表明SVM不管在无噪声还是在噪声条件下分类效果表现最佳,准确率分别为85.5%和85.8%。
1 引言
2 分类方法
2.1 监督式学习
监督式学习算法包括一个目标变量(因变量)和用来预测目标变量的预测变量(自变量)。通过这些变量我们可以搭建一个模型,从而对于一个已知的预测变量值,我们可以得到对应的目标变量值。重复训练这个模型,直到它能在训练数据集上达到预定的准确度。属于监督式学习的算法有:回归模型,决策树,随机森林,K邻近算法,逻辑回归等。
2.2 无监督式学习
与监督式学习不同的是,无监督学习中我们没有需要预测或估计的目标变量。无监督式学习是用来对总体对象进行分类的。它在根据某一指标将客户分类上有广泛应用。属于无监督式学习的算法有:关联规则,K-means聚类算法等。
2.3 强化学习
这个算法可以训练程序做出某一决定。程序在某一情况下尝试所有的可能行动,记录不同行动的结果并试着找出最好的一次尝试来做决定。属于这一类算法的有马尔可夫决策过程。
常见的机器学习算法
以下是最常用的机器学习算法,大部分数据问题都可以通过它们解决:
1).线性回归 (Linear Regression)
2).逻辑回归 (Logistic Regression)
3).决策树 (Decision Tree)
4).支持向量机(SVM)
5).朴素贝叶斯 (Naive Bayes)
6).K邻近算法(KNN)
7).K-均值算法(K-means)
8).随机森林 (Random Forest)
9).降低维度算法(Dimensionality Reduction Algorithms)
10).GradientBoost和Adaboost算法
关于算法的具体介绍,见:
http://scikit-learn.org/stable/supervised_learning.html#supervised-learning
2.4
分类器选择
由于本文采用的数据集为3个类别数据集,无噪声数据集和有噪声数据集中每个样本的维度分别为21和40,且为均为含标签数据样本。所以宜采用监督式多分类算法。上述分类算法中选择决策树、SVM、贝叶斯、KNN、随机森林、AdaBoost 进行分类效果比较。
3 结果
以下是分类算法的的正确率统计表和柱状图:
条件 分类器 |
无噪声 |
含噪声 |
决策树 |
0.758 |
0.755 |
SVM |
0.855 |
0.858 |
贝叶斯 |
0.821 |
0.795 |
KNN |
0.83 |
0.81 |
随机森林 |
0.805 |
0.814 |
AdaBoost |
0.845 |
0.845 |
其中贝叶斯和KNN分类算法,对有噪声的分类效果明显较无噪声差,说明这两类分类器的抗干扰能力较差。
4 总结与展望:
从实验结果可看出,针对UCI数据集,SVM算法是目前主流的分类算法中效果最好的,且具有强抗干扰能力,未来将通过其他数据集对目前主流的分类算法进行性能比较。
Reference:
Gales and Young (2007). “The Application of HiddenMarkov Models in Speech Recognition”, Foundations and Trends in SignalProcessing, 1 (3), 195–304: section 2.2.
Jurafsky and Martin (2008). Speech and LanguageProcessing(2nd ed.): sections 6.1–6.5; 9.2; 9.4. (Errata at
Rabiner and Juang (1989). “An introduction to hidden Markovmodels”, IEEE ASSP Magazine, 3 (1), 4–16.
Renals and Hain (2010). “SpeechRecognition”,Computational Linguistics and Natural Language Processing
Handbook, Clark, Fox and Lappin (eds.),Blackwells.
附录:源码代码
数据集下载链接:http://archive.ics.uci.edu/ml/datasets/Waveform+Database+Generator+%28Version+1%29
(1)决策树:
#Import Library
#Import other necessary libraries like pandas,numpy...
from sklearn import tree
#Assumed you have, X (predictor) and Y (target) fortraining data set and x_test(predictor) of test_dataset
X= waveform_noise[0:3000, :40]
y= waveform_noise[0:3000, 40:41]
x_test=waveform_noise[4000:5000, :40]
y_test= waveform_noise[4000:5000, 40:41]
# Create tree object
model = tree.DecisionTreeClassifier(criterion='gini')# for classification, here you can change the algorithm as gini or entropy(information gain) by default it is gini
# model = tree.DecisionTreeRegressor() for regression
# Train the model using the training sets and checkscore
model.fit(X, y)
model.score(X, y)
#Predict Output
predicted= model.predict(x_test)
res=0;
acc=0;
for i in range(0, 1000):
ifpredicted[i] == y_test[i]:
res=res+1
(2)SVM
acc=res/len(y_test)
#Import Library
from sklearn import svm
#Assumed you have, X (predictor) and Y (target) fortraining data set and x_test(predictor) of test_dataset
X= waveform_noise[0:3000, :40]
y= waveform_noise[0:3000, 40:41]
x_test=waveform_noise[4000:5000, :40]
y_test= waveform_noise[4000:5000, 40:41]
# Create SVM classification object
model = svm.SVC() # there is various option associatedwith it, this is simple for classification. You can refer link, for mo# redetail.
# Train the model using the training sets and checkscore
model.fit(X, y)
model.score(X, y)
#Predict Output
predicted= model.predict(x_test)
res=0;
acc=0;
for i in range(0, 1000):
ifpredicted[i] == y_test[i]:
res=res+1
acc=res/len(y_test)
(3)贝叶斯 分类
#Import Library
from sklearn.naive_bayes import GaussianNB
#Assumed you have, X (predictor) and Y (target) fortraining data set and x_test(predictor) of test_dataset
X= waveform_noise[0:3000, :40]
y= waveform_noise[0:3000, 40:41]
x_test=waveform_noise[4000:5000, :40]
y_test= waveform_noise[4000:5000, 40:41]
model = GaussianNB() # there is other distribution formultinomial classes like Bernoulli Naive Bayes, Refer link
# Train the model using the training sets and checkscore
model.fit(X, y)
#Predict Output
predicted= model.predict(x_test)
res=0;
acc=0;
for i in range(0, 1000):
ifpredicted[i] == y_test[i]:
res=res+1
acc=res/len(y_test)
(4)KNN
#Import Library
from sklearn.neighbors import KNeighborsClassifier
#Assumed you have, X (predictor) and Y (target) fortraining data set and x_test(predictor) of test_dataset
X= waveform_noise[0:3000, :40]
y= waveform_noise[0:3000, 40:41]
x_test=waveform_noise[4000:5000, :40]
y_test= waveform_noise[4000:5000, 40:41]
# Create KNeighbors classifier object model
model=KNeighborsClassifier(n_neighbors=6) # defaultvalue for n_neighbors is 5
# Train the model using the training sets and checkscore
model.fit(X, y)
#Predict Output
predicted= model.predict(x_test)
res=0;
acc=0;
for i in range(0, 1000):
ifpredicted[i] == y_test[i]:
res=res+1
acc=res/len(y_test)
(5)随机森林
#Import Library
from sklearn.ensemble import RandomForestClassifier
#Assumed you have, X (predictor) and Y (target) fortraining data set and x_test(predictor) of test_dataset
X= waveform_noise[0:3000, :40]
y= waveform_noise[0:3000, 40:41]
x_test=waveform_noise[4000:5000, :40]
y_test= waveform_noise[4000:5000, 40:41]
# Create Random Forest object
model= RandomForestClassifier()
# Train the model using the training sets and checkscore
model.fit(X, y)
#Predict Output
predicted= model.predict(x_test)
res=0;
acc=0;
for i in range(0, 1000):
ifpredicted[i] == y_test[i]:
res=res+1
acc=res/len(y_test)
(6)AdaBoost
#Import Library
from sklearn.ensemble import RandomForestClassifier
#Assumed you have, X (predictor) and Y (target) fortraining data set and x_test(predictor) of test_dataset
X= waveform_noise[0:3000, :40]
y= waveform_noise[0:3000, 40:41]
x_test=waveform_noise[4000:5000, :40]
y_test= waveform_noise[4000:5000, 40:41]
# Create Random Forest object
model= RandomForestClassifier()
# Train the model using the training sets and checkscore
model.fit(X, y)
#Predict Output
predicted= model.predict(x_test)
res=0;
acc=0;
for i in range(0, 1000):
ifpredicted[i] == y_test[i]:
res=res+1
acc=res/len(y_test)
主流监督式机器学习分类算法相关推荐
- 来!一起捋一捋机器学习分类算法
点击上方"AI遇见机器学习",选择"星标"公众号 重磅干货,第一时间送达 来自:算法与数学之美 可是,你能够如数家珍地说出所有常用的分类算法,以及他们的特征.优 ...
- 长文解读|Progress in Neurobiology:监督式机器学习在神经科学中的应用
<本文同步发布于"脑之说"微信公众号,欢迎搜索关注~~> 这些年来,人们投入了相当多的热情在机器学习(Machine Learning)领域中,毕竟它让电脑的表现在某 ...
- 机器学习分类算法(附图文详解)
说起分类算法,相信学过机器学习的同学都能侃上一二. 可是,你能够如数家珍地说出所有常用的分类算法,以及他们的特征.优缺点吗?比如说,你可以快速地回答下面的问题么: KNN算法的优缺点是什么? Naiv ...
- 15分钟带你入门sklearn与机器学习——分类算法篇
作者 | 何从庆 本文转载自AI算法之心(ID:AIHeartForYou) [导读]众所周知,Scikit-learn(以前称为scikits.learn)是一个用于Python编程语言的免费软件机 ...
- [转载] python机器学习第三章:使用scikit-learn实现机器学习分类算法
参考链接: 使用Scikit-Learn在Python中进行embedding/投票分类 训练机器学习算法所涉及的五个主要步骤可以概述如下: 1.特征的选择 2.确定性能评价标准 3.选择分类器及其优 ...
- 机器学习—分类算法的对比实验
文章目录 前言 一.分类算法实现 1.决策树 2.KNN 3.SVM 4.逻辑回归 5.朴素贝叶斯 6.随机森林 7.AdaBoost 8.GradientBoosting 二.分类算法的对比 前言 ...
- 大数据 机器学习 分类算法_13种用于数据科学的机器学习分类算法及其代码
大数据 机器学习 分类算法 The roundup of most common classification algorithms along with their python and r cod ...
- k近邻算法_机器学习分类算法之k近邻算法
本编文章将介绍机器学习入门算法-k近邻算法,将会用demo演示机器学习分类算法. 在先介绍算法时,先回顾分类和回归的区别.像文章分类识别也是这样处理的,如1代表体育,2代表科技,3代表娱乐属于分类问题 ...
- 机器学习分类算法常用评价指标
目录 1.准确率,召回率,精确率,F1-score,Fβ,ROC曲线,AUC值 2.宏平均(Macro-averaging)和微平均(Micro-averaging) 3.Python3 sklea ...
最新文章
- JAVA 线上故障排查完整套路,从 CPU、磁盘、内存、网络、GC 一条龙!
- /proc/meminfo详解 = /nmon analysis --MEM
- JUC并发编程九 并发架构--循环打印
- usb打印机linux识别不了怎么办,win10不识别usb打印机怎么回事_win10系统不识别usb打印机如何修复-系统城...
- 机房系统(三)——【充值 退卡 】
- Python----socket编程
- 在 eclipse 中设置每行的字数
- 进退之间,一位29岁已婚女性的自由之路
- PowerDesigner基础学习
- 软件度量都该度个啥?
- mysql 导入SQL脚本及乱码处理
- Lua解析器管理器(封装解析器通用函数(销毁解析器,垃圾清理),通过ab包加载lua文件的加载器)
- 加密狗 破解 复制 模拟 软件
- 每天10道Crypto Day3
- MAC 如何连接惠普打印机
- springboot校园疫情智慧防控微信小程序 毕业设计-附源码011133
- 【ES6新特性】set对象
- 机器学习入门09 - 特征组合 (Feature Crosses)
- 小程序源码:宝宝起名神器微信小程序源码下载-多玩法安装简单
- 帮助新员工快速形成战斗力,Filez在入职与培训场景应用
热门文章
- uni-app 22发布朋友圈页面
- 大连理工计算机原理综合设计,大连理工大学计算机原理实验综合实验设计报告.pdf...
- python 处理数据类型data_python处理multipart/form-data类型请求
- WPS如何批量设置行高磅数
- QWebEngineView无法输入中文
- oauth/authorize 返回403
- 如何手动控制iPhone相机(以及为什么要这么做)
- 财务rpa机器人 快速实现企业财务自动化
- 搭建TinyTiny rss服务
- 图数据结构之邻接链表Adjacency List(Python版)