<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>0.Blog</title>
        <link>https://www.duanyc.xyz//</link>
        <description>这是一个由NotionNext生成的站点</description>
        <lastBuildDate>Wed, 07 Oct 2026 09:16:50 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en-US</language>
        <copyright>All rights reserved 2026, DDDBlog</copyright>
        <item>
            <title><![CDATA[统计知识总结(一)]]></title>
            <link>https://www.duanyc.xyz//统计学/1a4979dd-ee53-80b1-85dd-f0f6dd6057b2</link>
            <guid>https://www.duanyc.xyz//统计学/1a4979dd-ee53-80b1-85dd-f0f6dd6057b2</guid>
            <pubDate>Mon, 24 Feb 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1a4979ddee5380b185ddf0f6dd6057b2"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1a4979ddee53801f8dfee5322426ec8f" data-id="1a4979ddee53801f8dfee5322426ec8f"><span><div id="1a4979ddee53801f8dfee5322426ec8f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1a4979ddee53801f8dfee5322426ec8f" title="概率"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">概率</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1b7979ddee5380d4907bf863ee9743ab" data-id="1b7979ddee5380d4907bf863ee9743ab"><span><div id="1b7979ddee5380d4907bf863ee9743ab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b7979ddee5380d4907bf863ee9743ab" title="条件概率"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">条件概率</span></span></h3><div class="notion-text notion-block-1b7979ddee5380a7a65ef4e2c28c64e3">设A与B是样本空间 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的两事件。若 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,则称为在B发生下A的条件概率</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b7979ddee53804fb818fb735a99c9e9"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:429.9999694824219px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A21127361-59c4-4801-934d-1dacd77fdc99%3Aimage.png?table=block&amp;id=1b7979dd-ee53-804f-b818-fb735a99c9e9&amp;t=1b7979dd-ee53-804f-b818-fb735a99c9e9" alt="notion image" loading="lazy" decoding="async"/></div></figure><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1b7979ddee5380f7957bfc7015f9770a" data-id="1b7979ddee5380f7957bfc7015f9770a"><span><div id="1b7979ddee5380f7957bfc7015f9770a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b7979ddee5380f7957bfc7015f9770a" title="全概率公式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">全概率公式</span></span></h3><div class="notion-text notion-block-1b7979ddee5380858001c35bbd31146c">设 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为样本空间 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的一个分割，即 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>互不相容，且 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,如果 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,则对任一事件A有</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1b7979ddee53800186c6fb9ca86e5c1c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:489.006103515625px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A157303c0-2a70-457e-9b99-379ff0bf563e%3Aimage.png?table=block&amp;id=1b7979dd-ee53-8001-86c6-fb9ca86e5c1c&amp;t=1b7979dd-ee53-8001-86c6-fb9ca86e5c1c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1b7979ddee5380bbaa9bd74c53dd2e1d">因为 </div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1b7979ddee5380f0acfaf5f48ec90ca9">且 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>互不相容，所以由可加性得</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1b7979ddee53805d9959fcbb910760ca">再将 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1b7979ddee538005aa41d8f622deb588">满足0&lt;P(B)&lt;1,最简单得全概率公式为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1b8979ddee5380ecade8ddfed47f938e" data-id="1b8979ddee5380ecade8ddfed47f938e"><span><div id="1b8979ddee5380ecade8ddfed47f938e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b8979ddee5380ecade8ddfed47f938e" title="贝叶斯公式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">贝叶斯公式</span></span></h3><div class="notion-text notion-block-1b8979ddee53808c9d99cdeae6baa200">设 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为样本空间 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的一个分割，即 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>互不相容，且 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,如果P(A)&gt;0 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,则</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1b8979ddee538036bc38edfd6dddfa35" data-id="1b8979ddee538036bc38edfd6dddfa35"><span><div id="1b8979ddee538036bc38edfd6dddfa35" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b8979ddee538036bc38edfd6dddfa35" title="随机变量及其分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">随机变量及其分布</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1bd979ddee5380749f7bd727dff6db7f" data-id="1bd979ddee5380749f7bd727dff6db7f"><span><div id="1bd979ddee5380749f7bd727dff6db7f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bd979ddee5380749f7bd727dff6db7f" title="分布函数"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">分布函数</span></span></h3><div class="notion-text notion-block-1bd979ddee53809d8cc4f7d9e69a3050">设<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是一个随机变量，对任意实数<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,称</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1bd979ddee53802d9c27c5a98a384c80">为随机变量<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的分布函数，且称<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>服从<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,记为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>.有时间也可用 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>以表明是X的分布函数</div><div class="notion-blank notion-block-1bd979ddee5380fb9e2cc4cf50ddf71e"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1bd979ddee5380ddaddef8b3ef8dbb7a" data-id="1bd979ddee5380ddaddef8b3ef8dbb7a"><span><div id="1bd979ddee5380ddaddef8b3ef8dbb7a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bd979ddee5380ddaddef8b3ef8dbb7a" title="连续随机变量的概率密度函数"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">连续随机变量的概率密度函数</span></span></h3><div class="notion-text notion-block-1bd979ddee5380d09d34d73cbe58ad2d">一切可能取值充满某个区间 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，而在这个区间内有无穷不可列个实数，因此这类随机变量的概率分布不能再用分布列形式表示，而要改用概率密度函数表示。</div><div class="notion-text notion-block-1bd979ddee5380a5a10ac73bb6d8934d">概率密度函数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的值虽不是概率，但乘微分元dx就可得小区间 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>上概率的近似值，即</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1bd979ddee5380a1b869c849c8c494ad">即 </div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1bd979ddee5380d4a8dbd7f69827af9d">在 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>上<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的积分就是分布函数<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，即</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1bd979ddee53802e8c84f81f39bdcde7">设随机变量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的分布函数为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，如果存在实数轴上的一个非负可积函数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,使得对任意实数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>有</div><div class="notion-text notion-block-1bd979ddee5380b0894af9541aa1b7f9">  </div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1bd979ddee5380b48092ea9e319c3b23">则称 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的概率密度函数，简称为密度函数或密度．同时称<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为连续随机变呈，称
 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为连续分布函数。</div><div class="notion-blank notion-block-1bd979ddee538008b739f623c0730e8c"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1bd979ddee538049bd0edc8bb4a0b513" data-id="1bd979ddee538049bd0edc8bb4a0b513"><span><div id="1bd979ddee538049bd0edc8bb4a0b513" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bd979ddee538049bd0edc8bb4a0b513" title="随机变量的期望、方差、标准差"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">随机变量的期望、方差、标准差</span></span></h3><div class="notion-text notion-block-1bd979ddee5380168832fe27547ef45a"> 设离散随机变量X的分布列为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1bd979ddee538072a247fc23b1ac4a02">如果</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1bd979ddee53809cb72de9d83e421671">则</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-1ed979ddee5380cbb8b0ea751c0c1a3a"> </div><div class="notion-text notion-block-1ed979ddee53808b813df455cec9245d">如果随机变量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的数学期望 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>存在，则称偏差平方 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的数学期望 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为随机变量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的方差</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee5380c3af7bc74a62fcb9c7">方差的平方根记为标准差</div><ul class="notion-list notion-list-disc notion-block-1ed979ddee53803896fffeb7c2a40baa"><li>方差的性质</li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee5380f18281fd07245e12c8">常数方差为0，若 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是常数，则 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1ed979ddee5380bf88a7e271a4755c41"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1ed979ddee53803c8ef0d05630b7a3f0" data-id="1ed979ddee53803c8ef0d05630b7a3f0"><span><div id="1ed979ddee53803c8ef0d05630b7a3f0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ed979ddee53803c8ef0d05630b7a3f0" title="常用的离散分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">常用的离散分布</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ed979ddee5380039309f6e6b3145237" data-id="1ed979ddee5380039309f6e6b3145237"><span><div id="1ed979ddee5380039309f6e6b3145237" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ed979ddee5380039309f6e6b3145237" title="二项分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二项分布</span></span></h4><div class="notion-text notion-block-1ed979ddee538058a96ecbd92eaeb323">记<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>重伯努利实验中成功(记为事件A)的次数，则 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的可能取值为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,记<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为每次试验中<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>发生的概率，即 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1ed979ddee53804297cbdbbf3c2a01ff">如抛硬币实验，每次抛硬币正面朝上的概率为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,反面朝上概率为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,实验n次，证明朝上k次的概率</div><div class="notion-text notion-block-1ed979ddee5380db842dc9ce2c091464">n重伯努利试验的基本结果可以记作:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee5380a4a390eb407e637ae1">事件发生<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>次的概率为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee538064913ec5e3aea0574c">这个分布就称为二项分布，记为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1ed979ddee53800abe89c5c4168b6326">二项分布除抛硬币例子外，还有如:</div><ul class="notion-list notion-list-disc notion-block-1ed979ddee5380d8ba68f98deb3e3562"><li>检查10件产品，10件产品不合格品的个数X服从二项分布 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,其中<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为不合格率</li></ul><div class="notion-blank notion-block-1ed979ddee5380119058f5569760f1c5"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ed979ddee5380e7a004ce9645581f71" data-id="1ed979ddee5380e7a004ce9645581f71"><span><div id="1ed979ddee5380e7a004ce9645581f71" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ed979ddee5380e7a004ce9645581f71" title="0-1分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">0-1分布</span></span></h4><div class="notion-text notion-block-1ed979ddee5380e5a606f2c6f6b5592d">n=1时的二项分布<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>就称为0-1分布，或伯努利分布</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-1ed979ddee538093a2fdef3901c3ad1e"> </div><ul class="notion-list notion-list-disc notion-block-1ed979ddee538094aca9d1fab86513e5"><li>二项分布的数学期望和方差</li></ul><div class="notion-text notion-block-1ed979ddee5380668cb1e8c60f21fd42">设随机变量<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee5380e2bbcfeab3a193ef62">因为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>, <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1ed979ddee5380e7b50cedf1b3210318">即 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee5380c99fd3d73a29d13d32">其方差为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1ed979ddee538095a394d5304509841d"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ed979ddee53804189afcb4915b71100" data-id="1ed979ddee53804189afcb4915b71100"><span><div id="1ed979ddee53804189afcb4915b71100" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ed979ddee53804189afcb4915b71100" title="泊松分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">泊松分布</span></span></h4><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee5380ea810ee8b270b513be">其中参数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,记为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1ed979ddee538052a1afc8c4e02a6c01">泊松分布是一种常用的离散分布，它常与单位时间（或单位面积、单位产品等 ）上
