Feature Engineering versus Feature Extraction: Game On!

"Feature engineering" is a fancy term for making sure that your predictors are encoded in the model in a manner that makes it as easy as possible for the model to achieve good performance. For example, if your have a date field as a predictor and there are larger differences in response for the weekends versus the weekdays, then encoding the date in this way makes it easier to achieve good results.

However, this depends on a lot of things.

First, it is model-dependent. For example, trees might have trouble with a classification data set if the class boundary is a diagonal line since their class boundaries are made using orthogonal slices of the data (oblique trees excepted).

Second, the process of predictor encoding benefits the most from subject-specific knowledge of the problem. In my example above, you need to know the patterns of your data to improve the format of the predictor. Feature engineering is very different in image processing, information retrieval, RNA expressions profiling, etc. You need to know something about the problem and your particular data set to do it well.

Here is some training set data where two predictors are used to model a two-class system (I'll unblind the data at the end):

There is also a corresponding test set that we will use below.

There are some observations that we can make:

  • The data are highly correlated (correlation = 0.85)
  • Each predictor appears to be fairly right-skewed
  • They appear to be informative in the sense that you might be able to draw a diagonal line to differentiate the classes

Depending on what model that we might choose to use, the between-predictor correlation might bother us. Also, we should look to see of the individual predictors are important. To measure this, we'll use the area under the ROC curve on the predictor data directly.

Here are univariate box-plots of each predictor (on the log scale):

There is some mild differentiation between the classes but a significant amount of overlap in the boxes. The area under the ROC curves for predictor A and B are 0.61 and 0.59, respectively. Not so fantastic.

What can we do? Principal component analysis (PCA) is a pre-processing method that does a rotation of the predictor data in a manner that creates new synthetic predictors (i.e. the principal components or PC's). This is conducted in a way where the first component accounts for the majority of the (linear) variation or information in the predictor data. The second component does the same for any information in the data that remains after extracting the first component and so on. For these data, there are two possible components (since there are only two predictors). Using PCA in this manner is typically called feature extraction.

Let's compute the components:

> library(caret)
> head(example_train)
   PredictorA PredictorB Class
2 3278.726 154.89876 One
3 1727.410 84.56460 Two
4 1194.932 101.09107 One
12 1027.222 68.71062 Two
15 1035.608 73.40559 One
16 1433.918 79.47569 One
> pca_pp <- preProcess(example_train[, 1:2],
+ method = c("center", "scale", "pca"))
+ pca_pp

Call:
preProcess.default(x = example_train[, 1:2], method = c("center",
"scale", "pca")) Created from 1009 samples and 2 variables
Pre-processing: centered, scaled, principal component signal extraction PCA needed 2 components to capture 95 percent of the variance
> train_pc <- predict(pca_pp, example_train[, 1:2])
> test_pc <- predict(pca_pp, example_test[, 1:2])
> head(test_pc, 4)
        PC1         PC2
1 0.8420447 0.07284802
5 0.2189168 0.04568417
6 1.2074404 -0.21040558
7 1.1794578 -0.20980371

Note that we computed all the necessary information from the training set and apply these calculations to the test set. What do the test set data look like?

These are the test set predictors simply rotated.

PCA is unsupervised, meaning that the outcome classes are not considered when the calculations are done. Here, the area under the ROC curves for the first component is 0.5 and 0.81 for the second component. These results jive with the plot above; the first component has an random mixture of the classes while the second seems to separate the classes well. Box plots of the two components reflect the same thing:

There is much more separation in the second component.

This is interesting. First, despite PCA being unsupervised, it managed to find a new predictor that differentiates the classes. Secondly, it is the last component that is most important to the classes but the least important to the predictors. It is often said that PCA doesn't guarantee that any of the components will be predictive and this is true. Here, we get lucky and it does produce something good.

However, imagine that there are hundreds of predictors. We may only need to use the first X components to capture the majority of the information in the predictors and, in doing so, discard the later components. In this example, the first component accounts for 92.4% of the variation in the predictors; a similar strategy would probably discard the most effective predictor.

How does the idea of feature engineering come into play here? Given these two predictors and seeing the first scatterplot shown above, one of the first things that occurs to me is "there are two correlated, positive, skewed predictors that appear to act in tandem to differentiate the classes". The second thing that occurs to be is "take the ratio". What does that data look like?

The corresponding area under the ROC curve is 0.8, which is nearly as good as the second component. A simple transformation based on visually exploring the data can do just as good of a job as an unbiased empirical algorithm.

These data are from the cell segmentation experiment of Hill et al,and predictor A is the "surface of a sphere created from by rotating the equivalent circle about its diameter" (labeled as EqSphereAreaCh1 in the data) and predictor B is the perimeter of the cell nucleus (PerimCh1). A specialist in high content screening might naturally take the ratio of these two features of cells because it makes good scientific sense (I am not that person). In the context of the problem, their intuition should drive the feature engineering process.

However, in defense of an algorithm such as PCA, the machine has some benefit. In total, there are almost sixty predictors in these data whose features are just as arcane as EqSphereAreaCh1. My personal favorite is the "Haralick texture measurement of the spatial arrangement of pixels based on the co-occurrence matrix". Look that one up some time. The point is that there are often too many features to engineer and they might be completely unintuitive from the start.

Another plus for feature extraction is related to correlation. The predictors in this particular data set tend to have high between-predictor correlations and for good reasons. For example, there are many different ways to quantify the eccentricity of a cell (i.e. how elongated it is). Also, the size of a cell's nucleus is probably correlated with the size of the overall cell and so on. PCA can mitigate the effect of these correlations in one fell swoop. An approach of manually taking ratios of many predictors seems less likely to be effective and would take more time.

Last year, in one of the R&D groups that I support, there was a bit of a war being waged between the scientists who focused on biased analysis (i.e. we model what we know) versus the unbiased crowd (i.e. just let the machine figure it out). I fit somewhere in-between and believe that there is a feedback loop between the two. The machine can flag potentially new and interesting features that, once explored, become part of the standard book of "known stuff".

Feature Engineering versus Feature Extraction: Game On!的更多相关文章

  1. Feature Engineering and Feature Selection

    首先,弄清楚三个相似但是不同的任务: feature extraction and feature engineering: 将原始数据转换为特征,以适合建模. feature transformat ...

  2. Discover Feature Engineering, How to Engineer Features and How to Get Good at It

    Feature engineering is an informal topic, but one that is absolutely known and agreed to be key to s ...

  3. 学习笔记(四): Representation:Feature Engineering/Qualities of Good Features/Cleaning Data/Feature Sets

    目录 Representation Feature Engineering Mapping Raw Data to Features Mapping numeric values Mapping ca ...

  4. 特征工程(Feature Engineering)

    一.什么是特征工程? "Feature engineering is the process of transforming raw data into features that bett ...

  5. 【计算机视觉领域】常用的 feature 提取方法,feature 提取工具包

    [计算机视觉领域]常用的 feature 提取方法,feature 提取工具包 利用 VL 工具包进行各种特征的提取: VL 工具包官网地址:http://www.vlfeat.org/index.h ...

  6. 机器学习-特征工程-Feature generation 和 Feature selection

    概述:上节咱们说了特征工程是机器学习的一个核心内容.然后咱们已经学习了特征工程中的基础内容,分别是missing value handling和categorical data encoding的一些 ...

  7. feature.shape和feature.shapecopy的区别

    以前在写AE代码的时候也没有注意到feature.shape和feature.shapecopy的区别,觉得两者也差不多: 今天写入库程序才明白过来. 如果取feature.shape,则得到的是该要 ...

  8. Google Play和基于Feature的过滤 —— Feature 参考手册

    翻译自 Features Reference 下表列出了软/硬件Feature和权限的参考信息,它们被用于GooglePlay. 硬件feature 下面列出了被大多数当前发布的平台所支持的硬件功能描 ...

  9. tensorflow-TFRecord报错ValueError: Protocol message Feature has no "feature" field.

    编写代码用TFRecord数据结构存储数据集信息是报错:ValueError: Protocol message Feature has no "feature" field.或和 ...

随机推荐

  1. 设计师眼中功能强大的Xcode

    作为设计师,不仅要能创造出移动为先的新产品,更要了解能创造出优秀移动作品的工具.这个实现过程可以让我们的设计更加优秀. 过去两个月,我每天在 Xcode 上花费的时间大约有 10 个小时,我学到了很多 ...

  2. 转:OK6410内存及启动流程

    一.内存 只是从大体上介绍,并没有涉及寄存器的操作 6410的系统资源为:256MB DDR .2GB NANDFlash 如下图所示: ROM是只读存储器,RAM是随机存储器. 区别: 1.ROM( ...

  3. Python脚本控制的WebDriver 常用操作 <十一> 操作测试对象

    下面将使用WebDriver来模拟键盘的输入操作,以及复习上节的层对象操作 测试用例场景 定位到具体的对象后,我们就可以对这个对象进行具体的操作,比如先前已经看到过的点击操作(click).一般来说, ...

  4. 关于activity_main.xml与fragment_main.xml

    第一种解决办法 新版安装SDK文件一开始有两个XML文件,activity_main.xml和fragment_main.xml,不习惯的可以这样处理:1.删除fragment_main.xml整个文 ...

  5. Google Chrome浏览器各版本直接下载地址

    Google Chrome浏览器各版本直接下载地址  2012.04.12珍藏软件  10161 Views  0 Comments 现在所用的主浏览器Google Chrome,在其官方主页上默认只 ...

  6. Linux中JDK环境变量的配置

    在JDK安装好以后,需要进行环境变量的配置 配置目录   /etc/profile 在这个文件的末尾追加 JAVA_HOME=/home/j2sdk1.4.2_11PATH=$PATH:/home/j ...

  7. MAC 重置MySQL root 密码

    重置MySQL root 密码:当忘记密码,或者想要强行重置 MySQL 密码的时候,可以像下面这样: 1.停止 MySQL 服务 sudo /usr/local/mysql/support-file ...

  8. hdu 5142 NPY and FFT

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5142 NPY and FFT Description A boy named NPY is learn ...

  9. iOS学习之界面通信

    一.属性传值 在SecondViewController.h里 #import <UIKit/UIKit.h> @interface SecondViewController : UIVi ...

  10. swift 命令行工具初探

    亲爱的同学们好,今天我们要介绍这么一个东西.相信有过解释型语言(PHP,Ruby,等)使用经验的同学会更加熟悉,就是 Swift 也为我们提供了命令行运行工具,俗称 REPL.好了,我们进入正题,在安 ...