作者:文兄
链接: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预测模型【转载】的更多相关文章

  1. Domain adaptation:连接机器学习(Machine Learning)与迁移学习(Transfer Learning)

    domain adaptation(域适配)是一个连接机器学习(machine learning)与迁移学习(transfer learning)的新领域.这一问题的提出在于从原始问题(对应一个 so ...

  2. 【机器学习Machine Learning】资料大全

    昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...

  3. Machine Learning Algorithms Study Notes(2)--Supervised Learning

    Machine Learning Algorithms Study Notes 高雪松 @雪松Cedro Microsoft MVP 本系列文章是Andrew Ng 在斯坦福的机器学习课程 CS 22 ...

  4. Stanford机器学习笔记-7. Machine Learning System Design

    7 Machine Learning System Design Content 7 Machine Learning System Design 7.1 Prioritizing What to W ...

  5. Machine Learning - 第7周(Support Vector Machines)

    SVMs are considered by many to be the most powerful 'black box' learning algorithm, and by posing构建 ...

  6. 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 ...

  7. Machine Learning - 第3周(Logistic Regression、Regularization)

    Logistic regression is a method for classifying data into discrete outcomes. For example, we might u ...

  8. 机器学习(Machine Learning)&深度学习(Deep Learning)资料【转】

    转自:机器学习(Machine Learning)&深度学习(Deep Learning)资料 <Brief History of Machine Learning> 介绍:这是一 ...

  9. Coursera《machine learning》--(8)神经网络表述

    本笔记为Coursera在线课程<Machine Learning>中的神经网络章节的笔记. 八.神经网络:表述(Neural Networks: Representation) 本节主要 ...

随机推荐

  1. GitHub搭配使用Travis CI 进行自动构建服务

    Travis CI (Continuous Integration)持续集成服务 用处:自动监控软件仓库,可以在代码提交后立刻执行自动测试或构建 1.在Github自己的仓库根目录里添加.travis ...

  2. PHP实现动态获取函数参数的方法

    1. func_num_args — 返回传入函数的参数总个数 int func_num_args ( void ) 示例 <?php function demo () { $numargs = ...

  3. java----static关键字(包括final)

    static修饰字段: 使用static关键字修饰一个字段:声明的static变量实际上就是一个全局变量 使用static关键字修饰一个方法:可以直接使用类调用方法,和对象没有关系了 使用static ...

  4. C++ GetModuleFileName()

    关于GetModuleFileName function,参考:https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197(v= ...

  5. axure--中继器

    *****中继器-repeater*****1.结构:类似于MVC(增删查改)1)中继器数据集:可包括图片.文字.网址(页面)(右键添加,列名尽量使用英 文或拼音) 2)中继器格式:横向.纵向(是否换 ...

  6. Android取得系统时间

    Time t = new Time();//实例化Time类 t.setToNow();//取得当前的系统时间 int month = t.month;//获取月 int year = t.year; ...

  7. Java接口自动化测试之TestNG测试报告ExtentReports的应用(三)

    pom.xml导入包 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=" ...

  8. 解决AS gradle下载同步卡慢的问题

    国内因为GFW的原因,导致同步谷歌等服务器的插件源非常非常慢,几乎是龟爬,还好有阿里云的镜像源,据说速度很快,还不快试试: 1.build.gradle里的buildscript和allproject ...

  9. Android.os.SystemClock

    https://www.linuxidc.com/Linux/2011-11/48325p2.htm 文档中对System.currentTimeMillis()进行了相应的描述,就是说它不适合用在需 ...

  10. NHibernate:no persister for 异常

    几种原因: 1.配置文件后缀名写错 mapping file 必须是.hbm.xml结尾 2.Web.config配置里面引用实体 <session-factory> .......... ...