的计数过程相联系，譬如:</div><ul class="notion-list notion-list-disc notion-block-1ed979ddee538011b857ca6c0b3a6e08"><li>在一天内，来到某商场的顾客数</li></ul><ul class="notion-list notion-list-disc notion-block-1ed979ddee538007898ff43d81174f28"><li>某地区某一时间间隔内发生交通事故的次数</li></ul><div class="notion-text notion-block-1ed979ddee5380c1bcdcfff42aab844f">其期望方差均为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1ed979ddee5380719feac50e3d2cf652"> </div><div class="notion-text notion-block-1ed979ddee5380718b14f4d7c57aae4d">泊松分布有一个非常实用的特性，即可以用泊松分布作为二项分布的一种近似。在二项分布 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中，当n较大时计算比较麻烦。当n较大且p较小时可以使用泊松定理来减少二项分布的计算</div><div class="notion-text notion-block-1ee979ddee538002ae25f8b3e089a712"><b>泊松定理</b>在n重伯努利试验中，记事件A在一次试验中发生的概率为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>与试验次数有关，如果当 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>时，有 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,则:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ed979ddee5380508bf5e14b0a2227de">由于泊松定理是在 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>条件下获得的，故计算二项分布 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>时，当n很大，p很小，而乘积 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>大小适中时，可以用泊松分布做近似，即:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-1ee979ddee538060b09be3d891210322"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ee979ddee5380f081e3ccc1adcd8092" data-id="1ee979ddee5380f081e3ccc1adcd8092"><span><div id="1ee979ddee5380f081e3ccc1adcd8092" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ee979ddee5380f081e3ccc1adcd8092" title="超几何分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">超几何分布</span></span></h4><div class="notion-text notion-block-1ee979ddee5380908b6cc8ec67963d2e">从一个有限总体中进行不放回抽样常会遇到超几何分布</div><div class="notion-text notion-block-1ee979ddee538036814bfaf9effbb6d3">设有<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>件产品，其中有 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>件不合格品，若从中不放回地随机抽取<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>件，其中含有的不合格品的件数<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>服从超几何分布，记为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。超几个分布的概率分布列为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ee979ddee5380fe9c08f9543215763f">其期望为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,方差为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1ee979ddee538098b619f9b5dbdc5539"> </div><div class="notion-text notion-block-1ee979ddee5380eba84beed7275779c1">当 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>时，即抽样个数<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>远小于产品总数<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>时，每次抽取后，总体中的不合格品率 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>改变很小，所以不放回抽样可近似看成放回抽样，这时超几何分布可以用二项分布近似</div><div class="notion-blank notion-block-1ee979ddee53809f926eecf18f85a26c"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ee979ddee5380adb544e753391dc62d" data-id="1ee979ddee5380adb544e753391dc62d"><span><div id="1ee979ddee5380adb544e753391dc62d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ee979ddee5380adb544e753391dc62d" title="几何分布与负二项分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">几何分布与负二项分布</span></span></h4><div class="notion-text notion-block-1ee979ddee5380b08978ecf073aa538c">在伯努利试验序列中，记每次试验中事件<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>发生的概率为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,如果<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为事件<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>首次出现的试验次数，则 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的可能取值为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 称<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>服从几何分布，记为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ee979ddee53806faa04d51edac9cc98">如</div><ul class="notion-list notion-list-disc notion-block-1ee979ddee538027bd95df5cd273118a"><li>某产品不合格率为0.05，则首次查到不合格率的检查次数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><ul class="notion-list notion-list-disc notion-block-1ee979ddee53809aa455ed8f349a2a64"><li>掷一颗骰子，首次出现6点投掷次数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><div class="notion-text notion-block-1ee979ddee538021a459e798dd0aba76">其数学期望为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,方差为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1ee979ddee538055946dfdde5a5fa45e"> </div><div class="notion-text notion-block-1ee979ddee53800a91a5d9d0443c517e">几何分布具有无记忆性</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ee979ddee53805994a3ec9105df91db">比如说在一系列伯努利试验序列中，若首次成功(A)出现的试验次数<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>服从几何分布，则事件记为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示前<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>次试验中A没有出现。假如在接下去的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>次试验中A仍未出现，这个事件记为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>.</div><div class="notion-text notion-block-1ee979ddee538046968bf1760efb7c89">该定理表明：在前m次试验中A没有出现的条件下，在接下去的n次试验中A仍未出现的概率只与n有关 ，而与以前的m次试验 无关，似乎忘记了前m次试验结果，这就是无记忆性</div><div class="notion-blank notion-block-1ee979ddee5380d98032c7b79842ddff"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1ee979ddee5380df9ce5d80e61b517cd" data-id="1ee979ddee5380df9ce5d80e61b517cd"><span><div id="1ee979ddee5380df9ce5d80e61b517cd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ee979ddee5380df9ce5d80e61b517cd" title="常用连续分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">常用连续分布</span></span></h3><div class="notion-blank notion-block-1ee979ddee5380f4978dfb42ad04590c"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ee979ddee5380829da2c61dff515fc0" data-id="1ee979ddee5380829da2c61dff515fc0"><span><div id="1ee979ddee5380829da2c61dff515fc0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ee979ddee5380829da2c61dff515fc0" title="正态分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">正态分布</span></span></h4><div class="notion-text notion-block-1ee979ddee5380fbbd60debcf4570b12">概率密度函数</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ee979ddee538024a3bdd9e78a9ede70">则称<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>服从正态分布，称<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为正态变量，记<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1ee979ddee53804a9541cbe31de7a3a2">其分布函数为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ee979ddee5380ab8b84e83c957d96be"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>时的正态分布 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为标准正态分布，其密度函数为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,分数函数为<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span><span style="padding:0.5em"></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-1ee979ddee538038950fc9e7dbd4479d"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ee979ddee538036a109e1e21b4d2226" data-id="1ee979ddee538036a109e1e21b4d2226"><span><div id="1ee979ddee538036a109e1e21b4d2226" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ee979ddee538036a109e1e21b4d2226" title="均匀分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">均匀分布</span></span></h4><div class="notion-text notion-block-1ee979ddee53807ea2ecf52b8e100f28">记作 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1ee979ddee538011b274c5de0cdc93d5">均值为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,方差为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1ee979ddee538071aa9bfadb4cfe6a43"> </div><h4 class="notion-h notion-h3 notion-h-indent-2 notion-block-1ee979ddee5380b9b432cc973cfc7a2b" data-id="1ee979ddee5380b9b432cc973cfc7a2b"><span><div id="1ee979ddee5380b9b432cc973cfc7a2b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1ee979ddee5380b9b432cc973cfc7a2b" title="指数分布"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">指数分布</span></span></h4><div class="notion-text notion-block-1ee979ddee5380a093b4d28219e7a4eb">其概率密度函数为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ee979ddee53809ebc7edb08673ecc81">其分布函数为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1ee979ddee538068b9d4c8fc0112b95b">其期望为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,方差为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1ee979ddee5380ca8cd9c7c715a2f3db">其他分布有gamma分布、贝塔分布、卡方分布、柯西分布等。</div><div class="notion-blank notion-block-1ee979ddee5380cd87d0cede42b10a3d"> </div><div class="notion-blank notion-block-1ee979ddee53800aaad7dfd13984c7d1"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[因果推断入门-2]]></title>
            <link>https://www.duanyc.xyz//1f1979dd-ee53-8054-b884-f4906c57dc7d</link>
            <guid>https://www.duanyc.xyz//1f1979dd-ee53-8054-b884-f4906c57dc7d</guid>
            <pubDate>Mon, 12 May 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1f1979ddee538054b884f4906c57dc7d"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f1979ddee5380af961ff1868761d41a" data-id="1f1979ddee5380af961ff1868761d41a"><span><div id="1f1979ddee5380af961ff1868761d41a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f1979ddee5380af961ff1868761d41a" title="结构因果模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结构因果模型</span></span></h2><div class="notion-text notion-block-1f1979ddee5380908654df559af60ff3">如果<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是导致 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的原因，记作 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1f3979ddee53806b8a61e2bab204219f">有时产生结果的因素不止<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,则有 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1f3979ddee53803ba4fff09f7e1a8fd6">当X不是导致Y结果的直接因素时，则有 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1f3979ddee538066997adb2963f4d143">或记为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1f3979ddee538057bfced58dc53d1bba"> </div><ul class="notion-list notion-list-disc notion-block-1f3979ddee5380cc964cfb91055c2de7"><li>X是导致Y的原因</li></ul><div class="notion-blank notion-block-1f3979ddee538084a44ce291986f809a"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f3979ddee538025bf4ed0addd8321fc"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:445px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A9b77bc83-e6cc-461d-be43-c3fa78773be7%3Aimage.png?table=block&amp;id=1f3979dd-ee53-8025-bf4e-d0addd8321fc&amp;t=1f3979dd-ee53-8025-bf4e-d0addd8321fc" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1f3979ddee538032b076dc83ebef0281"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><ul class="notion-list notion-list-disc notion-block-1f3979ddee538067b2bbf3be7c5f32b3"><li>导致Y的原因有两个 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f3979ddee5380618575ed9f493ae0a8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:485px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Afa09b35e-024a-45d8-a1f5-53af67e37736%3Aimage.png?table=block&amp;id=1f3979dd-ee53-8061-8575-ed9f493ae0a8&amp;t=1f3979dd-ee53-8061-8575-ed9f493ae0a8" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1f3979ddee5380e2a202f515c908e005"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1f3979ddee5380b29387f222c820ebbc">其他同理</div><div class="notion-text notion-block-1f3979ddee5380ce97d0d240d8fea2c1">下面看一个例子</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f4979ddee53808296abf1652462fe35"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A672a47d1-673b-4d97-b11f-c1c6c31529b3%3Aimage.png?table=block&amp;id=1f4979dd-ee53-8082-96ab-f1652462fe35&amp;t=1f4979dd-ee53-8082-96ab-f1652462fe35" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1f4979ddee53800c96e7ee3c59fd05d4">U是外生变量，V是内生变量，边的关系就由<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>刻画</div><div class="notion-text notion-block-1f4979ddee5380cca59efa6d24389f70">内生变量是外生变量的子节点，外生变量没有任何子节点</div><div class="notion-text notion-block-1f4979ddee5380a4a359e554354956fe">比如说出去找工作，工资和受教育程度及经验有关</div><div class="notion-text notion-block-1f4979ddee5380b49c2af0971b4474b5">外生变量集合为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>教育程度， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为经验</div><div class="notion-text notion-block-1f4979ddee5380868e19eb31fa55ff4c">内生变量集合为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,表示的是薪资</div><div class="notion-text notion-block-1f4979ddee5380ce9b97c6f12b93d700">内生变量和外生变量之间的关系为</div><div class="notion-text notion-block-1f4979ddee53803a8cb7dfa20d89891f"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1f4979ddee53804db57af91c4f0b3708">这个结构化因果模型对应的图结构如下</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f4979ddee5380a28947d37f59772270"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ab2e1c68e-18d8-4123-969b-f5f3b16dc9f2%3Aimage.png?table=block&amp;id=1f4979dd-ee53-80a2-8947-d37f59772270&amp;t=1f4979dd-ee53-80a2-8947-d37f59772270" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1f4979ddee5380178949eae169e1ca6a"> </div><div class="notion-text notion-block-1f4979ddee53808d93cecf7c6af655aa">再看一个更复杂的例子，打篮球的表现</div><div class="notion-text notion-block-1f4979ddee5380ed847fdc16d1bdae4f">内生变量有三个</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f4979ddee5380aca407c2932c666f34"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:559px"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A66aa79a2-1725-48fc-935f-c4b83c19dced%3Aimage.png?table=block&amp;id=1f4979dd-ee53-80ac-a407-c2932c666f34&amp;t=1f4979dd-ee53-80ac-a407-c2932c666f34" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1f4979ddee53808d85e2f9cacb53f407"> </div><div class="notion-blank notion-block-1f4979ddee5380d1a8e7c66cee37e733"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f3979ddee53809c82fafde3317a2150" data-id="1f3979ddee53809c82fafde3317a2150"><span><div id="1f3979ddee53809c82fafde3317a2150" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f3979ddee53809c82fafde3317a2150" title="Intransitive case"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Intransitive case</span></span></h2><div class="notion-text notion-block-1f1979ddee53806da7ecff76ea178237">因果性和相关性之间的区别，比如说冰激凌销量和溺水人数相关性高，但是冰激凌销量并不是溺水人数的因，可能是因为夏天游泳人数多溺水人数就多，冰淇淋销量也多</div><div class="notion-text notion-block-1f4979ddee5380769554cbeb05922231">一般来说 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>之间是统计独立的就不存在因果关系，但是也有一些特例</div><div class="notion-blank notion-block-1f4979ddee5380a9be96ccbe2e0ea0f7"> </div><div class="notion-text notion-block-1f4979ddee5380c3af0ae3061f2bfa4a">看下面的例子， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的取值由抛硬币决定, <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的取值也由抛硬币决定，两个硬币之间相互独立， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的取值为0,1，当前仅当X的值和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的值相等时，Y的值才为1。</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee5380ae91a4cacaa1a05ee8"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:233px"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A3723854e-c4c5-4d7d-a0ce-3ec96d6240a6%3Aimage.png?table=block&amp;id=1f5979dd-ee53-80ae-91a4-cacaa1a05ee8&amp;t=1f5979dd-ee53-80ae-91a4-cacaa1a05ee8" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1f5979ddee5380699504e39f304eeb55"> </div><div class="notion-text notion-block-1f5979ddee5380488f2fd334a2739449">X跟Y是有因果性的，但是其之间是统计独立的</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1f5979ddee5380a795e8f6390b78f438">所以X,Y是统计独立的。</div><div class="notion-text notion-block-1f5979ddee53800092a7f8ed327ea9bd">再看一个例子：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee5380e8b9bffed5ee2b845c"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:114px"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A152f497e-04c0-4851-828d-71d3e4c1b728%3Aimage.png?table=block&amp;id=1f5979dd-ee53-80e8-b9bf-fed5ee2b845c&amp;t=1f5979dd-ee53-80e8-b9bf-fed5ee2b845c" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1f5979ddee5380d8afe9cbac80879f2e">上边图结构，大多数情况而言，X和Y是统计相关的，但是也有一些特例，如</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1f5979ddee5380a8b192cc2b32e78f95">其结构图如下：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee5380bd9baad52c7e367080"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:211px"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Ad9bf9aa6-521a-42e7-b07c-b033f55edd7b%3Aimage.png?table=block&amp;id=1f5979dd-ee53-80bd-9baa-d52c7e367080&amp;t=1f5979dd-ee53-80bd-9baa-d52c7e367080" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1f5979ddee53807f8194ffd016f04084">Z和X之间是独立的</div><div class="notion-blank notion-block-1f5979ddee53802c835ff3adc173da4c"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee53801cacdfc4db8ebdca3a" data-id="1f5979ddee53801cacdfc4db8ebdca3a"><span><div id="1f5979ddee53801cacdfc4db8ebdca3a" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee53801cacdfc4db8ebdca3a" title="链状结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">链状结构</span></span></h2><div class="notion-text notion-block-1f5979ddee538072a626f42e752a38af">链状结构，叉状结构，对撞结构是因果图中的基本图结构，其他图结构分析就可以拆分成这三种结构</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee53804f9e24e3470b998305"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:279px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A53e9b435-1626-4b9b-87e5-ba6924c37ef5%3Aimage.png?table=block&amp;id=1f5979dd-ee53-804f-9e24-e3470b998305&amp;t=1f5979dd-ee53-804f-9e24-e3470b998305" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1f5979ddee5380fe9b4eebaa76595e4d"> </div><div class="notion-text notion-block-1f5979ddee5380e785b9cdd867a830cc">因果模型表示如下</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><ul class="notion-list notion-list-disc notion-block-1f5979ddee5380ba8392c75b37b8d9bd"><li>Z和Y大概率是独立的（考虑上面的举的的一些特殊例子）</li></ul><ul class="notion-list notion-list-disc notion-block-1f5979ddee538054ba3bf4f4f9721c77"><li>Y和X是大概率独立的</li></ul><ul class="notion-list notion-list-disc notion-block-1f5979ddee53806faddbe197fec75861"><li>Z和X是大概率独立的</li></ul><ul class="notion-list notion-list-disc notion-block-1f5979ddee53802da2b7c61f1f9fc085"><li>给定Y的情况下，Z和X之间是独立的</li></ul><div class="notion-text notion-block-1f5979ddee5380c7b04fd8af12e67cdf">就是上面的例子，在给定Y的情况下，也就是Y为常数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,所以就有 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1f5979ddee5380a1b9d8e365f7cd714e">所以有结论</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee5380fd8c39df3b9611d07a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:347px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A5a8fec44-69bf-4edd-8cd6-f0f3f09ca9d1%3Aimage.png?table=block&amp;id=1f5979dd-ee53-80fd-8c39-df3b9611d07a&amp;t=1f5979dd-ee53-80fd-8c39-df3b9611d07a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1f5979ddee538089aa8ced082b67d9bf"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1f5979ddee5380c0b183f27ce7687cb4"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1f5979ddee53800da373d7a21dd31c7f"> </div><div class="notion-text notion-block-1f5979ddee53807d892ad442773624dc"><b>Rule1:Condition independence in Chain</b></div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee538092a1c4ef5455a35881" data-id="1f5979ddee538092a1c4ef5455a35881"><span><div id="1f5979ddee538092a1c4ef5455a35881" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee538092a1c4ef5455a35881" title="叉状结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">叉状结构</span></span></h2><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee538029b358fec05fb0f79d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:292px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A18b6af86-b1db-4ff4-b687-1810544fe5a9%3Aimage.png?table=block&amp;id=1f5979dd-ee53-8029-b358-fec05fb0f79d&amp;t=1f5979dd-ee53-8029-b358-fec05fb0f79d" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1f5979ddee53803cbee6f669bfca9047"> </div><div class="notion-text notion-block-1f5979ddee538018a2bac84333216aec">看一些因果模型</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1f5979ddee538060912fd13b9785b651">给<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>分别赋予一些含义，分别表示为海滩上的人数、冰激凌销量和溺水人数</div><div class="notion-text notion-block-1f5979ddee538024a61eee97491a9bd6">在给定<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的情况下，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是相互独立的，没有给定<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的情况下，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是相关的</div><div class="notion-text notion-block-1f5979ddee538049af35c32ff303ff91">同理，给定<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的情况下，即<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为常数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>只和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>相关， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>只和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>相关</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1f5979ddee5380009e99d170a7fb169f"><b>Rule2:Condition independence in Forks</b></div><div class="notion-blank notion-block-1f5979ddee538001820acef5a2b4b94c"> </div><div class="notion-text notion-block-1f5979ddee5380ccac0cc4bdb6d085ed">看一下更复杂的图，这中情况需要同时condition 在 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>上 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>跟 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>才会独立</div><div class="notion-blank notion-block-1f5979ddee5380f8b326f68c141659e3"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee53800b8a2df6356d5a5d8b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:378px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A60b788bd-3fb5-4458-9293-6c6b23cc2ac3%3Aimage.png?table=block&amp;id=1f5979dd-ee53-800b-8a2d-f6356d5a5d8b&amp;t=1f5979dd-ee53-800b-8a2d-f6356d5a5d8b" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1f5979ddee5380e18ed5df1b70bb0c43">如果是串行结构，只需要condition在其中一个变量就行</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee5380269c16f7ff10ad8817"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A9402d072-ce44-40cb-abf6-c48cd11c236b%3Aimage.png?table=block&amp;id=1f5979dd-ee53-8026-9c16-f7ff10ad8817&amp;t=1f5979dd-ee53-8026-9c16-f7ff10ad8817" alt="notion image" loading="lazy" decoding="async"/></div></figure><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee53805ba55dea32bfae8c32" data-id="1f5979ddee53805ba55dea32bfae8c32"><span><div id="1f5979ddee53805ba55dea32bfae8c32" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee53805ba55dea32bfae8c32" title="对撞结构"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">对撞结构</span></span></h2><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee538017b97ce329bc6f634a"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:284px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A85e53e28-6447-4faa-b4ca-378167d42a72%3Aimage.png?table=block&amp;id=1f5979dd-ee53-8017-b97c-e329bc6f634a&amp;t=1f5979dd-ee53-8017-b97c-e329bc6f634a" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1f5979ddee5380309d6ddfa6f6c278e5"> </div><div class="notion-text notion-block-1f5979ddee53800fa527cc0ec2eb57fa">其因果模型如下</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><ul class="notion-list notion-list-disc notion-block-1f5979ddee53807d801cf443b018c141"><li>X 和 Z 很大概率是相关的</li></ul><ul class="notion-list notion-list-disc notion-block-1f5979ddee53805398a5c49ecd3eb6d4"><li>Y 和 Z 很大概率是相关的</li></ul><ul class="notion-list notion-list-disc notion-block-1f5979ddee53800ea433cb3b3b0909ec"><li>X 和 Y是独立的</li></ul><ul class="notion-list notion-list-disc notion-block-1f5979ddee5380f9bb24ea09b0b98a92"><li>在给定Z的情况下，X和Y之间相关</li></ul><div class="notion-blank notion-block-1f5979ddee5380bbb08adefb4d2766e5"> </div><div class="notion-text notion-block-1f5979ddee53809ca079dac0c8eb0560"><b>Rule3:Condition dependence in Colliders</b></div><div class="notion-blank notion-block-1f5979ddee53807db9b4d1f3d0914ddb"> </div><div class="notion-text notion-block-1f5979ddee538089b8bbeab41a8a6375">讲一个额外的性质</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1f5979ddee5380c694c2cbfe74707647"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:258px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A0cf01e00-4c70-44e8-8268-53b764938c69%3Aimage.png?table=block&amp;id=1f5979dd-ee53-80c6-94c2-cbfe74707647&amp;t=1f5979dd-ee53-80c6-94c2-cbfe74707647" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1f5979ddee538066a863ed79e7b99cd2"> </div><div class="notion-text notion-block-1f5979ddee53807087dbcb0ee3301593">只要condition在Z及Z的任何子孙节点， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>都是相关的</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee5380c6b4a7f0ac565d6ea8" data-id="1f5979ddee5380c6b4a7f0ac565d6ea8"><span><div id="1f5979ddee5380c6b4a7f0ac565d6ea8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee5380c6b4a7f0ac565d6ea8" title="D-分隔"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">D-分隔</span></span></h2><div class="notion-text notion-block-223979ddee5380e78e69e03c82de28d2">之前介绍的，链状结构和叉状结构两端是unblock的，也就是没有阻塞，是相关的。但是condition在中间节点后，就是block的了。</div><div class="notion-text notion-block-223979ddee53806784afeee7c7ca9d4e">对撞结构跟上边两种结构有些区别</div><div class="notion-blank notion-block-223979ddee5380a18b35d288f0fcee2a"> </div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-223979ddee5380db8fe3fa745e7bfc7d"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A77f8c3b1-e3ae-4cd9-be0e-cbe86ae4e765%3Aimage.png?table=block&amp;id=223979dd-ee53-80db-8fe3-fa745e7bfc7d&amp;t=223979dd-ee53-80db-8fe3-fa745e7bfc7d" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-223979ddee53808da6a6d158ee7b3d6f"> </div><div class="notion-text notion-block-223979ddee5380ce8d93c35b01738c2e">D-Separation可以区分任意两个节点之间的统计相关性，d代表的就是directional,就是方向的意思。</div><div class="notion-text notion-block-223979ddee53806ba629cd57dc364f18">下边有定义表示方法</div><ul class="notion-list notion-list-disc notion-block-223979ddee538049809af4fc1ae2886f"><li>X and Y d-separated &lt;=&gt; X,Y independent </li></ul><ul class="notion-list notion-list-disc notion-block-223979ddee538014aa15d6b21d8607b3"><li>X and Y d-separated condition Z &lt;⇒X,Y independent | Z </li></ul><div class="notion-blank notion-block-223979ddee5380b885b5ca4f9833a317"> </div><div class="notion-text notion-block-223979ddee53805c9765c1401c73c63e">in a fork(chain) X and Y are d-connected </div><div class="notion-text notion-block-223979ddee5380838dbccf0e41e3a49c">in a collider X and Y are d-separated </div><div class="notion-blank notion-block-223979ddee5380aa8880d47851cfd903"> </div><div class="notion-blank notion-block-223979ddee538044a226eea38488aacf"> </div><div class="notion-blank notion-block-223979ddee5380a08cf9f60d0da8cd5d"> </div><div class="notion-blank notion-block-223979ddee538001876bc4f4ebe79477"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee538045bdd5ca7d9c2d8184" data-id="1f5979ddee538045bdd5ca7d9c2d8184"><span><div id="1f5979ddee538045bdd5ca7d9c2d8184" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee538045bdd5ca7d9c2d8184" title="模型检验和等价类"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">模型检验和等价类</span></span></h2><div class="notion-blank notion-block-1f5979ddee53804695a9cdc5d2a91e41"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee53802dbe00ed97a87c6deb" data-id="1f5979ddee53802dbe00ed97a87c6deb"><span><div id="1f5979ddee53802dbe00ed97a87c6deb" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee53802dbe00ed97a87c6deb" title="乘积分解法则"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">乘积分解法则</span></span></h2><div class="notion-blank notion-block-1f5979ddee53802da64aef892b267c20"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee538026ba86e0cad3f528f6" data-id="1f5979ddee538026ba86e0cad3f528f6"><span><div id="1f5979ddee538026ba86e0cad3f528f6" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee538026ba86e0cad3f528f6" title="混淆变量"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">混淆变量</span></span></h2><div class="notion-blank notion-block-1f5979ddee53806f8f58cb184a41fa64"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee5380389b6cdfd48b581a1d" data-id="1f5979ddee5380389b6cdfd48b581a1d"><span><div id="1f5979ddee5380389b6cdfd48b581a1d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee5380389b6cdfd48b581a1d" title="观测数据和试验数据"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">观测数据和试验数据</span></span></h2><div class="notion-blank notion-block-1f5979ddee53802db7c6f0237326bcb1"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee538013987ddc02cc04782d" data-id="1f5979ddee538013987ddc02cc04782d"><span><div id="1f5979ddee538013987ddc02cc04782d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee538013987ddc02cc04782d" title="干预"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">干预</span></span></h2><div class="notion-blank notion-block-1f5979ddee5380d28180cc2cf9a56925"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee5380b0b38df46b8149e117" data-id="1f5979ddee5380b0b38df46b8149e117"><span><div id="1f5979ddee5380b0b38df46b8149e117" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee5380b0b38df46b8149e117" title="do算子"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">do算子</span></span></h2><div class="notion-blank notion-block-1f5979ddee53808cbf91f416bd95cab9"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1f5979ddee538053b164e32e2b3ef972" data-id="1f5979ddee538053b164e32e2b3ef972"><span><div id="1f5979ddee538053b164e32e2b3ef972" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1f5979ddee538053b164e32e2b3ef972" title="调整公式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">调整公式</span></span></h2><div class="notion-blank notion-block-1f5979ddee538018a308e99322194f40"> </div><div class="notion-blank notion-block-1f5979ddee538031bdcaea8577eec4a9"> </div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[机器学习-Boosting]]></title>
            <link>https://www.duanyc.xyz//1d2979dd-ee53-805f-baa1-f0323e0cc10f</link>
            <guid>https://www.duanyc.xyz//1d2979dd-ee53-805f-baa1-f0323e0cc10f</guid>
            <pubDate>Fri, 11 Apr 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1d2979ddee53805fbaa1f0323e0cc10f"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-1d2979ddee53800ca383cfffbff623e5">boosting方法在分类中通过改变训练验样本的权重，学习多个分类器，并将这些分类器进行线性组合，提高分类的性能。</div><div class="notion-blank notion-block-1d2979ddee53806bb775ebb92e158794"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1d2979ddee53802f83b5e282a0ce5154" data-id="1d2979ddee53802f83b5e282a0ce5154"><span><div id="1d2979ddee53802f83b5e282a0ce5154" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d2979ddee53802f83b5e282a0ce5154" title="AdaBoost"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">AdaBoost</span></span></h2><div class="notion-text notion-block-1d2979ddee5380f8952dc8cdf0be87d2">AdaBoost的主要思路是提高被前一轮弱分类器错误分类的样本的权值，而降低那些被正确分类样本的权值。弱分类器的组合是加大分类误差率小的弱分类器的全职，使其在表决中起较大作用。减小分类误差率大的弱分类器的权值，使其在表决中起较小作用</div><div class="notion-blank notion-block-1d5979ddee5380a8a971d98370039721"> </div><div class="notion-text notion-block-1d5979ddee53806c884fca1c8ed56628">这里介绍AdaBoost的前向算法解释</div><div class="notion-blank notion-block-1d5979ddee5380c99effc862e98e05d2"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1d5979ddee53803fad1fe75e46721314" data-id="1d5979ddee53803fad1fe75e46721314"><span><div id="1d5979ddee53803fad1fe75e46721314" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d5979ddee53803fad1fe75e46721314" title="前向分步算法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">前向分步算法</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1d5979ddee538005be8ede36cf81a306" data-id="1d5979ddee538005be8ede36cf81a306"><span><div id="1d5979ddee538005be8ede36cf81a306" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d5979ddee538005be8ede36cf81a306" title="加法模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">加法模型</span></span></h3><div class="notion-text notion-block-1d5979ddee53805baf77cbe59a339d8c">考虑加法模型</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380b9b22deb7650a3e5d3">其中， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 为基函数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 为基函数的参数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 为基函数的系数。 </div><div class="notion-text notion-block-1d5979ddee5380699775c6d9304d7891">给定训练数据及损失函数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的条件下，问题演变成最小化损失函数的问题</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d2979ddee5380cb8712cff2b77d5ba5">前向分布算法的思路是因为学习的是加法模型，每步只学习一个基函数及其系数，逐步的优化目标函数，就可以简化成</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380d3997fe80971a04c12">AdaBoost是前向分步加法算法的特例。这时，模型是由基本分类器组成的加法模型，损失函数是指数函数</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380efa9b7eb679dba3fd6">由基本分类器 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 及其系数<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>组成</div><div class="notion-text notion-block-1d5979ddee538013ae41c0bb99536a2f">其损失函数为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380fa965ec8e06ea25bf0">假设经过 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>轮的迭代得到 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee538056ad51e63a71a092da">目标是使前向分步算法得到的 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 使 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 在训练数据集 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 上的指数损失最小，即</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380118837efb66a6cf4f0">上式可以表示为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee538051897dc1ea655f5720">其中， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。因为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span><em> 既不依赖 </em><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span><em> 也不依赖于 </em><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span><em> ，所以与最小化无关。但 </em><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 依赖于 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，随着每一轮迭代而发生改变。</div><div class="notion-blank notion-block-1d5979ddee538025bb70e2c63f0c8ba9"> </div><div class="notion-text notion-block-1d5979ddee538006b8efe5beca488e4d">现在求解使得上式达到最小的参数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>就是AdaBoost算法得到的 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。求解分为两步：</div><ul class="notion-list notion-list-disc notion-block-1d5979ddee5380ca869cfd33a1a35881"><li>首先，求 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。对任意 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，使式最小的<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>由下式得到：</li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380188297ea4f595a62c6">其中, <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><ul class="notion-list notion-list-disc notion-block-1d5979ddee5380b5b286f403fe8d14ea"><li>再求 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>。</li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380888393ed8f717a8b19">求导使导数等于0有：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee53807790d5f20ed9f211b9">其中 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是分类误差率：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee538069850dfc73d4740892">最后看每一轮的权重更新。有</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380eaa060e11982e9debb">以及 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，可得 </div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380d5a170ded47e6c8d4a">adaboost算法其他解释及误差界参考</div><div class="notion-text notion-block-1d5979ddee538070bc51ea9fc1c88421"><a class="notion-link" href="/1c2979ddee5380909fd9f2ae25d4b1c2"><span class="notion-page-title"><div class="notion-page-icon-inline notion-page-icon-image"><svg class="notion-page-title-icon notion-page-icon" alt="机器学习-Adaboost" viewBox="0 0 30 30" width="16"><path d="M16,1H4v28h22V11L16,1z M16,3.828L23.172,11H16V3.828z M24,27H6V3h8v10h10V27z M8,17h14v-2H8V17z M8,21h14v-2H8V21z M8,25h14v-2H8V25z"></path></svg></div><span class="notion-page-title-text">机器学习-Adaboost</span></span></a> </div><div class="notion-blank notion-block-1d5979ddee5380a29328fdaec8b20653"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-1d5979ddee5380c3b609ce6a5db15c4d" data-id="1d5979ddee5380c3b609ce6a5db15c4d"><span><div id="1d5979ddee5380c3b609ce6a5db15c4d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d5979ddee5380c3b609ce6a5db15c4d" title="提升树模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">提升树模型</span></span></h2><div class="notion-text notion-block-1d5979ddee53804aa7b0d38653620a25">提升方法采用加法模型（基函数的线性组合）与前向分步算法。以决策树为基函数的提升方法称为提升树(boosting tree)。对分类问题决策时是二叉分类树，对回归问题决策树是二叉回归树。提升树模型可以表示为决策树的加法模型</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d5979ddee5380ce942efa9a108c9062"> 其中， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示决策树， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为决策树的参数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为树的个数。</div><div class="notion-blank notion-block-1d5979ddee5380619088f164035def5e"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1d5979ddee538086a8d8e17690e111ca" data-id="1d5979ddee538086a8d8e17690e111ca"><span><div id="1d5979ddee538086a8d8e17690e111ca" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d5979ddee538086a8d8e17690e111ca" title="提升树算法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">提升树算法</span></span></h3><div class="notion-text notion-block-1d6979ddee53808eb351e37cac1dd32d">提升树算法采用前向分步算法。首先确定初始提升树 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，第m步的模型是：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee53808ba88fe69956b8dbc9">其中， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为当前模型，通过经验风险最小化确定下一课决策树的参数</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee5380608c98eb4ed3c21ffe">不同问题的提升树学习算法，主要区别在于使用的损失函数不同，如平方误差，指数损失等。</div><div class="notion-blank notion-block-1d6979ddee53804193d0d503341dbe39"> </div><div class="notion-text notion-block-1d6979ddee53801a8373e53b7b562a85">已知一个训练数据集 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 为输入空间， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 为输出空间。如果将输入空间 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 划分为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 个互不相交的区域 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，并且在每个区域上确定输出的常量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，那么树可表示为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee53806dbc37dd26f6dccab5">其中，参数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 表示树的区域划分和各区域上的常数。 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 是回归树的复杂度即叶结点个数。</div><div class="notion-blank notion-block-1d6979ddee5380ae8a26dbf87c7d618a"> </div><div class="notion-text notion-block-1d6979ddee5380c2b7dbed6cb598fad3">回归问题提升树使用以下前向分步算法：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee538022ae77c204b3cb2694">在前向分布算法的第m步，给定当前模型 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，需求解</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee538080bee8ed8292b06e58">得到 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，即第 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 棵树的参数。 </div><div class="notion-text notion-block-1d6979ddee53802c8669edd8aca65a38">当采用平方误差损失函数时，</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee5380218a64f276a1aa7100">其损失变为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee5380d8bb87d44599c5e358"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是当前模型拟合数据的残差。要使损失最小，需要使得残差越小越好。所以，对回归问题的提升树算法来说，只需要简单地拟合当前模型的残差。</div><div class="notion-blank notion-block-209979ddee5380d8baa3c7fdffe1b52a"> </div><div class="notion-blank notion-block-209979ddee5380a6b6e1f71691ad8e68"> </div><div class="notion-text notion-block-1d6979ddee5380dea147c5bb286699a9">所以其算法流程如下：</div><div class="notion-text notion-block-1d6979ddee538007858ec25e9b32373b">
</div><div class="notion-text notion-block-1d6979ddee53800e9950eaa5e137cc68">输入：训练数据集 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ；输出：提升树 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。
（1）初始化 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。
（2）对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。
（a）按上式计算残差：</div><div class="notion-text notion-block-1d6979ddee5380598c5bc07f68bfafaf"> <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1d6979ddee538056ba97f33bcea72442">（b）拟合残差 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 学习一个回归树，得到 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。
（c）更新 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。
（3）得到回归问题提升树</div><div class="notion-text notion-block-1d6979ddee53808abeb0e59617e181b0"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-1d6979ddee5380899afbcd2f30568282"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-1d6979ddee5380419686f2debbcc948c" data-id="1d6979ddee5380419686f2debbcc948c"><span><div id="1d6979ddee5380419686f2debbcc948c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d6979ddee5380419686f2debbcc948c" title="梯度提升"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">梯度提升</span></span></h3><div class="notion-text notion-block-1d6979ddee5380d093f8cd4383216f2b">提升树利用加法模型与前向分布算法学习的优化过程。当损失函数是<b>平方损失和指数损失</b>时，每一步优化是很简单的。但对一般损失函数而言，优化并不容易，这样就有了梯度提升算法。</div><div class="notion-text notion-block-1d6979ddee53803a860fc556121a5701">是利用梯度最速下降法的近似方法，关键是利用 <b>损失函数的负梯度</b>在当前模型的值</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d6979ddee538084a993d28e2d817adf">作为回归问题提升树算法中的残差的近似值，拟合一个回归树</div><div class="notion-text notion-block-1d6979ddee538054a72ff8aab9aac073">算法流程如下：</div><div class="notion-text notion-block-1d6979ddee5380098cc9cd077ab6bcec">输入：训练数据集 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ；损失函数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ；</div><div class="notion-text notion-block-1d6979ddee53803d8906c4bcaeee9980">输出：回归树 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。
（1）初始化</div><div class="notion-text notion-block-1d6979ddee5380aa8b53ede7f07bddad"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1d6979ddee5380da8503f87ac63e3c15">（2）对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>
（a）对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，计算</div><div class="notion-text notion-block-1d6979ddee5380a88f83dd264773c98f"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1d6979ddee5380a4b7eef7aa76735e1d">（b）对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 拟合一个回归树，得到第 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 棵树的叶结点区域 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 。
（c）对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，计算</div><div class="notion-text notion-block-1d6979ddee5380c9a760cd6a0a7af965"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1d6979ddee538076bb7cd34d2df140b5">（d）更新 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>
（3）得到回归树</div><div class="notion-text notion-block-1d6979ddee53804096cde9181ddf2fba"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>
</div><div class="notion-blank notion-block-209979ddee53802d8b83cf816ba10dd5"> </div><div class="notion-text notion-block-209979ddee53808e88fce739632a6a54"><b>为什么梯度提升拟合的是负梯度？</b></div><div class="notion-text notion-block-209979ddee538004b8dfd3e21539de5f">从前边的提升树我们知道，当损失函数是平方损失的时候，其实就是使得预测值和残差越接近越好，当是分类问题时，如果是指数损失，其也是拟合的残差(真实标签和概率的差值)，但是如果是其他损失函数呢？从通用性角度出发有</div><ul class="notion-list notion-list-disc notion-block-209979ddee5380fc92b5dca051d93132"><li>拟合的目标是使得 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>最小</li></ul><ul class="notion-list notion-list-disc notion-block-209979ddee53801a9f4ec6301c6b5f6c"><li>对损失函数一阶泰勒展开有 </li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-209979ddee5380d5bf7ed74333215b24">每一次迭代需要损失不断下降，则有</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-209979ddee538034ab04c3b5cbbfc5bb">代入上式可得：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-209979ddee5380e99249fd5fc26fe92b">为了使得上式小于0，可以令</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-209979ddee53803583e5ef7763390a24">因此，梯度提升树的每一颗新的树拟合的目标值就是损失函数的负梯度。</div><div class="notion-blank notion-block-209979ddee53800eac6ec55cda8f6223"> </div><div class="notion-text notion-block-209979ddee5380bc87e1e195a9d9675c"><a class="notion-link" href="https://zhuanlan.zhihu.com/p/348776985" target="_blank" rel="noopener noreferrer">https://zhuanlan.zhihu.com/p/348776985</a></div><div class="notion-text notion-block-209979ddee538078a0bffccb5bd1f8ba"><span class="notion-link-mention"><a href="https://zhuanlan.zhihu.com/p/625318418" target="_blank" rel="noopener noreferrer" class="notion-link-mention-link"><img class="notion-link-mention-icon"/><span class="notion-link-mention-title">zhuanlan.zhihu.com</span></a><div class="notion-link-mention-preview"><article class="notion-link-mention-card"><img class="notion-link-mention-preview-thumbnail" alt="zhuanlan.zhihu.com" referrerPolicy="same-origin"/><div class="notion-link-mention-preview-content"><p class="notion-link-mention-preview-title">zhuanlan.zhihu.com</p><p class="notion-link-mention-preview-description"></p><div class="notion-link-mention-preview-footer"><img class="notion-link-mention-preview-icon" referrerPolicy="same-origin"/><span class="notion-link-mention-preview-provider"></span></div></div></article></div></span></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[决策树原理总结]]></title>
            <link>https://www.duanyc.xyz//面试整理/207979dd-ee53-80e1-aaaa-ca77f1964bf2</link>
            <guid>https://www.duanyc.xyz//面试整理/207979dd-ee53-80e1-aaaa-ca77f1964bf2</guid>
            <pubDate>Tue, 03 Jun 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-207979ddee5380e1aaaaca77f1964bf2"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-207979ddee5380b8baacd4a18df15d84">决策树是一种基本的分类回归方法。决策树通常包括3个步骤：特征选择、决策树的生成和决策树的修剪。</div><div class="notion-text notion-block-207979ddee5380e8a542dbd9fa2056ae">特征选择不同的算法使用的标准不同，但其有一个共同点，选择的特征应该是能够使得整体的不确定性下降到最大的。</div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-207979ddee5380de9c5dcd316ecaee39" data-id="207979ddee5380de9c5dcd316ecaee39"><span><div id="207979ddee5380de9c5dcd316ecaee39" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee5380de9c5dcd316ecaee39" title="特征选择"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">特征选择</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-207979ddee5380508ec3df0d3f82dd52" data-id="207979ddee5380508ec3df0d3f82dd52"><span><div id="207979ddee5380508ec3df0d3f82dd52" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee5380508ec3df0d3f82dd52" title="信息增益"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>信息增益</b></span></span></h3><div class="notion-text notion-block-207979ddee53802e943ff8134f14d1cd">信息增益用来进行决策树的特征选择，这里先介绍熵与条件熵，在信息论中，熵是用来度量随机变量的不确定性。设X是一个取有限个值的离散随机变量，其概率分布为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee53801b9506e714435dc2e1">则随机变量X的熵定义为:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee538056924fc8abee596af6">如果 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为0，则定义0log0=0,如果以2为底，则熵的单位称为比特(bit)，如果以e为底，则熵的单位为纳特(nat),将X的熵记作 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，即：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee53801aa65bfa6576265df6">熵越大，随机变量的不确定性就越大。</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee538030b440c3bfbc3a6b5d">当随机变量取值只有两个值时， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-207979ddee5380c09a87dfe2a80f933f"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:605.984375px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Affcc4e05-1627-4681-8db8-471e6db61c50%3Aimage.png?table=block&amp;id=207979dd-ee53-80c0-9a87-dfe2a80f933f&amp;t=207979dd-ee53-80c0-9a87-dfe2a80f933f" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-207979ddee5380f1b2eaceb043b8758b">p=0或者p=1时，熵为0，随机变量完全没有不确定性。当p=0.5时，熵最大,其不确定性也越大</div><div class="notion-text notion-block-207979ddee53800d92a3e8293b12f885">设有随机变量(X,Y)，其联合概率分布为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee5380b39bb8dd2e64eca657">条件熵 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 表示在已知随机变量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的条件下随机变量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的不确定性。随机变量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 给定的条件下随机变量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的条件熵（conditional entropy） <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，定义为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 给定条件下 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的条件概率分布的熵对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的数学期望:</div><div class="notion-text notion-block-207979ddee5380baa355cb3cec85058f">这里 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee538014892dcf8f26d72bda"><b>注意，</b>这个条件熵，<b>是指在给定某个数（某个变量为某个值）的情况下，另一个变量的熵是多少，变量的不确定性是多少？</b></div><div class="notion-text notion-block-207979ddee538084806afc95aa5e0a97"><b>信息增益表示的是得知特征X的信息而使得类Y的信息的不确定性减少的程度</b></div><div class="notion-text notion-block-207979ddee5380f8abbbf1dbb4e17094">所以特征A对训练数据集D的信息增益 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，定义和集合D的经验熵H(D)与特征A给定条件下D的经验条件熵 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>之差，即：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><hr class="notion-hr notion-block-207979ddee5380228084f51ed65751b5"/><div class="notion-text notion-block-207979ddee5380dda44fe568bd04c98c">这里举例如何计算信息增益</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-207979ddee5380d28ad4f92bf697a40b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A7fbe1318-f02e-41fe-b4ce-107d0fd98fd5%3Aimage.png?table=block&amp;id=207979dd-ee53-80d2-8ad4-f92bf697a40b&amp;t=207979dd-ee53-80d2-8ad4-f92bf697a40b" alt="notion image" loading="lazy" decoding="async"/></div></figure><ul class="notion-list notion-list-disc notion-block-207979ddee53808f9fc5d26f6f76e6a2"><li>训练数据集为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 表示其样本容量，即样本个数。</li></ul><ul class="notion-list notion-list-disc notion-block-207979ddee538078b5a3dc66b61bcc77"><li><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 个类 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 为属于类 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的样本个数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><ul class="notion-list notion-list-disc notion-block-207979ddee5380c2bec9c0911f158ed0"><li>设特征 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 有 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 个不同的取值 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，根据特征<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的取值将<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>划分为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 个子集 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的样本个数。 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><ul class="notion-list notion-list-disc notion-block-207979ddee53808b8cacf2f8571c7267"><li>记子集<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>中属于类 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的样本的集合为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> ，即 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 的样本个数。于是信息增益的算法如下。</li></ul><div class="notion-text notion-block-207979ddee5380548405e5bdc49f2191">以上边西瓜分类的例子，特征有<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,这里一共17个样本，样本容量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，有两个类，是和否，记好瓜为1，坏瓜为2，好瓜的样本数为8个<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>=8，坏瓜的样本数为9个，则 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-207979ddee5380b788b5f99c39fa2fb6">这里以特征“色泽”为例，有三个取值， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,该特征三个取值将数据集划分为3个子集，</div><div class="notion-text notion-block-207979ddee5380dcb537e7b2f32ca103">1表示青绿，2表示乌黑，3表示浅白</div><div class="notion-text notion-block-207979ddee53807b9217c71cef5083a6"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-207979ddee538096b5d5ee170eda229e"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-207979ddee5380a58f30d9ea9714cd69"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><ul class="notion-list notion-list-disc notion-block-207979ddee53801b8c2bcf1363103dab"><li>先计算经验熵H(D)</li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><ul class="notion-list notion-list-disc notion-block-207979ddee5380f7bec7d87f24d2c85c"><li>然后计算特征色泽（以<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示）的信息增益</li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-207979ddee5380c19a74dc8b4754f40c"> </div><div class="notion-blank notion-block-207979ddee5380ecaabdea0d642d7452"> </div><ul class="notion-list notion-list-disc notion-block-207979ddee538037a667d4b35cf108e0"><li>计算信息增益</li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee538074bd30dfdeff987284">其他特征依次计算，计算出信息增益最大的，也就是给定特征后让其不确定性减少最多的特征作为划分的最优特征</div><div class="notion-text notion-block-207979ddee5380eb9442e8fe69e8c516">比如上述例子根蒂的信息增益为0.143、敲声的信息增益为0.141，纹理的信息增益为0.381，脐部的信息增益为0.289，触感的信息增益为0.006.</div><div class="notion-text notion-block-207979ddee538036b6edf7e90b516d87">这里显然纹理的信息增益最大，基于纹理作为根节点进行划分</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-207979ddee5380febcc7d486f0eeafb2"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A6605e2fb-dbe4-44ab-b7fe-3808c53d63c1%3Aimage.png?table=block&amp;id=207979dd-ee53-80fe-bcc7-d486f0eeafb2&amp;t=207979dd-ee53-80fe-bcc7-d486f0eeafb2" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-207979ddee5380c1ab66fb713472be62"> </div><hr class="notion-hr notion-block-207979ddee5380c7afcadbca5ba3edf0"/><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-207979ddee538053b793de4ad210077b" data-id="207979ddee538053b793de4ad210077b"><span><div id="207979ddee538053b793de4ad210077b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee538053b793de4ad210077b" title="2.信息增益率"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2.信息增益率</span></span></h3><div class="notion-text notion-block-207979ddee5380578720fc5a7637da24">信息增益会偏向于选择可取值数量多的特征，增益率能对这个问题进行改进</div><div class="notion-text notion-block-207979ddee5380babcaac4511e90d607">特征A对训练数据集D的信息增益比 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>定义为其信息增益 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>与训练数据集D关于特征A的值的熵 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>之比，即:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee53807aa68edebf815ff80f">其中， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>, n是特征A取值的个数。 </div><div class="notion-text notion-block-207979ddee5380ca91c1fcbfe382d23b">比如上例中的色泽特征为例</div><div class="notion-text notion-block-207979ddee5380b4b1fcfe6c27af3683"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-207979ddee5380939267e25e71620a50"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-207979ddee5380149ae3f7064197d23f"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-207979ddee5380b88c60cef3ad106686" data-id="207979ddee5380b88c60cef3ad106686"><span><div id="207979ddee5380b88c60cef3ad106686" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee5380b88c60cef3ad106686" title="决策树生成"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">决策树生成</span></span></h2><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-207979ddee5380c1b489dd6972a2b3ea" data-id="207979ddee5380c1b489dd6972a2b3ea"><span><div id="207979ddee5380c1b489dd6972a2b3ea" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee5380c1b489dd6972a2b3ea" title="ID3"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>ID3</b></span></span></h3><div class="notion-text notion-block-207979ddee53807e87d4c5a12cf95653">ID3算法是用信息增益来进行特征选择的</div><div class="notion-blank notion-block-207979ddee538094bb59dbe18a2f8692"> </div><h3 class="notion-h notion-h2 notion-h-indent-1 notion-block-207979ddee5380719b24c94df8223eaa" data-id="207979ddee5380719b24c94df8223eaa"><span><div id="207979ddee5380719b24c94df8223eaa" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee5380719b24c94df8223eaa" title="C4.5"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">C4.5</span></span></h3><div class="notion-text notion-block-207979ddee5380669ee4d6f0167e65bd">C4.5主要是用改进的信息增益率来进行特征选择，信息增益率对取值数目较少的属性有所偏好，因此C4.5并不是直接选择增益率最大的候选划分属性，而是用了一个启发式，先从候选划分属性中找出信息增益高于平均水平的属性，再从中选择增益率最高的。</div><div class="notion-blank notion-block-207979ddee5380e09e7eeb9172d660d6"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-207979ddee5380308930dcc8843a1526" data-id="207979ddee5380308930dcc8843a1526"><span><div id="207979ddee5380308930dcc8843a1526" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee5380308930dcc8843a1526" title="CART生成"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">CART生成</span></span></h2><ul class="notion-list notion-list-disc notion-block-207979ddee5380168804c9150c464795"><li>回归树的生成</li></ul><div class="notion-text notion-block-207979ddee53804d8cf9fa26d0094fce">回归树Y是连续变量，当输入特征划分确定时，用平方误差来表述对于训练数据的预测误差，用平方误差最小的准则求解每个单元上的最优输出值，特征进行切分找到最优的切分点</div><ul class="notion-list notion-list-disc notion-block-207979ddee53805a9887ce36569d505d"><li>分类树的生成</li></ul><div class="notion-text notion-block-207979ddee538001ba7bd3b1718b188d"> <b>基尼指数</b></div><div class="notion-text notion-block-207979ddee5380d7aca4ed2ed260bf01">在分类问题中，假设有K个类，样本点属于第k类的概率为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，则概率分布的基尼指数定义为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee5380caab08c07a0fbac58f">对于二分类问题，若样本点属于第1个类的概率是p，则概率分布的基尼指数为</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee53807ab7f5e3bcc5102fac">给定样本集合D，其基尼指数为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee5380fa89efc38d7d75544e">这里 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是D中属于第 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>类的样本子集，K是类的个数</div><div class="notion-text notion-block-207979ddee538070876efb377e9ff9d8">如果样本集合D根据特征A是否取某一个值a被分割成 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>两部分，则在特征A的条件下，集合D的基尼指数定义为：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee53800bb47bc6b52b596fb3">Gini(D) 反应了从数据集D中随机抽取两个样本，其类别标记不一致的概率，因此Gini(D)越小，则数据集D的纯度越高</div><div class="notion-text notion-block-207979ddee53807bbb31face9ed0dc3b">下图显示了基尼指数，熵之半和分类误差率之间的关系</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-207979ddee5380e797eac506cd157947"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aa6544a0e-e09f-4dda-b4a8-3103213110be%3Aimage.png?table=block&amp;id=207979dd-ee53-80e7-97ea-c506cd157947&amp;t=207979dd-ee53-80e7-97ea-c506cd157947" alt="notion image" loading="lazy" decoding="async"/></div></figure><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-207979ddee5380389f05fce5d8df28e1" data-id="207979ddee5380389f05fce5d8df28e1"><span><div id="207979ddee5380389f05fce5d8df28e1" class="notion-header-anchor"></div><a class="notion-hash-link" href="#207979ddee5380389f05fce5d8df28e1" title="剪枝"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>剪枝</b></span></span></h4><div class="notion-text notion-block-207979ddee5380589293ce2e6c06256d">剪枝是决策树学习算法主要是为了抑制“过拟合”，在训练阶段为了尽可能的正确分类训练样本，节点划分过程会不断重复，有时会造成决策树分支过多，有过拟合风险。决策树的剪枝分为预剪枝和后剪枝。</div><div class="notion-text notion-block-207979ddee5380299ac5f50abaae3ae3"><b>预剪枝</b>：主要思路就是，把这个特征作为根节点不进行划分，预测正确的概率和进行划分后预测正确的概率，如果划分后预测的准确率得到了提高就进行树的生长，不然就禁止该特征进行划分,这里的评估需要划分训练集，把一部分数据集留出用作验证集。如果使用某特征进行划分后，验证集的准确性没有提高，就禁止该特征进行划分。</div><div class="notion-text notion-block-207979ddee5380288086da70a0bcf4da"><b>后剪枝:</b>主要思想就是，先生成一颗完整的树，然后从最底层的非叶子结点开始，该节点分裂后的准确率为a，如果让其不进行分列，准确率为b，如果a&gt;b则不剪枝，a&lt;b则剪枝。</div><div class="notion-blank notion-block-207979ddee5380f6af94c72b14867df2"> </div><div class="notion-blank notion-block-207979ddee53805881befdbf9bb61875"> </div><div class="notion-text notion-block-207979ddee538036950edb3b4692abf3">Cart树的剪枝用的是后剪枝，先生成一棵树，然后使用使用策略剪去一些子树，让树的规模变小，其剪枝算法由两步组成</div><ul class="notion-list notion-list-disc notion-block-207979ddee5380e5a3c5f99ff225f927"><li>从生成算法产生的决策树 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>不断剪枝，直到<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的根节点，形成一个子序列 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><ul class="notion-list notion-list-disc notion-block-207979ddee5380eba07dce3fd4d26de3"><li>然后通过交叉验证法在独立的验证数据集上对子树序列进行测试，从中选取最优子树</li></ul><div class="notion-blank notion-block-207979ddee5380de9043c48a4bcc10d3"> </div><div class="notion-text notion-block-207979ddee5380d8a91ff8574a604b04">其子树的剪枝过程中，计算子树的损失函数</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee53804ca789d876d62a2268"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是对训练数据预测误差(比如基尼系数)， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为子树的叶节点个数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为参数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是参数为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>时的子树 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的整体损失，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是权衡模型复杂度和数据拟合程度的参数</div><div class="notion-text notion-block-207979ddee53803396c4eccdd73bae8d">一般 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>偏大的话，生成的树倾向于偏小，因为树生成带来的增益可能覆盖不了 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>带来的开销</div><div class="notion-blank notion-block-208979ddee5380cd9d24c55ba491e037"> </div><div class="notion-text notion-block-208979ddee5380baa8d4c6f29470ce55">从整体树<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>开始剪枝。对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的任意内部节点<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,以 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为单节点数的损失函数是</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-207979ddee538063a682c21badb6c783">以<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为根节点的子树<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的损失函数是</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-208979ddee53803ab185d8ef8a84d646">当 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>或者 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>充分小的话有：<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-208979ddee5380ca8ff3ebf55b07c54e">当<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>变大时，在某一<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>有<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-blank notion-block-208979ddee53806fa4a7d7a116c17048"> </div><div class="notion-text notion-block-208979ddee5380219d2afd702420e6e6">所以只要<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,有 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>和<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>有相同的损失值，但是t的节点更少，因此<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>比<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>更优,就对 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>进行剪枝。</div><div class="notion-text notion-block-209979ddee5380939978fca9e7b1e095">自上而下的对内部节点 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>计算 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>, <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>以及</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-208979ddee538084af01e124a739a5ec"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示以<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为根节点的子树， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是对训练数据的预测误差， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的叶节点个数。</div><div class="notion-blank notion-block-209979ddee5380a8ad01d548aeee2884"> </div><h2 class="notion-h notion-h1 notion-h-indent-0 notion-block-209979ddee5380b3ad04ceabb2b36031" data-id="209979ddee5380b3ad04ceabb2b36031"><span><div id="209979ddee5380b3ad04ceabb2b36031" class="notion-header-anchor"></div><a class="notion-hash-link" href="#209979ddee5380b3ad04ceabb2b36031" title="缺失值处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">缺失值处理</span></span></h2><div class="notion-text notion-block-209979ddee5380dcb3d3fb562ec607da">缺失值的处理需要处理两个问题</div><ul class="notion-list notion-list-disc notion-block-209979ddee53805884b8e299053c09e8"><li>如何在特征值缺失的情况下进行划分特征上选择</li></ul><ul class="notion-list notion-list-disc notion-block-209979ddee538020bae5f98cf5e854bf"><li>给定划分特征，若样本在该特征上的值缺失，如何对样本进行划分</li></ul><div class="notion-blank notion-block-209979ddee538088a98af3c717c686b4"> </div><div class="notion-text notion-block-209979ddee538005b078cc30e01f258a">对于第一个问题，将信息增益的计算改为如下式子</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-209979ddee538069bbc4e122da00470b"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示特征A上没有缺失值的样本子集，<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示特征A无缺失样本所占的比例</div><div class="notion-blank notion-block-209979ddee53800aa1c2e5015529fc31"> </div><div class="notion-text notion-block-209979ddee53807ea23fc7d2a027970b">对于第二个问题</div><div class="notion-text notion-block-209979ddee5380d79724f1b0c3eb64b4">我们需要假设每个样本都有一个权重 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,如果样本<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>在划分特征A上的取值已知，则将<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>划分到与其取值对应的子节点，且样本权重不变</div><div class="notion-text notion-block-209979ddee5380d79530ea443c3bc515">如果样本<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>在划分属性A上的取值位置，则将<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>划分到所有节点，但是其样本权重调整为 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>, <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为属性A的第i个取值的样本子集的大小，相当于让同一个样本以不同的概率划入到不同的子节点中去。</div><div class="notion-text notion-block-209979ddee538035bfc3c682bfc31d17">C4.5的缺失值就是使用上述的方法</div><div class="notion-blank notion-block-209979ddee538014a292f80f4b98982e"> </div><div class="notion-text notion-block-209979ddee538076bfcbee180757aa9f">Cart树缺失值处理，待定</div><div class="notion-blank notion-block-209979ddee538060994bf1b494155e0b"> </div><div class="notion-blank notion-block-209979ddee538083a26fc2ca4fc121cc"> </div><div class="notion-blank notion-block-209979ddee53808593e6eec6ce778cee"> </div><div class="notion-text notion-block-207979ddee53802c9674ebcfde96a032">参考：</div><div class="notion-text notion-block-207979ddee538050922ade3f7cd9fe10">李航统计学方法</div><div class="notion-text notion-block-207979ddee5380df9826fa9b4b1cf4fa">周志华-机器学习</div><div class="notion-text notion-block-207979ddee5380b1a868e562773dd5b3"><span class="notion-link-mention"><a href="https://zhuanlan.zhihu.com/p/85731206" target="_blank" rel="noopener noreferrer" class="notion-link-mention-link"><img class="notion-link-mention-icon"/><span class="notion-link-mention-title">zhuanlan.zhihu.com</span></a><div class="notion-link-mention-preview"><article class="notion-link-mention-card"><img class="notion-link-mention-preview-thumbnail" alt="zhuanlan.zhihu.com" referrerPolicy="same-origin"/><div class="notion-link-mention-preview-content"><p class="notion-link-mention-preview-title">zhuanlan.zhihu.com</p><p class="notion-link-mention-preview-description"></p><div class="notion-link-mention-preview-footer"><img class="notion-link-mention-preview-icon" referrerPolicy="same-origin"/><span class="notion-link-mention-preview-provider"></span></div></div></article></div></span></div><div class="notion-text notion-block-207979ddee538098ad1ff55ec59e03a2"><span class="notion-link-mention"><a href="https://zhuanlan.zhihu.com/p/594519152" target="_blank" rel="noopener noreferrer" class="notion-link-mention-link"><img class="notion-link-mention-icon"/><span class="notion-link-mention-title">zhuanlan.zhihu.com</span></a><div class="notion-link-mention-preview"><article class="notion-link-mention-card"><img class="notion-link-mention-preview-thumbnail" alt="zhuanlan.zhihu.com" referrerPolicy="same-origin"/><div class="notion-link-mention-preview-content"><p class="notion-link-mention-preview-title">zhuanlan.zhihu.com</p><p class="notion-link-mention-preview-description"></p><div class="notion-link-mention-preview-footer"><img class="notion-link-mention-preview-icon" referrerPolicy="same-origin"/><span class="notion-link-mention-preview-provider"></span></div></div></article></div></span></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[机器学习-XGBoost]]></title>
            <link>https://www.duanyc.xyz//1d0979dd-ee53-8092-aa85-f2f881087792</link>
            <guid>https://www.duanyc.xyz//1d0979dd-ee53-8092-aa85-f2f881087792</guid>
            <pubDate>Wed, 09 Apr 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1d0979ddee538092aa85f2f881087792"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-1d0979ddee5380d5a727df416a38a769">前边介绍了梯度提升树算法，XGBoost也是加法模型的一种，运用了梯度提升的思想。</div><div class="notion-blank notion-block-1d8979ddee5380c7b3daca4a323d42ba"> </div><div class="notion-text notion-block-1d8979ddee538030a23bc23daaacdf5b">XGBoost是由 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>个基模型组成的一个加法模型，假设我们第 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>次迭代要训练的树模型是 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1d8979ddee5380879792fa3713b5993f">,则有</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee53801aa6e8e3cc28163402"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>是第<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>次迭代后样本<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的预测结果， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示前t-1颗树的预测结果， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示第t棵树的预测结果。下边图是一个简单的示例</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1d8979ddee5380a8b06edc5b42c7c4ee"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A2fbb7472-c6ac-47b2-b179-2d79db054f4e%3Aimage.png?table=block&amp;id=1d8979dd-ee53-80a8-b06e-dc5b42c7c4ee&amp;t=1d8979dd-ee53-80a8-b06e-dc5b42c7c4ee" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1d8979ddee53801aa825d629fdb29588"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1d8979ddee53802c9c8fe3ba723d59ae" data-id="1d8979ddee53802c9c8fe3ba723d59ae"><span><div id="1d8979ddee53802c9c8fe3ba723d59ae" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d8979ddee53802c9c8fe3ba723d59ae" title="目标函数"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">目标函数</span></span></h3><div class="notion-text notion-block-1d8979ddee5380a0bfb1d053bd937aa8">其损失函数为预测值 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>与真实值 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>进行表示：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380b38898cc0cc8e282b9">n为样本量</div><div class="notion-text notion-block-1d8979ddee5380fdbc52eee4d1f3ac3e">其目标函数为损失函数+正则项组成</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380a7b450c9e0590a0698">其中正则项 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><div class="notion-text notion-block-1d8979ddee5380039caad066b75f6ca1">此处， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 和  <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 都是惩罚项， TT为树的叶子节点总数量。该定义可以如此理解：一方面，T值大，说明树的深度比较深，过拟合的概率就会变高，所以使用 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>进行惩罚； 另一方面， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>值大，说明该树在整个模型中会占据较大的比重，即预测结果主要依赖该树，此时过拟合风险也会变高，所以需要再使用 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>进行惩罚。</div><div class="notion-text notion-block-1d8979ddee53807d9325c79b59d64604">根据前步加法：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee53809cb068f4ab6d25342d">其中， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 是由第 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 步的模型给出的预测值，是已知常数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 是这次需要加入的新模型的预测值。此时，目标函数就可以写成：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380f7a079d793fd133858">正则项因为前t-1棵树已经确定，所以前t-1棵树的正则项就是吃常数</div><div class="notion-text notion-block-1d8979ddee5380cab7ece77de8bfa735">回顾一下泰勒展开,XGBoost主要是用到二阶，如下</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380d2abfed34e0d519726">所以有</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380839384ea6c07112a23"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为损失函数的一阶导数， <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为损失函数的二阶导数。这里 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>也是常数，目标函数可以写成</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-1d8979ddee53800e859dcff29357873f"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1d8979ddee538042ae4cc836c55811b0" data-id="1d8979ddee538042ae4cc836c55811b0"><span><div id="1d8979ddee538042ae4cc836c55811b0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d8979ddee538042ae4cc836c55811b0" title="定义树"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">定义树</span></span></h3><div class="notion-text notion-block-1d8979ddee5380269270f8e1fd76ef67">定义树我们需要有两个部分</div><ul class="notion-list notion-list-disc notion-block-1d8979ddee53804482f3fc1f4e7f30d4"><li>叶子节点的权重向量 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><ul class="notion-list notion-list-disc notion-block-1d8979ddee5380feb4f9e8e7eb30a8b0"><li>样本到叶子节点的映射关系 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><div class="notion-text notion-block-1d8979ddee538038ad7ee3ed3b7ffc45">看下面图</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1d8979ddee5380fd8a65e10eb31a2290"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3Aae6c68ca-d912-4079-b682-a1696d56d551%3Aimage.png?table=block&amp;id=1d8979dd-ee53-80fd-8a65-e10eb31a2290&amp;t=1d8979dd-ee53-80fd-8a65-e10eb31a2290" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1d8979ddee5380bab88acd60487d0698">定义 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,也就是实例所属于哪个叶子节点</div><div class="notion-text notion-block-1d8979ddee53806eadb7eb8dd3aaa70f">作为被分到第j个叶子节点下的样本的下标集合, <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>表示第属于第j类的权重，学习的参数</div><div class="notion-text notion-block-1d8979ddee53804e97dbfb595564ca4a">所以目标函数就可以写成:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380718420c3b370e6a525"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>为叶子节点的个数</div><div class="notion-text notion-block-1d8979ddee538067874cc13ba2e214f9">对方程进行求导后，可得参数</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380eb8926d79cce39cf33">再代入方程可得：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee538053908ad948719fbd2d">为简化表达式，我们定义 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>，含义如下：</div><ul class="notion-list notion-list-disc notion-block-1d8979ddee5380c8a7d3d5d41c79a73d"><li><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>: 叶子结点 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 所包含样本的一阶偏导数 累加之和，是一个常量；</li></ul><ul class="notion-list notion-list-disc notion-block-1d8979ddee5380c09227e676ec149bb3"><li><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>: 叶子结点 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 所包含样本的二阶偏导数累加之和，是一个常量 </li></ul><div class="notion-text notion-block-1d8979ddee538069a7c3f5a219f27cec">上述式子就可写成</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-1d8979ddee5380e3a100da8a6267b725"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1d8979ddee53809392d0fae18aa7d6cd" data-id="1d8979ddee53809392d0fae18aa7d6cd"><span><div id="1d8979ddee53809392d0fae18aa7d6cd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1d8979ddee53809392d0fae18aa7d6cd" title="树的生成"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">树的生成</span></span></h3><div class="notion-text notion-block-1d8979ddee538054a137d06d88721fd6">生成树的一个关键问题是要怎么找到特征的最优切分点，以及特征的选择</div><div class="notion-text notion-block-1d8979ddee5380279e54c14c344fc1f0">XGBoost支持两种算法，一是贪心策略，二是近似优化</div><ul class="notion-list notion-list-disc notion-block-1d8979ddee5380c8b2efda07cc0e5da5"><li>贪心</li></ul><div class="notion-text notion-block-1d8979ddee53800282f7d43f6246502e">贪心的思路是：针对每个特征，把属于该节点的训练样本根据该特征值进行升序排列，通过线性扫描的方式来决定该特征的最佳分裂点，并记录该特征的分裂收益；</div><div class="notion-text notion-block-1d8979ddee5380a9af9dc6b7c683031d">选择收益最大的特征作为分裂特征，用该特征的最佳分裂点作为分裂位置，在该节点上分裂出左右两个新的叶节点，</div><div class="notion-text notion-block-1d8979ddee53804aa956e9d9fb933136">然后一直递归执行直到满足特定条件为止。</div><div class="notion-text notion-block-1d8979ddee538073ba62f092937bcd07">计算每个特征分裂的关键逻辑是用什么去评价最优的切分点，树模型如ID3、C4.5或者CART，都有衡量的方式，分别是信息增益，信息增益率计基尼系数。XGBoost的计算逻辑是分类后左右节点的增益和未分裂的增益。</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><ul class="notion-list notion-list-disc notion-block-1dc979ddee5380ec8cd9cd44bb0507c8"><li>近似算法</li></ul><div class="notion-text notion-block-1dc979ddee53804c99c6d4c8c3044887">考虑贪心算法的寻找最优分割点的时间复杂度以及所需内存，近似算法给出近似的最优解，其思路主要是对于每个特征只考察每个分位点，这样就可以减少很多计算量。</div><div class="notion-text notion-block-1dc979ddee538060bac0c7c96ec705ba">该算法会首先根据特征分布的分位数提出候选划分点，然后将连续型特征映射到由这些候选点划分的桶中，然后聚合统计信息找到所有区间的最佳分裂点。</div><div class="notion-blank notion-block-1dc979ddee53809b9cdecc6b085da243"> </div><div class="notion-text notion-block-1dc979ddee53808cb68ffbfa14e9f2ce">上述按分位点进行分桶虽然降低了计算复杂度，但是分桶还可以做的相对更有说服力一些，</div><div class="notion-text notion-block-1dc979ddee53800b94e5e1dfe8325369">就有了 <b>加权分位数缩略图</b>，不是简单的按照样本分位数进行划分，而是以二阶导数 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>作为样本的权重进行划分</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1dc979ddee5380daaa05ca1f29a6d59b"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:506px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A1b8f78d3-fb5c-49cd-86e1-39cd94ddd2ec%3Aimage.png?table=block&amp;id=1dc979dd-ee53-80da-aa05-ca1f29a6d59b&amp;t=1dc979dd-ee53-80da-aa05-ca1f29a6d59b" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1d8979ddee538031a529fce5dcb00e0c">我们整理一下目标函数知道：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380eeb914d3f11677518a">整理一下公式可以得到：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1d8979ddee5380d7b0b5e1efe4799347">便可以看出 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>有对 loss 加权的作用,并且加权的式子为每个样本的残差或者说一阶导数的负梯度 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>,用二阶梯度划分逻辑我理解为，二阶梯度分位数其权重对残差的影响一致，那最佳分类点就是一阶负梯度方向下降最快的。</div><div class="notion-blank notion-block-1dc979ddee5380daa58dfc76ab637e3f"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1dc979ddee5380edbab6dd42c4b79733" data-id="1dc979ddee5380edbab6dd42c4b79733"><span><div id="1dc979ddee5380edbab6dd42c4b79733" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1dc979ddee5380edbab6dd42c4b79733" title="防止过拟合策略"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">防止过拟合策略</span></span></h3><ul class="notion-list notion-list-disc notion-block-1dc979ddee538054a07afb5f7af580a6"><li><b>Shrinkage方法</b></li></ul><div class="notion-text notion-block-1dc979ddee5380feb85efded1ebc7e4d">核心是增加一个衰减因子 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-blank notion-block-1dc979ddee5380588436fe190604f14d"> </div><ul class="notion-list notion-list-disc notion-block-1dc979ddee538033810be75950afad6c"><li><b>列采样方法</b></li></ul><div class="notion-text notion-block-1dc979ddee53808b89a4fa441969a11e">列采样方法类似于随机森林的处理思路，生成树模型的时候通过抽样部分特征来进行实现，在防止过拟合的同时还可以减少训练时间。</div><div class="notion-blank notion-block-1dd979ddee53802c8292ddd8e7092bbe"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1dc979ddee5380c4af16f0fae6886436" data-id="1dc979ddee5380c4af16f0fae6886436"><span><div id="1dc979ddee5380c4af16f0fae6886436" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1dc979ddee5380c4af16f0fae6886436" title="缺失值处理"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">缺失值处理</span></span></h3><ul class="notion-list notion-list-disc notion-block-1dd979ddee5380cd8788fa0539fbba33"><li>如果弱学习器为gblinear，由于线性模型不支持缺失值，会将缺失值填充为0</li></ul><ul class="notion-list notion-list-disc notion-block-1dd979ddee538038becdc52a7fcb2f09"><li>如果弱学习器是gbtree或dart，则支持缺失值</li><ul class="notion-list notion-list-disc notion-block-1dd979ddee538038becdc52a7fcb2f09"><li>训练过程</li><ul class="notion-list notion-list-disc notion-block-1dd979ddee5380989959daf387a2d69f"><li>如果特征出现缺失值，则分别放左右子树，那边增益大则放哪边</li></ul><li>预测阶段</li><ul class="notion-list notion-list-disc notion-block-1dd979ddee538067b305fa398acaed08"><li>如果特征出现缺失值，又分为两种情况</li><ul class="notion-list notion-list-disc notion-block-1dd979ddee53800cacfaff62f9af1f15"><li>如果该特征在训练过程中出现缺失值则按训练过程缺失值处理的方向就行</li><li>如果该特征在训练过程中未出现缺失值，将默认划分到左子树</li></ul></ul></ul></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1dc979ddee538092aac0e6e0698a3319" data-id="1dc979ddee538092aac0e6e0698a3319"><span><div id="1dc979ddee538092aac0e6e0698a3319" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1dc979ddee538092aac0e6e0698a3319" title="优缺点"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title"><b>优缺点</b></span></span></h4><div class="notion-text notion-block-1dc979ddee5380cb98ebfc812f30094a"><b>优点</b></div><ol start="1" class="notion-list notion-list-numbered notion-block-1dc979ddee53804bbda7d1e336ed94bc" style="list-style-type:decimal"><li><b>精度更高：</b>GBDT 只用到一阶泰勒展开，而 XGBoost 对损失函数进行了二阶泰勒展开。XGBoost 引入二阶导一方面是为了增加精度，另一方面也是为了能够自定义损失函数，二阶泰勒展开可以近似大量损失函数；</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1dc979ddee5380e28d11e840659b4bca" style="list-style-type:decimal"><li><b>灵活性更强：</b>GBDT 以 CART 作为基分类器，XGBoost 不仅支持 CART 还支持线性分类器，（使用线性分类器的 XGBoost 相当于带 L1 和 L2 正则化项的逻辑斯蒂回归（分类问题）或者线性回归（回归问题））。此外，XGBoost 工具支持自定义损失函数，只需函数支持一阶和二阶求导；</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1dc979ddee5380f096aac46ff9a95809" style="list-style-type:decimal"><li><b>正则化：</b>XGBoost 在目标函数中加入了正则项，用于控制模型的复杂度。正则项里包含了树的叶子节点个数、叶子节点权重的 L2 范式。正则项降低了模型的方差，使学习出来的模型更加简单，有助于防止过拟合；</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-1dc979ddee53804eb26dc835a95049ec" style="list-style-type:decimal"><li><b>Shrinkage（缩减）：</b>相当于学习速率。XGBoost 在进行完一次迭代后，会将叶子节点的权重乘上该系数，主要是为了削弱每棵树的影响，让后面有更大的学习空间；</li></ol><ol start="5" class="notion-list notion-list-numbered notion-block-1dc979ddee538058bfe3e6188d5fa02b" style="list-style-type:decimal"><li><b>列抽样：</b>XGBoost 借鉴了随机森林的做法，支持列抽样，不仅能降低过拟合，还能减少计算；</li></ol><ol start="6" class="notion-list notion-list-numbered notion-block-1dc979ddee5380b58e73f92c58386b85" style="list-style-type:decimal"><li><b>缺失值处理：</b>XGBoost 采用的稀疏感知算法极大的加快了节点分裂的速度；</li></ol><ol start="7" class="notion-list notion-list-numbered notion-block-1dc979ddee53800db39ed13c1896d194" style="list-style-type:decimal"><li><b>可以并行化操作：</b>块结构可以很好的支持并行计算。</li></ol><div class="notion-text notion-block-1dc979ddee5380658b3ce862d59f6076"><b>缺点</b></div><ol start="1" class="notion-list notion-list-numbered notion-block-1dc979ddee53807f815eda3299b9c0c8" style="list-style-type:decimal"><li>虽然利用预排序和近似算法可以降低寻找最佳分裂点的计算量，但在节点分裂过程中仍需要遍历数据集；</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1dc979ddee538016925fe080238daf4b" style="list-style-type:decimal"><li>预排序过程的空间复杂度过高，不仅需要存储特征值，还需要存储特征对应样本的梯度统计值的索引，相当于消耗了两倍的内存。</li></ol><div class="notion-blank notion-block-209979ddee5380e9935af2f671b94e77"> </div><div class="notion-text notion-block-209979ddee53808d9a93df73e4657231"><span class="notion-link-mention"><a href="https://zhuanlan.zhihu.com/p/625318418" target="_blank" rel="noopener noreferrer" class="notion-link-mention-link"><img class="notion-link-mention-icon"/><span class="notion-link-mention-title">zhuanlan.zhihu.com</span></a><div class="notion-link-mention-preview"><article class="notion-link-mention-card"><img class="notion-link-mention-preview-thumbnail" alt="zhuanlan.zhihu.com" referrerPolicy="same-origin"/><div class="notion-link-mention-preview-content"><p class="notion-link-mention-preview-title">zhuanlan.zhihu.com</p><p class="notion-link-mention-preview-description"></p><div class="notion-link-mention-preview-footer"><img class="notion-link-mention-preview-icon" referrerPolicy="same-origin"/><span class="notion-link-mention-preview-provider"></span></div></div></article></div></span></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[机器学习白板推导-核方法]]></title>
            <link>https://www.duanyc.xyz//机器学习/1c1979dd-ee53-80bb-9481-f68fea28e963</link>
            <guid>https://www.duanyc.xyz//机器学习/1c1979dd-ee53-80bb-9481-f68fea28e963</guid>
            <pubDate>Tue, 25 Mar 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1c1979ddee5380bb9481f68fea28e963"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1c1979ddee5380dbb7bdf345a1a94b1d" data-id="1c1979ddee5380dbb7bdf345a1a94b1d"><span><div id="1c1979ddee5380dbb7bdf345a1a94b1d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1c1979ddee5380dbb7bdf345a1a94b1d" title="一、线性不可分问题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一、线性不可分问题</span></span></h3><div class="notion-text notion-block-1c1979ddee53801fa50fcb5158918aef">有时线性可分的数据夹杂一点噪声，可以通过改进算法来实现分类，比如感知机的口袋算法和支持向量机的软间隔。但是有时候数据往往完全不是线性可分的，比如下面这种情况(异或问题)：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1c1979ddee53800bb131d7ca9948a328"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:615px;max-width:100%;flex-direction:column"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A6e2faa4b-5247-44ec-9157-f698399446fe%3Aimage.png?table=block&amp;id=1c1979dd-ee53-800b-b131-d7ca9948a328&amp;t=1c1979dd-ee53-800b-b131-d7ca9948a328" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-text notion-block-1c1979ddee53803ea087f157a065e489">在异或问题中数据往往不是线性可分的，但通过将数据映射到高维空间后就可以实现线性可分。可以认为高纬空间中的数据比低维空间的数据更易线性可分。对于异或问题，我们可以通过寻找一个映射 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>将低维空间中的数据x映射成高维空间中的z来实现数据的线性可分，例如:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee538006ab38fdebead5dbf4">然后在新的空间中，该数据就可以实现线性可分：</div><figure class="notion-asset-wrapper notion-asset-wrapper-image notion-block-1c1979ddee538062af4cfe9848683b8e"><div style="position:relative;display:flex;justify-content:center;align-self:center;width:100%;max-width:100%;flex-direction:column;height:100%"><img style="object-fit:cover" src="https://www.notion.so/image/attachment%3A217cc660-0148-46ed-a1e3-0fb660791b41%3Aimage.png?table=block&amp;id=1c1979dd-ee53-8062-af4c-fe9848683b8e&amp;t=1c1979dd-ee53-8062-af4c-fe9848683b8e" alt="notion image" loading="lazy" decoding="async"/></div></figure><div class="notion-blank notion-block-1c1979ddee5380b7aea6e510a1c5dd5b"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1c1979ddee538055acead119d4edb498" data-id="1c1979ddee538055acead119d4edb498"><span><div id="1c1979ddee538055acead119d4edb498" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1c1979ddee538055acead119d4edb498" title="二、核方法的引出"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">二、核方法的引出</span></span></h3><div class="notion-text notion-block-1c1979ddee5380f289fce98622508a38">映射到高维空间以后出现的问题是计算复杂度的加大，例如在支持向量机的求解过程中求解的优化问题可以转换为如下的优化问题：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee53809ea6bdd968fba867b3">将数据映射到高维空间后也就需要求解以下优化问题：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee53805bb7dae4ec098899b4">将数据映射到高维空间后也就需要求解以下优化问题:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee538080bc9beb76f8a2f542">将数据拓展到高维的方法可以用来解决完全非线性的问题</div><table class="notion-simple-table notion-block-1c1979ddee53807b875be66083293a7f"><tbody><tr class="notion-simple-table-row notion-block-1c1979ddee5380828938f10311e51ef3"><td class="" style="width:120px"><div class="notion-simple-table-cell">线性可分</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">容许一点点错误</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">严格非线性</div></td></tr><tr class="notion-simple-table-row notion-block-1c1979ddee5380719400dabdaa69c4a0"><td class="" style="width:120px"><div class="notion-simple-table-cell">PLA</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Pocker Alorithm</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"> <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>+PLA</div></td></tr><tr class="notion-simple-table-row notion-block-1c1979ddee5380fbb4b7e24a261786e5"><td class="" style="width:120px"><div class="notion-simple-table-cell">Hard-Margin SVM</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell">Soft-Margin SVM</div></td><td class="" style="width:120px"><div class="notion-simple-table-cell"> <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>+Hard-Margin SVM</div></td></tr></tbody></table><div class="notion-text notion-block-1c1979ddee538035aca2f696788148e0">然而在上边的方法中如果先将 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>与 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>计算出来然后再做点积，由于维度特别高加之得到 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>与 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>也需要计算量，因此计算量是相当大的，因此就有了核方法</div><div class="notion-text notion-block-1c1979ddee53802ea8e5fe6c0fd7abf9">通过使用核函数我们可以直接得到<span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>与 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span>的内积，正定核函数定义如下:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee5380dcaa37f15ec2537548">则称K(x,x)是一个正定核函数</div><div class="notion-text notion-block-1c1979ddee538082859ce7d89016ff67">其中 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span> 是Hilbert空间（完备的可能是无限维的被赋予内积的线性空间），如果去掉内积这个条件我们简单地称为核函数。</div><div class="notion-text notion-block-1c1979ddee53805d8f01c40868fe7bd5">Hilbert空间定义中的完备指的是对极限是封闭的，被赋予内积代表空间中的元素满足以下性质：</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee5380ab9fc9e00f2606fe6a">因为支持向量机的求解只用到内积运算，所以使用核函数会大大简化运算量。</div><div class="notion-blank notion-block-1c1979ddee5380d99dc3c45341664ce2"> </div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1c1979ddee53808d958df3b4b49e29f9" data-id="1c1979ddee53808d958df3b4b49e29f9"><span><div id="1c1979ddee53808d958df3b4b49e29f9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1c1979ddee53808d958df3b4b49e29f9" title="三、正定核函数的证明"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">三、正定核函数的证明</span></span></h3><div class="notion-text notion-block-1c1979ddee5380adae6be2903e004319">正定核函数还有另外一个定义</div><div class="notion-text notion-block-1c1979ddee5380e7b24adc43b360bcb9">如果核函数满足以下两条性质:</div><ul class="notion-list notion-list-disc notion-block-1c1979ddee5380bfa83ef6390f4df82e"><li>对称性</li></ul><ul class="notion-list notion-list-disc notion-block-1c1979ddee5380799a41c0765b410a3f"><li>正定性</li></ul><div class="notion-text notion-block-1c1979ddee5380c28867dcc1d47f109d">则称核函数K(x,z)为正定核函数</div><div class="notion-text notion-block-1c1979ddee5380b8a26aceae83cb1c00">这个定义也就是正定核函数的充要条件，其中两条性质分别指的是</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee53808d94a5d0f1708c3419"><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><ul class="notion-list notion-list-disc notion-block-1c1979ddee5380678528cbb3940cd2b7"><li><span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><div class="notion-text notion-block-1c1979ddee5380529a26ee044fb69daa">首先证明对称性</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee53803c982dd047f3819b2d">又内积具有对称性，即 <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee5380909e77dcc87fce13d5">然后证明:</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee5380729678e5bb16c3a9fb">所以k是半正定的</div><ul class="notion-list notion-list-disc notion-block-1c1979ddee538067a0bfc104dbdd302b"><li> <span role="button" tabindex="0" class="notion-equation notion-equation-inline"><span></span></span></li></ul><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span><div class="notion-text notion-block-1c1979ddee5380ff917cff45bee5c0e0">故而得证</div><div class="notion-text notion-block-1c1979ddee538053b100ced39b214377">说明一下证明矩阵半正定的两种方法</div><span role="button" tabindex="0" class="notion-equation notion-equation-block"><span></span></span></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>