如何做出一个更好的Machine Learning预测模型【转载】
链接:https://zhuanlan.zhihu.com/p/25013834
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
初衷
这篇文章主要从工程角度来总结在实际运用机器学习进行预测时,我们可以用哪些tips来提高最终的预测效果,主要分为Data Cleaning,Features Engineering, Models Training三个部分,可以帮助大家在实际的工作中取得更好的预测效果或是在kaggle的比赛里取得更好的成绩和排位。
Data Cleaning
1. 移除多余的duplicate features(相同或极为相似的features)
2. 移除constant features(只有一个value的feature)
#R里面可以使用unique()函数判断,如果返回值为1,则意味着为constant features
3. 移除方差过小的features(方差过小意味着提供信息很有限)
#R中可以使用caret包里的nearZeroVar()函数
#Python里可以使用sklearn包里的VarianceThreshold()函数
4. 缺失值处理:将missing value重新编为一类。
#比如原本-1代表negative,1代表positive,那么missing value就可以全部标记为0
#对于多分类的features做法也类似二分类的做法
#对于numeric values,可以用很大或很小的值代表missing value比如-99999.
5. 填补缺失值
可以用mean,median或者most frequent value进行填补
#R用Hmisc包中的impute()函数
#Python用sklearn中的Imputer()函数
6. 高级的缺失值填补方法
利用其他column的features来填补这个column的缺失值(比如做回归)
#R里面可以用mice包,有很多方法可供选择
注意:不是任何时候填补缺失值都会对最后的模型预测效果带来正的效果,必须进行一定的检验。
Features Engineering
1. Data Transformation
a. Scaling and Standardization
#标准化,R用scale(), Python用StandardScaler()
#注意:Tree based模型无需做标准化
b. Responses Transformation
#当responses展现skewed distribution时候用,使得residual接近normal distribution
#可以用log(x),log(x+1),sqrt(x)等
2. Features Encoding
#把categorical features变成numeric feature
#Label encoding:Python 用 LabelEncoder()和OneHotEncoder(), R用dummyVars()
3. Features Extraction
#主要是针对文本分析
4. Features Selection
a. 方法很多:
注:其中randomForest以及xgboost里的方法可以判断features的Importance
b. 此外,PCA等方法可以生成指定数量的新features(映射)
c. 擅对features进行visualization或correlation的分析。
Models Trainning
1. Mostly Used ML Models
尝试多一些的模型,比如下面这些:
2. 利用Grid Search进行hyper参数的选择
3. 利用Cross-Validation衡量训练效果
4. Ensemble Learning Methods
必读下面这个文档:Kaggle Ensembling Guide
文章原地址:https://zhuanlan.zhihu.com/p/25013834
如何做出一个更好的Machine Learning预测模型【转载】的更多相关文章
- Domain adaptation:连接机器学习(Machine Learning)与迁移学习(Transfer Learning)
domain adaptation(域适配)是一个连接机器学习(machine learning)与迁移学习(transfer learning)的新领域.这一问题的提出在于从原始问题(对应一个 so ...
- 【机器学习Machine Learning】资料大全
昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...
- Machine Learning Algorithms Study Notes(2)--Supervised Learning
Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 22 ...
- Stanford机器学习笔记-7. Machine Learning System Design
7 Machine Learning System Design Content 7 Machine Learning System Design 7.1 Prioritizing What to W ...
- Machine Learning - 第7周(Support Vector Machines)
SVMs are considered by many to be the most powerful 'black box' learning algorithm, and by posing构建 ...
- Machine Learning - 第6周(Advice for Applying Machine Learning、Machine Learning System Design)
In Week 6, you will be learning about systematically improving your learning algorithm. The videos f ...
- Machine Learning - 第3周(Logistic Regression、Regularization)
Logistic regression is a method for classifying data into discrete outcomes. For example, we might u ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料【转】
转自:机器学习(Machine Learning)&深度学习(Deep Learning)资料 <Brief History of Machine Learning> 介绍:这是一 ...
- Coursera《machine learning》--(8)神经网络表述
本笔记为Coursera在线课程<Machine Learning>中的神经网络章节的笔记. 八.神经网络:表述(Neural Networks: Representation) 本节主要 ...
随机推荐
- npm无反应的问题&npm常用命令
RT: windows安装完nodejs后做了相关环境变量配置后,cmd输入npm命令无反应,就光标一直闪,百度了半天终于找到解决办法 解决方法:C:\Users\Administrator(或你的账 ...
- uva11827 处理下输入
/*0.012s*/ #include<cstdio> #include<algorithm> using namespace std; ], n; int gcd(int a ...
- 封装input 逐渐,且input插件必须带有默认值。
封装input 逐渐,且input插件必须带有默认值. 组件: <template> <div class="input-show"> <span c ...
- 常用的web服务器软件整理
(1)ApacheApache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上.Apache源于NCSAhttpd服务器,经过多次修改,成为世界上最流行的Web服务器软 ...
- jQuery示例
<!DOCTYPE html><html lang="en" class="loading"><head> <meta ...
- vue :基本语法格式
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>Vu ...
- Selenium CSS定位语法
大部分人在使用selenium定位元素时,用的是xpath定位,因为xpath基本能解决定位的需求.css定位往往被忽略掉了,其实css定位也有它的价值,css定位更快,语法更简洁.这一篇css的定位 ...
- Linux发布WebApi
一:WebApi 使用Owin来做 http://www.cnblogs.com/xiaoyaodijun/category/666029.html 二:安装最新版的Jexus服务 https:// ...
- django-会话 cookie 中缺少HttpOnly 属性-安全加强
如果django程序扫描到会话 cookie 中缺少 HttpOnly 属性问题,需要如何进行安全加强? https://docs.djangoproject.com/en/2.2/ref/setti ...
- vue-app开发入门
vue的中文文档在这里 1. 简单地引用vue.js 使用vue框架最简单的方式就是写一个HTML页面然后引用vue.js啦. 使用<script> 标签就可以将vue.js导入并且使用它 ...