如何做出一个更好的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) 本节主要 ...
随机推荐
- hiho1460 rmq模板题
好久没做rmq的题了,今天写了一遍,感觉打表有点像区间dp /* 给定长为n的字符串,要求在字符串中选择k个字符, 选择的子系列字典序最小 因为选择k个字符,那么就是去掉n-k个字符 那么[1,n-k ...
- queryset优化 。。。。。exists()与iterator()方法
exists()方法!! 判断queryset是否有值存在.exists() 只会查询一个字段 .正常会查所有!!! iterator()方法 objs = Book.objects.all() ...
- vue 在.vue文件里监听路由
监听路由 watch $route vue项目中的App.vue 文件 <template> <div id="app"> <!--includ ...
- Java 画一个5X5的方形矩阵
效果图如下: 思路:创建一个窗口,使其居中于屏幕中央,使用drawRect(x, y, width, height)画正方形. import java.awt.Graphics; import jav ...
- go-web项目性能测试,CPU, 内存泄露等
go中提供了pprof包来做代码的性能监控,在两个地方有包: net/http/pprof runtime/pprof 其实net/http/pprof中只是使用runtime/pprof包来进行封装 ...
- Loadrunner11.0 录制手机App脚本的方法一
使用Loadrunner录制手机终端App脚本 1. 说明 目前手机APP上的功能日益丰富,对手机应用功能的性能测试需求也越来越多.公司比较抠门没有花钱买Loadrunner,可怜我们工作中一直用的破 ...
- python操作注册表
#注册表操作 # -*- coding: utf-8 -*- import win32api import win32con #打开注册表:传主键化值,子键值,操作方法(win32con.KEY_AL ...
- POJ 3080 Blue Jeans (字符串处理暴力枚举)
Blue Jeans Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21078 Accepted: ...
- python---使用字典来实现链接表图
最后一章,坚持!!! # coding = utf-8 class Vertex: def __init__(self, key): self.id = key self.connected_to = ...
- mysql恢复ibd文件
1.将原表删除,包括ibd和frm文件 2.重新创建表结构. 3.丢弃表空间 alter table tableName discard tablespace; 4.将要恢复的ibd文件拷贝到数据库目 ...