学习笔记(五): Feature Crosses

特征交叉是一种通过将两个或多个特征相乘来创建合成特征的方法,可以捕捉特征之间的非线性关系。本文介绍了特征交叉的概念、用途,以及如何在TensorFlow中实现。通过特征交叉,线性模型能够学习到更复杂的模式,解决非线性问题。
摘要由CSDN通过智能技术生成

 

目录

Feature Crosses

Encoding Nonlinearity

Kinds of feature crosses

Glossay 

Crossing One-Hot Vectors

Playground Exercises

Introducing Feature Crosses

More Complex Feature Crosses

Programming Exercise

Check Your Understanding


Feature Crosses

feature cross is a synthetic feature formed by multiplying (crossing) two or more features. Crossing combinations of features can provide predictive abilities beyond what those features can provide individually.

Learning Objectives

  • Build an understanding of feature crosses.
  • Implement feature crosses in TensorFlow.

 

Encoding Nonlinearity

In Figures 1 and 2, imagine the following:

  • The blue dots represent sick trees.
  • The orange dots represent healthy trees.

Blues dots occupy the northeast quadrant; orange dots occupy the southwest quadrant.

Figure 1. Is this a linear problem?

Can you draw a line that neatly separates the sick trees from the healthy trees? Sure. This is a linear problem. The line won't be perfect. A sick tree or two might be on the "healthy" side, but your line will be a good predictor.

Now look at the following figure:

Blues dots occupy the northeast and southwest quadrants; orange dots occupy the northwest and southeast quadrants.

Figure 2. Is this a linear problem?

Can you draw a single straight line that neatly separates the sick trees from the healthy trees? No, you can't. This is a nonlinear problem. Any line you draw will be a poor predictor of tree health.

Same drawing as Figure 2, except that a horizontal line breaks the plane. Blue and orange dots are above the line; blue and orange dots are below the line.

Figure 3. A single line can't separate the two classes.

To solve the nonlinear problem shown in Figure 2, create a feature cross.

feature cross is a synthetic feature that encodes nonlinearity in the feature space by multiplying two or more input features together. (The term cross comes from cross product.) Let's create a feature cross named x3 by crossing x1 and x2:

x3=x1x2

We treat this newly minted x3 feature cross just like any other feature. The linear formula becomes:

y=b+w1x1+w2x2+w3x3

A linear algorithm can learn a weight for w3 just as it would for w1 and w2. In other words, although w3 encodes nonlinear information, you don’t need to change how the linear model trains to determine the value of w3.

 

Kinds of feature crosses

We can create many different kinds of feature crosses. For example:

  • [A X B]: a feature cross formed by multiplying the values of two features.
  • [A x B x C x D x E]: a feature cross formed by multiplying the values of five features.
  • [A x A]: a feature cross formed by squaring a single feature.

Thanks to stochastic gradient descent, linear models can be trained efficiently. Consequently, supplementing scaled linear models with feature crosses has traditionally been an efficient way to train on massive-scale data sets.

 

Glossay 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值