`
BradyZhu
  • 浏览: 261322 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

机器学习系列(5)_从白富美相亲看特征预处理与选择(上)

 
阅读更多

作者:龙心尘 &&寒小阳
时间:2016年1月。
出处:
http://blog.csdn.net/longxinchen_ml/article/details/50471682,
http://blog.csdn.net/han_xiaoyang/article/details/50481967
声明:版权所有,转载请联系作者并注明出处

1. 引言

再过一个月就是春节,相信有很多码农就要准备欢天喜地地回家过(xiang)年(qin)了。我们今天也打算讲一个相亲的故事。

讲机器学习为什么要讲相亲?被讨论群里的小伙伴催着相亲,哦不,催着讲特征工程紧啊。只是我们不太敢讲这么复杂高深的东西,毕竟工程实践的经验太复杂了,没有统一的好解释的理论,一般的教材讲这方面的内容不多。我们就打算以一个相亲的故事为例,串一些特征工程的内容。

2. 故事背景

事先声明:本故事纯属虚构,如有雷同,纯属巧合!

海归白富美韩梅梅刚回国,还没适应工作,母亲就催着相亲。以父母的关系,他们了解到的适龄单身男青年有100个。要从100个男生中找到1个理想的女婿,可谓百里挑一。韩梅梅母亲也担心女儿相亲多了会反感,打算草拟一个相亲名单,人数不多。怎么从中挑出优秀男青年就是一个首要的问题。

3. 用机器学习的框架去分析

我们用机器学习的框架分析,在父母眼中,这100个男生最终将会分成两类:“女婿”(1人)和“非女婿”(99人)。“女婿”和“非女婿”就叫做“标签”。

而选择相亲名单的标准——如“是否高富帅”、“是否海归”等等——就叫作“特征”。最好能有一个特征能够精确定位理想女婿。但这太过理想了。比较现实的方法是从这些“特征”中选择、拆分、组合出最合适的特征,逐渐逼近我们的标签,以形成一个精简的相亲名单。而这个过程,就可以理解成特征处理、特征工程的过程。

但是,现实中的特征有千千万,拆分重组之后特征又是几何级数地增加,可能永远也穷举不完。因此需要有统一客观的指标来衡量这些特征对标签的识别能力,以便进一步地深入分析。而评估这些“特征”对我们的“标签”的有效程度的过程就叫作“特征有效性分析”。

4. 剧情一:韩妈妈的“如意算盘”

为人父母嘛,总是希望女儿嫁得好。韩妈妈的第一反应的就是要找“高富帅”。先她先从这100个男生中挑了挑,符合高富帅这个标准的有5个人。

韩妈妈的如意算盘是这样的:女婿就从这5个人中挑,概率就是20%,比之前的1%整整提高了20倍,嘿嘿嘿。。。

5. 特征有效性分析

其实,这就韩妈妈不知不觉就走了一个特征有效性分析的过程。我们用图表演示一下:


图表

考虑到各方面的概率,用下图表示更加直观:

条件概率

为了表述方便,我们以随机挑女婿而不考虑任何特征的概率叫做“先验概率”(1%)。而中间的箭头中的概率则表示在已经知道样本所属特征前提下,属于女婿还是不属于女婿的概率,也可以叫作“标签相对于某个特征的后验概率”(20%)。而母亲的如意算盘就是考虑了上图中红圈部分的先验概率与后验概率(也可以叫条件概率)。这其实是一种很朴素的特征有效性分析的方法。而且她还做了个更加精确的数量化描述:

<nobr><span class="math" id="MathJax-Span-1" style="width: 13.229em; display: inline-block;"><span style="display: inline-block; position: relative; width: 10.563em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.283em 1000em 3.363em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-2"><span class="mfrac" id="MathJax-Span-3"><span style="display: inline-block; position: relative; width: 2.669em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -2.877em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-4"><span class="texatom" id="MathJax-Span-5"><span class="mrow" id="MathJax-Span-6"><span class="mo" id="MathJax-Span-7" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">后</span></span></span></span><span class="texatom" id="MathJax-Span-8"><span class="mrow" id="MathJax-Span-9"><span class="mo" id="MathJax-Span-10" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-11"><span class="mrow" id="MathJax-Span-12"><span class="mo" id="MathJax-Span-13" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-14"><span class="mrow" id="MathJax-Span-15"><span class="mo" id="MathJax-Span-16" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -1.864em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-17"><span class="texatom" id="MathJax-Span-18"><span class="mrow" id="MathJax-Span-19"><span class="mo" id="MathJax-Span-20" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">先</span></span></span></span><span class="texatom" id="MathJax-Span-21"><span class="mrow" id="MathJax-Span-22"><span class="mo" id="MathJax-Span-23" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-24"><span class="mrow" id="MathJax-Span-25"><span class="mo" id="MathJax-Span-26" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-27"><span class="mrow" id="MathJax-Span-28"><span class="mo" id="MathJax-Span-29" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.669em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-30" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mfrac" id="MathJax-Span-31" style="padding-left: 0.323em;"><span style="display: inline-block; position: relative; width: 1.389em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.477em); top: -2.824em; left: 50%; margin-left: -0.637em;"><span class="mrow" id="MathJax-Span-32"><span class="mn" id="MathJax-Span-33" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">20</span><span class="mi" id="MathJax-Span-34" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">%</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -1.971em; left: 50%; margin-left: -0.424em;"><span class="mrow" id="MathJax-Span-35"><span class="mn" id="MathJax-Span-36" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span class="mi" id="MathJax-Span-37" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">%</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 1.389em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-38" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-39" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">20</span><span class="texatom" id="MathJax-Span-40"><span class="mrow" id="MathJax-Span-41"><span class="mo" id="MathJax-Span-42"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="texatom" id="MathJax-Span-43"><span class="mrow" id="MathJax-Span-44"><span class="mo" id="MathJax-Span-45"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">倍</span></span></span></span><span class="texatom" id="MathJax-Span-46"><span class="mrow" id="MathJax-Span-47"><span class="mo" id="MathJax-Span-48"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 2.337em; vertical-align: -0.863em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1">\frac{后验概率}{先验概率}=\frac{20\%}{1\%}=20(倍)</script>。

只是在工程上做除法可能运算会麻烦些,而两边同时取对数转换成减法则更方便:

<nobr><span class="math" id="MathJax-Span-49" style="width: 22.136em; display: inline-block;"><span style="display: inline-block; position: relative; width: 17.709em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.283em 1000em 3.363em -0.424em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-50"><span class="mi" id="MathJax-Span-51" style="font-family: STIXGeneral-Italic;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-52" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-53" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-54" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-55"><span style="display: inline-block; position: relative; width: 2.669em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -2.877em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-56"><span class="texatom" id="MathJax-Span-57"><span class="mrow" id="MathJax-Span-58"><span class="mo" id="MathJax-Span-59" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">后</span></span></span></span><span class="texatom" id="MathJax-Span-60"><span class="mrow" id="MathJax-Span-61"><span class="mo" id="MathJax-Span-62" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-63"><span class="mrow" id="MathJax-Span-64"><span class="mo" id="MathJax-Span-65" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-66"><span class="mrow" id="MathJax-Span-67"><span class="mo" id="MathJax-Span-68" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -1.864em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-69"><span class="texatom" id="MathJax-Span-70"><span class="mrow" id="MathJax-Span-71"><span class="mo" id="MathJax-Span-72" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">先</span></span></span></span><span class="texatom" id="MathJax-Span-73"><span class="mrow" id="MathJax-Span-74"><span class="mo" id="MathJax-Span-75" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-76"><span class="mrow" id="MathJax-Span-77"><span class="mo" id="MathJax-Span-78" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-79"><span class="mrow" id="MathJax-Span-80"><span class="mo" id="MathJax-Span-81" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.669em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-82" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-83" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mi" id="MathJax-Span-84" style="font-family: STIXGeneral-Italic; padding-left: 0.323em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-85" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-86" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-87" style="font-family: STIXGeneral-Regular;">(</span><span class="texatom" id="MathJax-Span-88"><span class="mrow" id="MathJax-Span-89"><span class="mo" id="MathJax-Span-90"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">后</span></span></span></span><span class="texatom" id="MathJax-Span-91"><span class="mrow" id="MathJax-Span-92"><span class="mo" id="MathJax-Span-93"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-94"><span class="mrow" id="MathJax-Span-95"><span class="mo" id="MathJax-Span-96"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-97"><span class="mrow" id="MathJax-Span-98"><span class="mo" id="MathJax-Span-99"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span><span class="mo" id="MathJax-Span-100" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-101" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">−</span><span class="mi" id="MathJax-Span-102" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-103" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-104" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-105" style="font-family: STIXGeneral-Regular;">(</span><span class="texatom" id="MathJax-Span-106"><span class="mrow" id="MathJax-Span-107"><span class="mo" id="MathJax-Span-108"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">先</span></span></span></span><span class="texatom" id="MathJax-Span-109"><span class="mrow" id="MathJax-Span-110"><span class="mo" id="MathJax-Span-111"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-112"><span class="mrow" id="MathJax-Span-113"><span class="mo" id="MathJax-Span-114"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-115"><span class="mrow" id="MathJax-Span-116"><span class="mo" id="MathJax-Span-117"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span><span class="mo" id="MathJax-Span-118" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 2.337em; vertical-align: -0.863em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2">log(\frac{后验概率}{先验概率})=log(后验概率)-log(先验概率) </script>

概率表示着选女婿的可能性或者确定性。在本例中,后验概率的确定性比先验概率的确定性更高。可见,“确定性的增加”可以作为特征有效性分析的一个指标。

我们进一步分析,无论先验概率还是后验概率,其本身是0-1之间的一个数,取完对数之后是一个负数,这在现实中不太方便找到其对应的现象解释。但是概率的倒数一定大于1,取完对数之后就是一个正数,就好找现实解释了。我们可以把这个“概率倒数的对数”理解成不确定性的指标。于是上式就变成:

<nobr><span class="math" id="MathJax-Span-119" style="width: 21.336em; display: inline-block;"><span style="display: inline-block; position: relative; width: 17.069em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.283em 1000em 3.363em -0.424em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-120"><span class="mi" id="MathJax-Span-121" style="font-family: STIXGeneral-Italic;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-122" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-123" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-124" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-125"><span style="display: inline-block; position: relative; width: 2.669em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -2.877em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-126"><span class="texatom" id="MathJax-Span-127"><span class="mrow" id="MathJax-Span-128"><span class="mo" id="MathJax-Span-129" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">后</span></span></span></span><span class="texatom" id="MathJax-Span-130"><span class="mrow" id="MathJax-Span-131"><span class="mo" id="MathJax-Span-132" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-133"><span class="mrow" id="MathJax-Span-134"><span class="mo" id="MathJax-Span-135" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-136"><span class="mrow" id="MathJax-Span-137"><span class="mo" id="MathJax-Span-138" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -1.864em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-139"><span class="texatom" id="MathJax-Span-140"><span class="mrow" id="MathJax-Span-141"><span class="mo" id="MathJax-Span-142" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">先</span></span></span></span><span class="texatom" id="MathJax-Span-143"><span class="mrow" id="MathJax-Span-144"><span class="mo" id="MathJax-Span-145" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-146"><span class="mrow" id="MathJax-Span-147"><span class="mo" id="MathJax-Span-148" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-149"><span class="mrow" id="MathJax-Span-150"><span class="mo" id="MathJax-Span-151" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.669em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-152" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-153" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mi" id="MathJax-Span-154" style="font-family: STIXGeneral-Italic; padding-left: 0.323em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-155" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-156" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-157" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-158"><span style="display: inline-block; position: relative; width: 2.669em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-159" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -1.864em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-160"><span class="texatom" id="MathJax-Span-161"><span class="mrow" id="MathJax-Span-162"><span class="mo" id="MathJax-Span-163" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">先</span></span></span></span><span class="texatom" id="MathJax-Span-164"><span class="mrow" id="MathJax-Span-165"><span class="mo" id="MathJax-Span-166" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-167"><span class="mrow" id="MathJax-Span-168"><span class="mo" id="MathJax-Span-169" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-170"><span class="mrow" id="MathJax-Span-171"><span class="mo" id="MathJax-Span-172" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.669em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-173" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-174" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">−</span><span class="mi" id="MathJax-Span-175" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-176" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-177" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-178" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-179"><span style="display: inline-block; position: relative; width: 2.669em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-180" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.603em 1000em 2.669em -0.477em); top: -1.864em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-181"><span class="texatom" id="MathJax-Span-182"><span class="mrow" id="MathJax-Span-183"><span class="mo" id="MathJax-Span-184" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">后</span></span></span></span><span class="texatom" id="MathJax-Span-185"><span class="mrow" id="MathJax-Span-186"><span class="mo" id="MathJax-Span-187" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-188"><span class="mrow" id="MathJax-Span-189"><span class="mo" id="MathJax-Span-190" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-191"><span class="mrow" id="MathJax-Span-192"><span class="mo" id="MathJax-Span-193" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.669em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-194" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 2.337em; vertical-align: -0.863em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-3">log(\frac{后验概率}{先验概率})=log(\frac{1}{先验概率})-log(\frac{1}{后验概率})</script>

这里面的<nobr><span class="math" id="MathJax-Span-195" style="width: 6.152em; display: inline-block;"><span style="display: inline-block; position: relative; width: 4.757em; height: 0px; font-size: 129%;"><span style="position: absolute; clip: rect(1.191em 1000em 3.258em -0.411em); top: -2.478em; left: 0.003em;"><span class="mrow" id="MathJax-Span-196"><span class="mi" id="MathJax-Span-197" style="font-family: STIXGeneral-Italic;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-198" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-199" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-200" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-201"><span style="display: inline-block; position: relative; width: 2.587em; height: 0px; margin-right: 0.106em; margin-left: 0.106em;"><span style="position: absolute; clip: rect(1.553em 1000em 2.587em -0.463em); top: -2.84em; left: 50%; margin-left: -1.238em;"><span class="mrow" id="MathJax-Span-202"><span class="texatom" id="MathJax-Span-203"><span class="mrow" id="MathJax-Span-204"><span class="mo" id="MathJax-Span-205" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">后</span></span></span></span><span class="texatom" id="MathJax-Span-206"><span class="mrow" id="MathJax-Span-207"><span class="mo" id="MathJax-Span-208" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-209"><span class="mrow" id="MathJax-Span-210"><span class="mo" id="MathJax-Span-211" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-212"><span class="mrow" id="MathJax-Span-213"><span class="mo" id="MathJax-Span-214" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.276em;"></span></span><span style="position: absolute; clip: rect(1.553em 1000em 2.587em -0.463em); top: -1.806em; left: 50%; margin-left: -1.238em;"><span class="mrow" id="MathJax-Span-215"><span class="texatom" id="MathJax-Span-216"><span class="mrow" id="MathJax-Span-217"><span class="mo" id="MathJax-Span-218" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">先</span></span></span></span><span class="texatom" id="MathJax-Span-219"><span class="mrow" id="MathJax-Span-220"><span class="mo" id="MathJax-Span-221" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">验</span></span></span></span><span class="texatom" id="MathJax-Span-222"><span class="mrow" id="MathJax-Span-223"><span class="mo" id="MathJax-Span-224" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">概</span></span></span></span><span class="texatom" id="MathJax-Span-225"><span class="mrow" id="MathJax-Span-226"><span class="mo" id="MathJax-Span-227" style="font-size: 70.7%;"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">率</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.276em;"></span></span><span style="position: absolute; clip: rect(0.881em 1000em 1.243em -0.463em); top: -1.289em; left: 0.003em;"><span style="border-left-width: 2.587em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.088em;"></span></span></span></span><span class="mo" id="MathJax-Span-228" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.483em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 2.337em; vertical-align: -0.863em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-4">log(\frac{后验概率}{先验概率})</script>我们叫做互信息

因此,“不确定性的减少”可以作为特征有效性分析的一个指标。这个结论我们接下来将会反复用到。

6. 剧情二:白富美巧劝慈母

韩妈妈半开玩笑地问韩梅梅:“我们家闺女只挑高富帅的怎么样?”女儿想了想,说:“如果人家看不上我们怎么办?”母亲笑着说:“我们的家境哪里差了?何况我们的女儿这么优秀,我们还看不上他们呢。”

女儿说:“这就是说明我们双方不合适了。我们家条件虽然还不错,但是比下有余、比上不足,跟真正条件好的家庭比较起来我们根本不算事儿。如果一味挑高富帅,他们可能觉得我们只是看中他们的钱,反倒把我们家看低了。相反,要是真要有个真正对我好的男生,比什么都幸福,而他不一定必须是高富帅。毕竟跟我一起相处一辈子的是一个活生生的人,而不是他背后的东西嘛。”

母亲很有感慨地说:“嗯,你能这样想我就放心了。梅梅真是长大了。那么,你打算怎么办?”女儿说道:“高富帅也得分人,踏实人品好的也可以接触一下,但是玩心太重不会照顾人的我就不喜欢。估计高富帅里面这两种人一半一半吧。很多男生并不是高富帅,其中没准也有合适的人呢。”

7. 特征有效性分析

现在特征的分布发生了新变化。按韩梅梅的分析,高富帅中可能有一半她就不会喜欢,而不是高富帅的男生中没准有合适的人。我们可以简单假设高富帅中与非高富帅中各有0.5个合适的人。则分析图表如下:

图表

条件概率

现在的情况是,“是不是女婿”的可能性同时分布在“是高富帅”和“不是高富帅”中,单独衡量“高富帅”本身的后验概率已经不够描述特征的整体效果了。我们可以有一个考虑特征整体情况的指标。

还是回到之前的那句话:

不确定性的减少”可以作为特征有效性分析的一个指标。

我们之前考虑了“是女婿”的不确定性是<nobr><span class="math" id="MathJax-Span-229" style="width: 4.003em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.203em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.496em 1000em 3.149em -0.424em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-230"><span class="mi" id="MathJax-Span-231" style="font-family: STIXGeneral-Italic;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-232" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-233" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-234" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-235"><span style="display: inline-block; position: relative; width: 1.016em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-236" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -1.971em; left: 50%; margin-left: -0.424em;"><span class="mrow" id="MathJax-Span-237"><span class="mn" id="MathJax-Span-238" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span class="mi" id="MathJax-Span-239" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">%</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 1.016em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-240" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.803em; vertical-align: -0.597em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-5">log(\frac{1}{1\%})</script>,相应的“不是女婿”的不确定性是<nobr><span class="math" id="MathJax-Span-241" style="width: 4.483em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.576em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.496em 1000em 3.149em -0.424em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-242"><span class="mi" id="MathJax-Span-243" style="font-family: STIXGeneral-Italic;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-244" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-245" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-246" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-247"><span style="display: inline-block; position: relative; width: 1.389em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-248" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.477em); top: -1.971em; left: 50%; margin-left: -0.637em;"><span class="mrow" id="MathJax-Span-249"><span class="mn" id="MathJax-Span-250" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">99</span><span class="mi" id="MathJax-Span-251" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">%</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 1.389em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-252" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.803em; vertical-align: -0.597em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-6">log(\frac{1}{99\%})</script>,那么标签“是否女婿”作为整体的平均不确定性则可以理解为这两个状态的加权平均:

<nobr><span class="math" id="MathJax-Span-253" style="width: 27.736em; display: inline-block;"><span style="display: inline-block; position: relative; width: 22.189em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.496em 1000em 3.149em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-254"><span class="mi" id="MathJax-Span-255" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-256"><span class="mrow" id="MathJax-Span-257"><span class="mo" id="MathJax-Span-258"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-259" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-260"><span class="mrow" id="MathJax-Span-261"><span class="mo" id="MathJax-Span-262"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-263" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-264" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">1</span><span class="mi" id="MathJax-Span-265" style="font-family: STIXGeneral-Regular;">%</span><span class="mo" id="MathJax-Span-266" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">×</span><span class="mi" id="MathJax-Span-267" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-268" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-269" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-270" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-271"><span style="display: inline-block; position: relative; width: 1.016em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-272" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -1.971em; left: 50%; margin-left: -0.424em;"><span class="mrow" id="MathJax-Span-273"><span class="mn" id="MathJax-Span-274" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span class="mi" id="MathJax-Span-275" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">%</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 1.016em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-276" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-277" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">+</span><span class="mn" id="MathJax-Span-278" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">99</span><span class="mi" id="MathJax-Span-279" style="font-family: STIXGeneral-Regular;">%</span><span class="mo" id="MathJax-Span-280" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">×</span><span class="mi" id="MathJax-Span-281" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-282" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-283" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-284" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-285"><span style="display: inline-block; position: relative; width: 1.389em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-286" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.477em); top: -1.971em; left: 50%; margin-left: -0.637em;"><span class="mrow" id="MathJax-Span-287"><span class="mn" id="MathJax-Span-288" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">99</span><span class="mi" id="MathJax-Span-289" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">%</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 1.389em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-290" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-291" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-292" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.08079</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.803em; vertical-align: -0.597em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-7">H(Y)=1\%×log(\frac{1}{1\%})+99\%×log(\frac{1}{99\%})=0.08079</script>。(全文假定对数log的底数取为2)

这就是传说中的信息熵。我们用Y表示标签,用<nobr><span class="math" id="MathJax-Span-293" style="width: 3.843em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.043em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-294"><span class="mi" id="MathJax-Span-295" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-296"><span class="mrow" id="MathJax-Span-297"><span class="mo" id="MathJax-Span-298"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-299" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-300"><span class="mrow" id="MathJax-Span-301"><span class="mo" id="MathJax-Span-302"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-8">H(Y)</script>表示“是否女婿”的信息熵,也就是其整体的平均不确定性

那么考虑特征(“是否高帅富”)后的标签(“是否女婿”)的平均不确定性怎么衡量?我们用<nobr><span class="math" id="MathJax-Span-303" style="width: 15.043em; display: inline-block;"><span style="display: inline-block; position: relative; width: 12.003em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.531em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-304"><span class="mi" id="MathJax-Span-305" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-306" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">:</span><span class="mo" id="MathJax-Span-307" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">{</span><span class="mo" id="MathJax-Span-308" style="font-family: STIXGeneral-Regular;">“</span><span class="texatom" id="MathJax-Span-309"><span class="mrow" id="MathJax-Span-310"><span class="mo" id="MathJax-Span-311"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-312"><span class="mrow" id="MathJax-Span-313"><span class="mo" id="MathJax-Span-314"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-315"><span class="mrow" id="MathJax-Span-316"><span class="mo" id="MathJax-Span-317"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-318"><span class="mrow" id="MathJax-Span-319"><span class="mo" id="MathJax-Span-320"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-321" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-322" style="font-family: STIXGeneral-Regular;">,</span><span class="mo" id="MathJax-Span-323" style="font-family: STIXGeneral-Regular; padding-left: 0.216em;">“</span><span class="texatom" id="MathJax-Span-324"><span class="mrow" id="MathJax-Span-325"><span class="mo" id="MathJax-Span-326"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">不</span></span></span></span><span class="texatom" id="MathJax-Span-327"><span class="mrow" id="MathJax-Span-328"><span class="mo" id="MathJax-Span-329"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-330"><span class="mrow" id="MathJax-Span-331"><span class="mo" id="MathJax-Span-332"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-333"><span class="mrow" id="MathJax-Span-334"><span class="mo" id="MathJax-Span-335"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-336"><span class="mrow" id="MathJax-Span-337"><span class="mo" id="MathJax-Span-338"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-339" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-340" style="font-family: STIXGeneral-Regular;">}</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-9">X:\{“是高富帅”,“不是高富帅”\}</script>来表示特征。其实,与上面的思路类似,我们在已知特征为“是高富帅”的前提下,“是否女婿”这个标签的整体平均不确定性可以用相对“是高富帅”的后验概率来求出

<nobr><span class="math" id="MathJax-Span-341" style="width: 25.603em; display: inline-block;"><span style="display: inline-block; position: relative; width: 20.483em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(3.256em 1000em 6.883em -0.477em); top: -4.317em; left: 0.003em;"><span class="mrow" id="MathJax-Span-342"><span style="display: inline-block; position: relative; width: 20.483em; height: 0px;"><span style="position: absolute; clip: rect(2.936em 1000em 4.696em -0.477em); top: -3.997em; left: 0.003em;"><span class="mi" id="MathJax-Span-343" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-344" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-345" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-346"><span class="mrow" id="MathJax-Span-347"><span class="mo" id="MathJax-Span-348" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="mi" id="MathJax-Span-349" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-350" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-351" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-352"><span class="mrow" id="MathJax-Span-353"><span class="mo" id="MathJax-Span-354"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-355"><span class="mrow" id="MathJax-Span-356"><span class="mo" id="MathJax-Span-357"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-358"><span class="mrow" id="MathJax-Span-359"><span class="mo" id="MathJax-Span-360"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-361"><span class="mrow" id="MathJax-Span-362"><span class="mo" id="MathJax-Span-363"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-364" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-365" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-366" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-367" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">(</span><span class="mn" id="MathJax-Span-368" style="font-family: STIXGeneral-Regular;">0.5</span><span class="texatom" id="MathJax-Span-369"><span class="mrow" id="MathJax-Span-370"><span class="mo" id="MathJax-Span-371" style="font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-372" style="font-family: STIXGeneral-Regular;">5</span><span class="mo" id="MathJax-Span-373" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-374" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">×</span><span class="mi" id="MathJax-Span-375" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-376" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-377" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-378" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-379"><span style="display: inline-block; position: relative; width: 2.029em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-380" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.669em -0.424em); top: -2.024em; left: 50%; margin-left: -0.957em;"><span class="mrow" id="MathJax-Span-381"><span class="mo" id="MathJax-Span-382" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">(</span><span class="mn" id="MathJax-Span-383" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">0.5</span><span class="texatom" id="MathJax-Span-384"><span class="mrow" id="MathJax-Span-385"><span class="mo" id="MathJax-Span-386" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-387" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">5</span><span class="mo" id="MathJax-Span-388" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.029em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-389" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-390" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">+</span><span class="mo" id="MathJax-Span-391" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">(</span><span class="mn" id="MathJax-Span-392" style="font-family: STIXGeneral-Regular;">4.5</span><span class="texatom" id="MathJax-Span-393"><span class="mrow" id="MathJax-Span-394"><span class="mo" id="MathJax-Span-395" style="font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-396" style="font-family: STIXGeneral-Regular;">5</span><span class="mo" id="MathJax-Span-397" style="font-family: STIXGeneral-Regular;">)</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(2.936em 1000em 4.696em -0.424em); top: -2.077em; left: 0.003em;"><span class="mo" id="MathJax-Span-398" style="font-family: STIXGeneral-Regular;">×</span><span class="mi" id="MathJax-Span-399" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-400" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-401" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-402" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-403"><span style="display: inline-block; position: relative; width: 2.029em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-404" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.669em -0.424em); top: -2.024em; left: 50%; margin-left: -0.957em;"><span class="mrow" id="MathJax-Span-405"><span class="mo" id="MathJax-Span-406" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">(</span><span class="mn" id="MathJax-Span-407" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">4.5</span><span class="texatom" id="MathJax-Span-408"><span class="mrow" id="MathJax-Span-409"><span class="mo" id="MathJax-Span-410" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-411" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">5</span><span class="mo" id="MathJax-Span-412" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.029em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-413" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-414" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-415" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.46900</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 4.323em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 4.27em; vertical-align: -3.063em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-10">H(Y|X=“是高富帅”) = (0.5/5)×log(\frac{1}{(0.5/5)})+(4.5/5)×log(\frac{1}{(4.5/5)}) = 0.46900</script>

在已知特征为“不是高富帅”的前提下,“是否女婿”这个标签的整体平均不确定性可以用相对“不是高富帅”的后验概率来求出:

<nobr><span class="math" id="MathJax-Span-416" style="width: 28.643em; display: inline-block;"><span style="display: inline-block; position: relative; width: 22.883em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(3.256em 1000em 6.883em -0.477em); top: -4.317em; left: 0.003em;"><span class="mrow" id="MathJax-Span-417"><span style="display: inline-block; position: relative; width: 22.883em; height: 0px;"><span style="position: absolute; clip: rect(2.936em 1000em 4.696em -0.477em); top: -3.997em; left: 0.003em;"><span class="mi" id="MathJax-Span-418" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-419" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-420" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-421"><span class="mrow" id="MathJax-Span-422"><span class="mo" id="MathJax-Span-423" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="mi" id="MathJax-Span-424" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-425" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-426" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-427"><span class="mrow" id="MathJax-Span-428"><span class="mo" id="MathJax-Span-429"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">不</span></span></span></span><span class="texatom" id="MathJax-Span-430"><span class="mrow" id="MathJax-Span-431"><span class="mo" id="MathJax-Span-432"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-433"><span class="mrow" id="MathJax-Span-434"><span class="mo" id="MathJax-Span-435"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-436"><span class="mrow" id="MathJax-Span-437"><span class="mo" id="MathJax-Span-438"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-439"><span class="mrow" id="MathJax-Span-440"><span class="mo" id="MathJax-Span-441"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-442" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-443" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-444" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-445" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">(</span><span class="mn" id="MathJax-Span-446" style="font-family: STIXGeneral-Regular;">0.5</span><span class="texatom" id="MathJax-Span-447"><span class="mrow" id="MathJax-Span-448"><span class="mo" id="MathJax-Span-449" style="font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-450" style="font-family: STIXGeneral-Regular;">95</span><span class="mo" id="MathJax-Span-451" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-452" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">×</span><span class="mi" id="MathJax-Span-453" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-454" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-455" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-456" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-457"><span style="display: inline-block; position: relative; width: 2.403em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-458" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.669em -0.424em); top: -2.024em; left: 50%; margin-left: -1.117em;"><span class="mrow" id="MathJax-Span-459"><span class="mo" id="MathJax-Span-460" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">(</span><span class="mn" id="MathJax-Span-461" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">0.5</span><span class="texatom" id="MathJax-Span-462"><span class="mrow" id="MathJax-Span-463"><span class="mo" id="MathJax-Span-464" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-465" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">95</span><span class="mo" id="MathJax-Span-466" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.403em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-467" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-468" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">+</span><span class="mo" id="MathJax-Span-469" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">(</span><span class="mn" id="MathJax-Span-470" style="font-family: STIXGeneral-Regular;">94.5</span><span class="texatom" id="MathJax-Span-471"><span class="mrow" id="MathJax-Span-472"><span class="mo" id="MathJax-Span-473" style="font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-474" style="font-family: STIXGeneral-Regular;">95</span><span class="mo" id="MathJax-Span-475" style="font-family: STIXGeneral-Regular;">)</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(2.936em 1000em 4.696em -0.424em); top: -2.077em; left: 0.003em;"><span class="mo" id="MathJax-Span-476" style="font-family: STIXGeneral-Regular;">×</span><span class="mi" id="MathJax-Span-477" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">l<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-478" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-479" style="font-family: STIXGeneral-Italic;">g</span><span class="mo" id="MathJax-Span-480" style="font-family: STIXGeneral-Regular;">(</span><span class="mfrac" id="MathJax-Span-481"><span style="display: inline-block; position: relative; width: 2.723em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.563em -0.424em); top: -2.824em; left: 50%; margin-left: -0.157em;"><span class="mn" id="MathJax-Span-482" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">1</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.669em -0.424em); top: -2.024em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-483"><span class="mo" id="MathJax-Span-484" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">(</span><span class="mn" id="MathJax-Span-485" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">94.5</span><span class="texatom" id="MathJax-Span-486"><span class="mrow" id="MathJax-Span-487"><span class="mo" id="MathJax-Span-488" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-489" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">95</span><span class="mo" id="MathJax-Span-490" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.723em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-491" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-492" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-493" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.04741</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 4.323em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 4.27em; vertical-align: -3.063em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-11">H(Y|X=“不是高富帅”) = (0.5/95)×log(\frac{1}{(0.5/95)})+(94.5/95)×log(\frac{1}{(94.5/95)}) = 0.04741</script>。

因此,已知特征(无论具体是“是高富帅”还是“不是高富帅”)情况下的标签平均不确定性为前面两种情况的加权平均:

<nobr><span class="math" id="MathJax-Span-494" style="width: 3.683em; display: inline-block;"><span style="display: inline-block; position: relative; width: 2.936em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.709em 1000em 2.883em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-495"><span class="mi" id="MathJax-Span-496" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-497" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-498" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-499"><span class="mrow" id="MathJax-Span-500"><span class="mo" id="MathJax-Span-501" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="mi" id="MathJax-Span-502" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-503" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.203em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-12">H(Y|X)</script>
<nobr><span class="math" id="MathJax-Span-504" style="width: 29.229em; display: inline-block;"><span style="display: inline-block; position: relative; width: 23.363em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(3.043em 1000em 5.869em -0.424em); top: -3.997em; left: 0.003em;"><span class="mrow" id="MathJax-Span-505"><span style="display: inline-block; position: relative; width: 23.363em; height: 0px;"><span style="position: absolute; clip: rect(3.043em 1000em 4.376em -0.424em); top: -3.997em; left: 0.003em;"><span class="mo" id="MathJax-Span-506" style="font-family: STIXGeneral-Regular;">=</span><span class="mi" id="MathJax-Span-507" style="font-family: STIXGeneral-Italic; padding-left: 0.323em;">P</span><span class="mo" id="MathJax-Span-508" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-509" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-510" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-511" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-512"><span class="mrow" id="MathJax-Span-513"><span class="mo" id="MathJax-Span-514"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-515"><span class="mrow" id="MathJax-Span-516"><span class="mo" id="MathJax-Span-517"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-518"><span class="mrow" id="MathJax-Span-519"><span class="mo" id="MathJax-Span-520"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-521"><span class="mrow" id="MathJax-Span-522"><span class="mo" id="MathJax-Span-523"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-524" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-525" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-526" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">×</span><span class="mi" id="MathJax-Span-527" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-528" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-529" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-530"><span class="mrow" id="MathJax-Span-531"><span class="mo" id="MathJax-Span-532" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="mi" id="MathJax-Span-533" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-534" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-535" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-536"><span class="mrow" id="MathJax-Span-537"><span class="mo" id="MathJax-Span-538"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-539"><span class="mrow" id="MathJax-Span-540"><span class="mo" id="MathJax-Span-541"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-542"><span class="mrow" id="MathJax-Span-543"><span class="mo" id="MathJax-Span-544"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-545"><span class="mrow" id="MathJax-Span-546"><span class="mo" id="MathJax-Span-547"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-548" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-549" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-550" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">+</span><span class="mi" id="MathJax-Span-551" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">P</span><span class="mo" id="MathJax-Span-552" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-553" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-554" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-555" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-556"><span class="mrow" id="MathJax-Span-557"><span class="mo" id="MathJax-Span-558"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">不</span></span></span></span><span class="texatom" id="MathJax-Span-559"><span class="mrow" id="MathJax-Span-560"><span class="mo" id="MathJax-Span-561"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-562"><span class="mrow" id="MathJax-Span-563"><span class="mo" id="MathJax-Span-564"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-565"><span class="mrow" id="MathJax-Span-566"><span class="mo" id="MathJax-Span-567"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-568"><span class="mrow" id="MathJax-Span-569"><span class="mo" id="MathJax-Span-570"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-571" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-572" style="font-family: STIXGeneral-Regular;">)</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(3.043em 1000em 4.376em -0.424em); top: -2.504em; left: 0.003em;"><span class="mo" id="MathJax-Span-573" style="font-family: STIXGeneral-Regular;">×</span><span class="mi" id="MathJax-Span-574" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-575" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-576" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-577"><span class="mrow" id="MathJax-Span-578"><span class="mo" id="MathJax-Span-579" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="mi" id="MathJax-Span-580" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-581" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-582" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-583"><span class="mrow" id="MathJax-Span-584"><span class="mo" id="MathJax-Span-585"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">不</span></span></span></span><span class="texatom" id="MathJax-Span-586"><span class="mrow" id="MathJax-Span-587"><span class="mo" id="MathJax-Span-588"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-589"><span class="mrow" id="MathJax-Span-590"><span class="mo" id="MathJax-Span-591"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-592"><span class="mrow" id="MathJax-Span-593"><span class="mo" id="MathJax-Span-594"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-595"><span class="mrow" id="MathJax-Span-596"><span class="mo" id="MathJax-Span-597"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="mo" id="MathJax-Span-598" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-599" style="font-family: STIXGeneral-Regular;">)</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 3.27em; vertical-align: -2.197em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-13">=P(X=“是高富帅”)×H(Y|X=“是高富帅”)+P(X=“不是高富帅”)×H(Y|X=“不是高富帅”)</script>
<nobr><span class="math" id="MathJax-Span-600" style="width: 25.976em; display: inline-block;"><span style="display: inline-block; position: relative; width: 20.749em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.709em 1000em 2.776em -0.424em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-601"><span class="mo" id="MathJax-Span-602" style="font-family: STIXGeneral-Regular;">=</span><span class="mn" id="MathJax-Span-603" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">5</span><span class="texatom" id="MathJax-Span-604"><span class="mrow" id="MathJax-Span-605"><span class="mo" id="MathJax-Span-606" style="font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-607" style="font-family: STIXGeneral-Regular;">100</span><span class="mo" id="MathJax-Span-608" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">×</span><span class="mn" id="MathJax-Span-609" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">0.46900</span><span class="mo" id="MathJax-Span-610" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">+</span><span class="mn" id="MathJax-Span-611" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">95</span><span class="texatom" id="MathJax-Span-612"><span class="mrow" id="MathJax-Span-613"><span class="mo" id="MathJax-Span-614" style="font-family: STIXGeneral-Regular;">/</span></span></span><span class="mn" id="MathJax-Span-615" style="font-family: STIXGeneral-Regular;">100</span><span class="mo" id="MathJax-Span-616" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">×</span><span class="mn" id="MathJax-Span-617" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">0.04741</span><span class="mo" id="MathJax-Span-618" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-619" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.06849</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.07em; vertical-align: -0.13em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-14">=5/100×0.46900+95/100×0.04741=0.06849</script>
这就是传说中的条件熵

所以,考虑特征后,标签的“不确定性的减少”为:

<nobr><span class="math" id="MathJax-Span-620" style="width: 21.016em; display: inline-block;"><span style="display: inline-block; position: relative; width: 16.803em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-621"><span class="mi" id="MathJax-Span-622" style="font-family: STIXGeneral-Italic;">I<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-623"><span class="mrow" id="MathJax-Span-624"><span class="mo" id="MathJax-Span-625"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-626" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-627" style="font-family: STIXGeneral-Regular;">,</span><span class="mi" id="MathJax-Span-628" style="font-family: STIXGeneral-Italic; padding-left: 0.216em;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-629"><span class="mrow" id="MathJax-Span-630"><span class="mo" id="MathJax-Span-631"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-632" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mi" id="MathJax-Span-633" style="font-family: STIXGeneral-Italic; padding-left: 0.323em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-634"><span class="mrow" id="MathJax-Span-635"><span class="mo" id="MathJax-Span-636"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-637" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-638"><span class="mrow" id="MathJax-Span-639"><span class="mo" id="MathJax-Span-640"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-641" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">−</span><span class="mi" id="MathJax-Span-642" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-643" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-644" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-645"><span class="mrow" id="MathJax-Span-646"><span class="mo" id="MathJax-Span-647" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="mi" id="MathJax-Span-648" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-649" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-650" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-651" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.01230</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-15"> I(Y,X)=H(Y)- H(Y|X)=0.01230 </script>
这个<nobr><span class="math" id="MathJax-Span-652" style="width: 4.696em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.736em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-653"><span class="mi" id="MathJax-Span-654" style="font-family: STIXGeneral-Italic;">I<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-655"><span class="mrow" id="MathJax-Span-656"><span class="mo" id="MathJax-Span-657"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-658" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-659" style="font-family: STIXGeneral-Regular;">,</span><span class="mi" id="MathJax-Span-660" style="font-family: STIXGeneral-Italic; padding-left: 0.216em;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-661"><span class="mrow" id="MathJax-Span-662"><span class="mo" id="MathJax-Span-663"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-16">I(Y,X)</script>就叫做平均互信息

我们用同样的方法去评价之前母亲设想的女婿只在高富帅中的理想情况(也就是女婿只在高富帅中产生的情况)的互信息<nobr><span class="math" id="MathJax-Span-664" style="width: 11.043em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.803em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-665"><span class="mi" id="MathJax-Span-666" style="font-family: STIXGeneral-Italic;">I<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-667"><span class="mrow" id="MathJax-Span-668"><span class="mo" id="MathJax-Span-669"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-670" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-671" style="font-family: STIXGeneral-Regular;">,</span><span class="msup" id="MathJax-Span-672" style="padding-left: 0.216em;"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-673" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.771em; left: 0.749em;"><span class="mo" id="MathJax-Span-674" style="font-size: 70.7%; font-family: STIXVariants;">′</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="texatom" id="MathJax-Span-675"><span class="mrow" id="MathJax-Span-676"><span class="mo" id="MathJax-Span-677"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-678" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-679" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.04470</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-17">I(Y,X’)=0.04470</script>

平均互信息从理想情况的0.04470下降到0.01230,也就是说原以为特征“是否高富帅”与标签“是否女婿”的相关性很高,后来发现相关性其实是比较低的。可见理想很丰满,现实很骨感。

8. 剧情三:白富美重定名单

其实,韩梅梅没有说出来的话是她有一个青梅竹马的码农叫李雷。她出国之前的对他的印象还不错。如果按母亲的标准李雷肯定排除在相亲名单外了,而她想给他一个机会。

这时母亲说话了:“我们家女儿考虑得挺好,那相亲名单你来定吧。”女儿说:“不是高富帅的男生也该好好区分一下,那些品行端正、气度不凡、踏实肯干的潜力股的男生我也比较欣赏,其他的就暂且不考虑了。”母亲说:“就是说可以从高富帅中挑出部分品德好的,还有从不是高帅富的男生中挑出部分潜力股,共同组成一个新的名单,我们的女婿就在这里面了?”女儿不好意思地说:“妈妈您真着急,八字还没一撇呢。”

接着,韩梅梅母女俩从高富帅中挑了2个口碑不错的,又从不是高富帅的男生中条了10个很不错的。最终组成了12人的相亲名单。李雷的名字在其中。

9. 拆分重组成为新特征

其实以上韩梅梅母女俩完成了一次特征的拆分与重组过程。具体图示如下:

特征拆分重组

这里用“潜帅德”表示韩梅梅对“品行端正、气度不凡、踏实肯干的潜力股”的特征的描述。

特征进行拆分与重组的过程在特征工程中经常出现。因为当你对特征与标签的相关性有定量的评估方法后,会筛选出那些不那么显著的特征(如本例中的“是否高富帅”),然后去分析考核指标这么低的原因,启发你引入新的特征(如本例中的“是否品德良好”、“是否有潜力”)将原有特征拆分重组,可能会有更好的效果。而这些生成的新特征,又要经过特征有效性分析来最终评估。如此反复迭代。

10. 特征有效性分析

新特征条件概率

我们用<nobr><span class="math" id="MathJax-Span-680" style="width: 1.496em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.176em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.549em 1000em 2.669em -0.531em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-681"><span class="msubsup" id="MathJax-Span-682"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-683" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-684" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">2</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.137em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-18">X_2</script>来表示新特征,与上面的思路类似,我们计算<nobr><span class="math" id="MathJax-Span-685" style="width: 1.496em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.176em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.549em 1000em 2.669em -0.531em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-686"><span class="msubsup" id="MathJax-Span-687"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-688" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-689" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">2</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.137em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-19">X_2</script>的平均互信息:

<nobr><span class="math" id="MathJax-Span-690" style="width: 22.136em; display: inline-block;"><span style="display: inline-block; position: relative; width: 17.709em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-691"><span class="mi" id="MathJax-Span-692" style="font-family: STIXGeneral-Italic;">I<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-693"><span class="mrow" id="MathJax-Span-694"><span class="mo" id="MathJax-Span-695"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-696" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-697" style="font-family: STIXGeneral-Regular;">,</span><span class="msubsup" id="MathJax-Span-698" style="padding-left: 0.216em;"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-699" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-700" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">2</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="texatom" id="MathJax-Span-701"><span class="mrow" id="MathJax-Span-702"><span class="mo" id="MathJax-Span-703"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-704" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mi" id="MathJax-Span-705" style="font-family: STIXGeneral-Italic; padding-left: 0.323em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-706"><span class="mrow" id="MathJax-Span-707"><span class="mo" id="MathJax-Span-708"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-709" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-710"><span class="mrow" id="MathJax-Span-711"><span class="mo" id="MathJax-Span-712"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-713" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">−</span><span class="mi" id="MathJax-Span-714" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-715" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-716" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-717"><span class="mrow" id="MathJax-Span-718"><span class="mo" id="MathJax-Span-719" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="msubsup" id="MathJax-Span-720"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-721" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-722" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">2</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="mo" id="MathJax-Span-723" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-724" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-725" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.03114</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-20"> I(Y,X_2)=H(Y)- H(Y|X_2)= 0.03114</script>

与之前的平均互信息<nobr><span class="math" id="MathJax-Span-726" style="width: 10.7em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.271em; height: 0px; font-size: 129%;"><span style="position: absolute; clip: rect(1.553em 1000em 2.845em -0.463em); top: -2.478em; left: 0.003em;"><span class="mrow" id="MathJax-Span-727"><span class="mi" id="MathJax-Span-728" style="font-family: STIXGeneral-Italic;">I<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.054em;"></span></span><span class="texatom" id="MathJax-Span-729"><span class="mrow" id="MathJax-Span-730"><span class="mo" id="MathJax-Span-731"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-732" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.054em;"></span></span><span class="mo" id="MathJax-Span-733" style="font-family: STIXGeneral-Regular;">,</span><span class="mi" id="MathJax-Span-734" style="font-family: STIXGeneral-Italic; padding-left: 0.209em;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.054em;"></span></span><span class="texatom" id="MathJax-Span-735"><span class="mrow" id="MathJax-Span-736"><span class="mo" id="MathJax-Span-737"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 78%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-738" style="font-family: STIXGeneral-Regular; padding-left: 0.313em;">=</span><span class="mn" id="MathJax-Span-739" style="font-family: STIXGeneral-Regular; padding-left: 0.313em;">0.01230</span></span><span style="display: inline-block; width: 0px; height: 2.483em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-21">I(Y,X)=0.01230</script>比起来,有了显著提高。可见新特征<nobr><span class="math" id="MathJax-Span-740" style="width: 1.496em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.176em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.549em 1000em 2.669em -0.531em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-741"><span class="msubsup" id="MathJax-Span-742"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-743" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-744" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">2</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.137em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-22">X_2</script>比之前的特征<nobr><span class="math" id="MathJax-Span-745" style="width: 0.909em; display: inline-block;"><span style="display: inline-block; position: relative; width: 0.696em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-746"><span class="mi" id="MathJax-Span-747" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 0.937em; vertical-align: -0.063em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-23">X</script>更有效。

11. 剧情四:韩妈妈给名单分级

在跟韩梅梅聊完之后,韩妈妈转念一想:“为什么非要有一份相亲名单?可以把这12个人再分成两类,第一类是高富帅的,先相亲。这些觉得不合适后再考虑剩下的10个人啊。”

12. 特征有效性分析

X3

我们继续分析,用<nobr><span class="math" id="MathJax-Span-748" style="width: 1.496em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.176em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.549em 1000em 2.669em -0.531em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-749"><span class="msubsup" id="MathJax-Span-750"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-751" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-752" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.137em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-24">X_3</script>来表示新特征,与上面的思路类似,我们计算<nobr><span class="math" id="MathJax-Span-753" style="width: 1.496em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.176em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.549em 1000em 2.669em -0.531em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-754"><span class="msubsup" id="MathJax-Span-755"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-756" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-757" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.137em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-25">X_3</script>的平均互信息:

<nobr><span class="math" id="MathJax-Span-758" style="width: 22.136em; display: inline-block;"><span style="display: inline-block; position: relative; width: 17.709em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-759"><span class="mi" id="MathJax-Span-760" style="font-family: STIXGeneral-Italic;">I<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-761"><span class="mrow" id="MathJax-Span-762"><span class="mo" id="MathJax-Span-763"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-764" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-765" style="font-family: STIXGeneral-Regular;">,</span><span class="msubsup" id="MathJax-Span-766" style="padding-left: 0.216em;"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-767" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-768" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="texatom" id="MathJax-Span-769"><span class="mrow" id="MathJax-Span-770"><span class="mo" id="MathJax-Span-771"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-772" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mi" id="MathJax-Span-773" style="font-family: STIXGeneral-Italic; padding-left: 0.323em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-774"><span class="mrow" id="MathJax-Span-775"><span class="mo" id="MathJax-Span-776"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-777" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-778"><span class="mrow" id="MathJax-Span-779"><span class="mo" id="MathJax-Span-780"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-781" style="font-family: STIXGeneral-Regular; padding-left: 0.269em;">−</span><span class="mi" id="MathJax-Span-782" style="font-family: STIXGeneral-Italic; padding-left: 0.269em;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-783" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-784" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-785"><span class="mrow" id="MathJax-Span-786"><span class="mo" id="MathJax-Span-787" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="msubsup" id="MathJax-Span-788"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-789" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-790" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="mo" id="MathJax-Span-791" style="font-family: STIXGeneral-Regular;">)</span><span class="mo" id="MathJax-Span-792" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-793" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.03593</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-26">I(Y,X_3)=H(Y)- H(Y|X_3)= 0.03593</script>

与之前的平均互信息<nobr><span class="math" id="MathJax-Span-794" style="width: 11.043em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.803em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-795"><span class="mi" id="MathJax-Span-796" style="font-family: STIXGeneral-Italic;">I<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-797"><span class="mrow" id="MathJax-Span-798"><span class="mo" id="MathJax-Span-799"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">(</span></span></span></span><span class="mi" id="MathJax-Span-800" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-801" style="font-family: STIXGeneral-Regular;">,</span><span class="msubsup" id="MathJax-Span-802" style="padding-left: 0.216em;"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-803" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-804" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">2</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="texatom" id="MathJax-Span-805"><span class="mrow" id="MathJax-Span-806"><span class="mo" id="MathJax-Span-807"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">)</span></span></span></span><span class="mo" id="MathJax-Span-808" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mn" id="MathJax-Span-809" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">0.03114</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-27">I(Y,X_2)=0.03114</script>比起来,又有了一定的提高。可见新特征<nobr><span class="math" id="MathJax-Span-810" style="width: 1.496em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.176em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.549em 1000em 2.669em -0.531em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-811"><span class="msubsup" id="MathJax-Span-812"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-813" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-814" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.137em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-28">X_3</script>比之前的特征<nobr><span class="math" id="MathJax-Span-815" style="width: 1.496em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.176em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.549em 1000em 2.669em -0.531em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-816"><span class="msubsup" id="MathJax-Span-817"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-818" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-819" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">2</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.137em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-29">X_2</script>更有效。

韩妈妈真是为女儿的相亲操碎了心。

13. 剧情五:韩妈妈问计赵媒婆

韩妈妈思索完之后抑制不住内心的兴奋,想找人倾诉。这时她正好在路上碰见了赵媒婆。赵媒婆在韩妈妈的老闺蜜圈中享有盛誉,相亲非常有经验。

赵媒婆听了韩妈妈的诉说后,微微一笑,说:“你这个名单不够专业。”韩妈妈大为诧异。赵媒婆继续说:“高、富、帅三个特征本来就是相互独立的三个特征,你硬生生地绑在一起,多少大好青年被你给甩掉了。后面的潜力股啊、人品端正啊什么的都类似。”韩妈妈恍然大悟:“真是这样啊。”

赵媒婆说:“其实你这里最大的问题是这些特征的评估都是拍脑袋决定,没有充分的现实数据做支撑,很可能会犯错误的。”韩妈妈暗暗点头,心生佩服。

赵媒婆接着说:“还有一个问题,你准备了两份名单,也就是把人群分成了三份,你算平均互信息只能评价整体的,具体到每一份人群你怎么对他们评价?”韩妈妈想了想,说:“我们可以直接用相对于某个具体条件的信息熵啊。”赵媒婆说:“何苦这么麻烦呢?”

韩妈妈听她话里有话,打算继续问下去。

14. 评价特征选项的两个方法

在赵媒婆最后一个问题中,韩妈妈所说的其实是可以计算以下三个值来评估具体的特征选项:

  • <nobr><span class="math" id="MathJax-Span-820" style="width: 11.043em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.803em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-821"><span class="mi" id="MathJax-Span-822" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-823" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-824" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-825"><span class="mrow" id="MathJax-Span-826"><span class="mo" id="MathJax-Span-827" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="msubsup" id="MathJax-Span-828"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-829" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-830" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="mo" id="MathJax-Span-831" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-832" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-833"><span class="mrow" id="MathJax-Span-834"><span class="mo" id="MathJax-Span-835"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-836"><span class="mrow" id="MathJax-Span-837"><span class="mo" id="MathJax-Span-838"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-839"><span class="mrow" id="MathJax-Span-840"><span class="mo" id="MathJax-Span-841"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="texatom" id="MathJax-Span-842"><span class="mrow" id="MathJax-Span-843"><span class="mo" id="MathJax-Span-844"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">德</span></span></span></span><span class="mo" id="MathJax-Span-845" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-846" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-30">H(Y|X_3=“高富帅德”)</script>
  • <nobr><span class="math" id="MathJax-Span-847" style="width: 10.029em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.003em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-848"><span class="mi" id="MathJax-Span-849" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-850" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-851" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-852"><span class="mrow" id="MathJax-Span-853"><span class="mo" id="MathJax-Span-854" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="msubsup" id="MathJax-Span-855"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-856" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-857" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="mo" id="MathJax-Span-858" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-859" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-860"><span class="mrow" id="MathJax-Span-861"><span class="mo" id="MathJax-Span-862"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">潜</span></span></span></span><span class="texatom" id="MathJax-Span-863"><span class="mrow" id="MathJax-Span-864"><span class="mo" id="MathJax-Span-865"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="texatom" id="MathJax-Span-866"><span class="mrow" id="MathJax-Span-867"><span class="mo" id="MathJax-Span-868"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">德</span></span></span></span><span class="mo" id="MathJax-Span-869" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-870" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-31">H(Y|X_3= “潜帅德”)</script>
  • <nobr><span class="math" id="MathJax-Span-871" style="width: 19.043em; display: inline-block;"><span style="display: inline-block; position: relative; width: 15.203em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.603em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-872"><span class="mi" id="MathJax-Span-873" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-874" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-875" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="texatom" id="MathJax-Span-876"><span class="mrow" id="MathJax-Span-877"><span class="mo" id="MathJax-Span-878" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="msubsup" id="MathJax-Span-879"><span style="display: inline-block; position: relative; width: 1.123em; height: 0px;"><span style="position: absolute; clip: rect(1.763em 1000em 2.723em -0.531em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-880" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.643em;"><span class="mn" id="MathJax-Span-881" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span><span class="mo" id="MathJax-Span-882" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">=</span><span class="mo" id="MathJax-Span-883" style="font-family: STIXGeneral-Regular; padding-left: 0.323em;">“</span><span class="texatom" id="MathJax-Span-884"><span class="mrow" id="MathJax-Span-885"><span class="mo" id="MathJax-Span-886"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">不</span></span></span></span><span class="texatom" id="MathJax-Span-887"><span class="mrow" id="MathJax-Span-888"><span class="mo" id="MathJax-Span-889"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-890"><span class="mrow" id="MathJax-Span-891"><span class="mo" id="MathJax-Span-892"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">高</span></span></span></span><span class="texatom" id="MathJax-Span-893"><span class="mrow" id="MathJax-Span-894"><span class="mo" id="MathJax-Span-895"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">富</span></span></span></span><span class="texatom" id="MathJax-Span-896"><span class="mrow" id="MathJax-Span-897"><span class="mo" id="MathJax-Span-898"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="texatom" id="MathJax-Span-899"><span class="mrow" id="MathJax-Span-900"><span class="mo" id="MathJax-Span-901"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">德</span></span></span></span><span class="texatom" id="MathJax-Span-902"><span class="mrow" id="MathJax-Span-903"><span class="mo" id="MathJax-Span-904"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">且</span></span></span></span><span class="texatom" id="MathJax-Span-905"><span class="mrow" id="MathJax-Span-906"><span class="mo" id="MathJax-Span-907"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">不</span></span></span></span><span class="texatom" id="MathJax-Span-908"><span class="mrow" id="MathJax-Span-909"><span class="mo" id="MathJax-Span-910"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">是</span></span></span></span><span class="texatom" id="MathJax-Span-911"><span class="mrow" id="MathJax-Span-912"><span class="mo" id="MathJax-Span-913"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">潜</span></span></span></span><span class="texatom" id="MathJax-Span-914"><span class="mrow" id="MathJax-Span-915"><span class="mo" id="MathJax-Span-916"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">帅</span></span></span></span><span class="texatom" id="MathJax-Span-917"><span class="mrow" id="MathJax-Span-918"><span class="mo" id="MathJax-Span-919"><span style="font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 80%; font-style: normal; font-weight: normal;">德</span></span></span></span><span class="mo" id="MathJax-Span-920" style="font-family: STIXGeneral-Regular;">”</span><span class="mo" id="MathJax-Span-921" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-32">H(Y|X_3= “不是高富帅德且不是潜帅德”)</script>

而这三个值在之前计算条件熵<nobr><span class="math" id="MathJax-Span-922" style="width: 4.344em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.362em; height: 0px; font-size: 129%;"><span style="position: absolute; clip: rect(1.656em 1000em 2.793em -0.463em); top: -2.478em; left: 0.003em;"><span class="mrow" id="MathJax-Span-923"><span class="mi" id="MathJax-Span-924" style="font-family: STIXGeneral-Italic;">H<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.054em;"></span></span><span class="mo" id="MathJax-Span-925" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-926" style="font-family: STIXGeneral-Italic;">Y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.054em;"></span></span><span class="texatom" id="MathJax-Span-927"><span class="mrow" id="MathJax-Span-928"><span class="mo" id="MathJax-Span-929" style="font-family: STIXGeneral-Regular;">|</span></span></span><span class="msubsup" id="MathJax-Span-930"><span style="display: inline-block; position: relative; width: 1.088em; height: 0px;"><span style="position: absolute; clip: rect(1.656em 1000em 2.638em -0.514em); top: -2.478em; left: 0.003em;"><span class="mi" id="MathJax-Span-931" style="font-family: STIXGeneral-Italic;">X<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.054em;"></span></span><span style="display: inline-block; width: 0px; height: 2.483em;"></span></span><span style="position: absolute; top: -2.168em; left: 0.623em;"><span class="mn" id="MathJax-Span-932" style="font-size: 70.7%; font-family: STIXGeneral-Regular;">3</span><span style="display: inline-block; width: 0px; height: 2.328em;"></span></span></span></span><span class="mo" id="MathJax-Span-933" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.483em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.27em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-33">H(Y|X_3)</script>的过程中就已经计算出来了。所以比较起来应该很方便。

其实更简单的方法用他们相对于所需要标签的后验概率评价。如下图红色的部分,比较大小就可以找出评价较好的特征。

X3

显然“高富帅德”的评分最高(0.25),“潜帅德”的评分次之(0.05),“不是高富帅德且不是潜帅德”评分最差(0)。符合韩妈妈的预期。

然而,赵媒婆的想说的并不是这种方法,而是逻辑回归……

15. 剧情六:赵媒婆的数据库

赵媒婆不等韩妈妈说话,就直接拿出了自己的神器:一个平板电脑。然后打开她的相亲数据库,点了点鼠标,一张巨大的表展现出来。韩妈妈目瞪口呆:“现在媒婆都用高科技了?”赵媒婆傲娇地说:“那是。”

这张大表是她这么多年来全国各地相亲介绍的所有男生信息,分别标注了每个男生的升高、年龄、年薪、长相特点、教育经历、工作经历、是否海归、工作年限、工作公司、工作地点、出身地、是否有户口、是否公务员、具体职业、行业、性格倾向等等信息。

她还有一张女生信息表,另外一张男生女生相亲情况表(相亲成功、相亲不成、继续发展、未接触)。媒婆一一给韩妈妈解释这些信息。韩妈妈连连惊呼。

赵媒婆接着说道:“我们可以从里面找出跟你女儿情况相近的一些女生信息,再把跟她们相过亲的男生找出来,把其中相亲成功的归为一类,剩下的归为另一类。然后假设男生的每个特征对相亲成功都有贡献,贡献的权重为<nobr><span class="math" id="MathJax-Span-934" style="width: 1.283em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.016em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.763em 1000em 2.669em -0.477em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-935"><span class="msubsup" id="MathJax-Span-936"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.723em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-937" style="font-family: STIXGeneral-Italic;">w</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.696em;"><span class="mi" id="MathJax-Span-938" style="font-size: 70.7%; font-family: STIXGeneral-Italic;">i</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 0.87em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-34">w_i</script>。我们用逻辑回归的方法可以求出这些权重,把这些权重大的特征挑出来,你再用它们来找女婿就方便了。”

韩妈妈说:“逻~辑~什么?”赵媒婆说:“高科技了,你不懂的。不过给我干儿子写了个博客来介绍,你可以看看。”

16. 特征筛选与特征工程工作流

呃,我们什么时候成赵媒婆的干儿子了?先不管这些。逻辑回归并不是什么高科技,在前面的文章里已有简单的解释。我们在这里就补充说明一下为什么可以用权重来衡量特征的贡献。以下是一个典型的逻辑回归过程:

逻辑回归

我们期望<nobr><span class="math" id="MathJax-Span-939" style="width: 2.136em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.709em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.709em 1000em 2.883em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-940"><span class="mi" id="MathJax-Span-941" style="font-family: STIXGeneral-Italic;">P</span><span class="mo" id="MathJax-Span-942" style="font-family: STIXGeneral-Regular;">(</span><span class="mi" id="MathJax-Span-943" style="font-family: STIXGeneral-Italic;">z</span><span class="mo" id="MathJax-Span-944" style="font-family: STIXGeneral-Regular;">)</span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.203em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-35">P(z)</script>的概率越大越好,<nobr><span class="math" id="MathJax-Span-945" style="width: 4.109em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.256em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.709em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mrow" id="MathJax-Span-946"><span class="mi" id="MathJax-Span-947" style="font-family: STIXGeneral-Italic;">s</span><span class="mi" id="MathJax-Span-948" style="font-family: STIXGeneral-Italic;">i</span><span class="mi" id="MathJax-Span-949" style="font-family: STIXGeneral-Italic;">g</span><span class="mi" id="MathJax-Span-950" style="font-family: STIXGeneral-Italic;">m</span><span class="mi" id="MathJax-Span-951" style="font-family: STIXGeneral-Italic;">o</span><span class="mi" id="MathJax-Span-952" style="font-family: STIXGeneral-Italic;">i</span><span class="mi" id="MathJax-Span-953" style="font-family: STIXGeneral-Italic;">d<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.27em; vertical-align: -0.33em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-36">sigmoid</script>函数是个单调递增函数,所以z越大越好,在所有特征都归一化的前提下,显然是权重<nobr><span class="math" id="MathJax-Span-954" style="width: 1.295em; display: inline-block;"><span style="display: inline-block; position: relative; width: 0.984em; height: 0px; font-size: 129%;"><span style="position: absolute; clip: rect(1.656em 1000em 2.587em -0.463em); top: -2.271em; left: 0.003em;"><span class="mrow" id="MathJax-Span-955"><span class="msubsup" id="MathJax-Span-956"><span style="display: inline-block; position: relative; width: 0.933em; height: 0px;"><span style="position: absolute; clip: rect(1.863em 1000em 2.638em -0.463em); top: -2.478em; left: 0.003em;"><span class="mi" id="MathJax-Span-957" style="font-family: STIXGeneral-Italic;">w</span><span style="display: inline-block; width: 0px; height: 2.483em;"></span></span><span style="position: absolute; top: -2.168em; left: 0.674em;"><span class="mi" id="MathJax-Span-958" style="font-size: 70.7%; font-family: STIXGeneral-Italic;">i</span><span style="display: inline-block; width: 0px; height: 2.328em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.276em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 0.937em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-37">w_i</script>越大越好。因此与<nobr><span class="math" id="MathJax-Span-959" style="width: 1.283em; display: inline-block;"><span style="display: inline-block; position: relative; width: 1.016em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.763em 1000em 2.669em -0.477em); top: -2.344em; left: 0.003em;"><span class="mrow" id="MathJax-Span-960"><span class="msubsup" id="MathJax-Span-961"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.723em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-962" style="font-family: STIXGeneral-Italic;">w</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.237em; left: 0.696em;"><span class="mi" id="MathJax-Span-963" style="font-size: 70.7%; font-family: STIXGeneral-Italic;">i</span><span style="display: inline-block; width: 0px; height: 2.403em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 0.87em; vertical-align: -0.263em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-38">w_i</script>对应的特征就是我们要寻找的显著特征。而那些权重小的特征就可以先不考虑了。这就完成了一个最简单的特征筛选的过程。

当然,这里所说的权重大可以指的是权重的绝对值很大,比如特征“富”的权重是-100,是一个很小的数,但这也就意味着“不富”的权重会很大,以至于显著影响我们的z的结果。所以这也是一个显著特征。

需要补充一下的是,在工程实践中,权重的幅度和正则化也有关系。L1正则化会把特征拉稀疏,会产出一部分0特征。而不是0的那些特征,是有作用的特征。所以L1正则化其实具备一定的特征选择(feature selection)的作用。尤其是很高维空间的feature,用L1正则化,其实能帮助做一下feature selection的。而L2正则化,则会把各个维度的权重拉平均一些,抑制住各个维度权重幅度的方差。但是抑制归抑制,最后的权重还是会有大小差异,就像上文说的,绝对值大的权重,对应的特征区分度好一些。

对于那些不够显著的特征,我们需要分析一下这个特征的具体情况是怎样,是否需要对其进行重新拆分与重组,拆分重组后新的特征又可以进行特征有效性分析。如此不断迭代反复,就可以挑选出比较理想的特征了。

我们用以下整个工作流大致展现这个过程。由于很多内容没有展开,我们先把名字写进去,在后续的文章中继续扩展。
工作流

17. 剧情七:韩妈妈新名单尘埃落定

在韩妈妈与赵媒婆的尽心鼓捣下,最终生成了一个只有4个人的相亲名单。其中只剩下一名高富帅,另外三人中有一人正是李雷。韩妈妈拿着新名单给女儿看,韩梅梅沉默半晌,心想李雷在四人名单中怎么也能存在,莫非这也是缘分?

18. 小结

本文中主要讲了一些特征有效性分析的方法,包括用互信息,平均互信息,条件熵,后验概率,逻辑回归权重等方法对特征与标签的相关性进行了评估。有了这些评估做基础,可以筛选出显著的特征,并对对不显著的特征进行分析、拆分和重组,最终形成新的特征并反复迭代。本文略过了一些特征预处理的方法,并对特征有效性评估的阐述不够充分,我们将在接下来的文章中予以讨论。

<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics