You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgi29wjsp/_book/linear_regression.html

651 lines
62 KiB

5 years ago
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>最简单的回归算法-线性回归 · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-katex/katex.min.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="logistic_regression.html" />
<link rel="prev" href="kNN.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="./">
<a href="./">
简介
</a>
</li>
<li class="chapter " data-level="1.2" data-path="machine_learning.html">
<a href="machine_learning.html">
机器学习概述
</a>
</li>
<li class="chapter " data-level="1.3" data-path="algorithm.html">
<a href="algorithm.html">
常见机器学习算法
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="kNN.html">
<a href="kNN.html">
近朱者赤近墨者黑-kNN
</a>
</li>
<li class="chapter active" data-level="1.3.2" data-path="linear_regression.html">
<a href="linear_regression.html">
最简单的回归算法-线性回归
</a>
</li>
<li class="chapter " data-level="1.3.3" data-path="logistic_regression.html">
<a href="logistic_regression.html">
使用回归的思想进行分类-逻辑回归
</a>
</li>
<li class="chapter " data-level="1.3.4" data-path="decision_tree.html">
<a href="decision_tree.html">
最接近人类思维的算法-决策树
</a>
</li>
<li class="chapter " data-level="1.3.5" data-path="random_forest.html">
<a href="random_forest.html">
群众的力量是伟大的-随机森林
</a>
</li>
<li class="chapter " data-level="1.3.6" data-path="kMeans.html">
<a href="kMeans.html">
物以类聚人以群分-kMeans
</a>
</li>
<li class="chapter " data-level="1.3.7" data-path="AGNES.html">
<a href="AGNES.html">
以距离为尺-AGNES
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="metrics.html">
<a href="metrics.html">
模型评估指标
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="classification_metrics.html">
<a href="classification_metrics.html">
分类性能评估指标
</a>
</li>
<li class="chapter " data-level="1.4.2" data-path="regression_metrics.html">
<a href="regression_metrics.html">
回归性能评估指标
</a>
</li>
<li class="chapter " data-level="1.4.3" data-path="cluster_metrics.html">
<a href="cluster_metrics.html">
聚类性能评估指标
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" data-path="sklearn.html">
<a href="sklearn.html">
使用sklearn进行机器学习
</a>
</li>
<li class="chapter " data-level="1.6" >
<span>
综合实战案例
</span>
<ul class="articles">
<li class="chapter " data-level="1.6.1" >
<span>
泰坦尼克生还预测
</span>
<ul class="articles">
<li class="chapter " data-level="1.6.1.1" data-path="titanic/introduction.html">
<a href="titanic/introduction.html">
简介
</a>
</li>
<li class="chapter " data-level="1.6.1.2" data-path="titanic/EDA.html">
<a href="titanic/EDA.html">
探索性数据分析(EDA)
</a>
</li>
<li class="chapter " data-level="1.6.1.3" data-path="titanic/feature engerning.html">
<a href="titanic/feature engerning.html">
特征工程
</a>
</li>
<li class="chapter " data-level="1.6.1.4" data-path="titanic/fit and predict.html">
<a href="titanic/fit and predict.html">
构建模型进行预测
</a>
</li>
<li class="chapter " data-level="1.6.1.5" data-path="titanic/tuning.html">
<a href="titanic/tuning.html">
调参
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.6.2" >
<span>
使用强化学习玩乒乓球游戏
</span>
<ul class="articles">
<li class="chapter " data-level="1.6.2.1" data-path="pingpong/what is reinforce learning.html">
<a href="pingpong/what is reinforce learning.html">
什么是强化学习
</a>
</li>
<li class="chapter " data-level="1.6.2.2" data-path="pingpong/Policy Gradient.html">
<a href="pingpong/Policy Gradient.html">
Policy Gradient原理
</a>
</li>
<li class="chapter " data-level="1.6.2.3" data-path="pingpong/coding.html">
<a href="pingpong/coding.html">
使用Policy Gradient玩乒乓球游戏
</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="recommand.html">
<a href="recommand.html">
实训推荐
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >最简单的回归算法-线性回归</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="&#x6700;&#x7B80;&#x5355;&#x7684;&#x56DE;&#x5F52;&#x7B97;&#x6CD5;-&#x7EBF;&#x6027;&#x56DE;&#x5F52;">&#x6700;&#x7B80;&#x5355;&#x7684;&#x56DE;&#x5F52;&#x7B97;&#x6CD5;-&#x7EBF;&#x6027;&#x56DE;&#x5F52;</h1>
<h2 id="&#x4EC0;&#x4E48;&#x662F;&#x7EBF;&#x6027;&#x56DE;&#x5F52;">&#x4EC0;&#x4E48;&#x662F;&#x7EBF;&#x6027;&#x56DE;&#x5F52;</h2>
<p>&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x662F;&#x4EC0;&#x4E48;&#x610F;&#x601D;&#xFF1F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x62C6;&#x5B57;&#x91CA;&#x4E49;&#x3002;&#x56DE;&#x5F52;&#x80AF;&#x5B9A;&#x4E0D;&#x7528;&#x6211;&#x591A;&#x8BF4;&#x4E86;&#xFF0C;&#x90A3;&#x4EC0;&#x4E48;&#x662F;&#x7EBF;&#x6027;&#x5462;&#xFF1F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x56DE;&#x5FC6;&#x4E00;&#x4E0B;&#x521D;&#x4E2D;&#x65F6;&#x5B66;&#x8FC7;&#x7684;&#x76F4;&#x7EBF;&#x65B9;&#x7A0B;&#xFF1A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>y</mi><mo>=</mo><mi>k</mi><mo>&#x2217;</mo><mi>x</mi><mo>+</mo><mi>b</mi></mrow><annotation encoding="application/x-tex">y=k*x+b</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.03588em;">y</span><span class="mrel">=</span><span class="mord mathit" style="margin-right:0.03148em;">k</span><span class="mbin">&#x2217;</span><span class="mord mathit">x</span><span class="mbin">+</span><span class="mord mathit">b</span></span></span></span></p>
<p>&#x8FD9;&#x4E2A;&#x5F0F;&#x5B50;&#x8868;&#x8FBE;&#x7684;&#x662F;&#xFF0C;&#x5F53;&#x6211;&#x77E5;&#x9053; k&#xFF08;&#x53C2;&#x6570;&#xFF09;&#x548C; b&#xFF08;&#x53C2;&#x6570;&#xFF09;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x6211;&#x968F;&#x4FBF;&#x7ED9;&#x4E00;&#x4E2A; x &#x6211;&#x90FD;&#x80FD;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x65B9;&#x7A0B;&#x7B97;&#x51FA; y &#x6765;&#x3002;&#x800C;&#x4E14;&#x5462;&#xFF0C;&#x8FD9;&#x4E2A;&#x5F0F;&#x5B50;&#x662F;&#x7EBF;&#x6027;&#x7684;&#xFF0C;&#x4E3A;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;&#x56E0;&#x4E3A;&#x4ECE;&#x76F4;&#x89C9;&#x4E0A;&#x6765;&#x8BF4;&#xFF0C;&#x4F60;&#x90FD;&#x77E5;&#x9053;&#xFF0C;&#x8FD9;&#x4E2A;&#x5F0F;&#x5B50;&#x7684;&#x51FD;&#x6570;&#x56FE;&#x50CF;&#x662F;&#x6761;&#x76F4;&#x7EBF;&#x3002;</p>
<p>&#x4ECE;&#x7406;&#x8BBA;&#x4E0A;&#x6765;&#x8BF4;&#xFF0C;&#x8FD9;&#x5F0F;&#x5B50;&#x6EE1;&#x8DB3;&#x7EBF;&#x6027;&#x7CFB;&#x7EDF;&#x7684;&#x6027;&#x8D28;(&#x81F3;&#x4E8E;&#x7EBF;&#x6027;&#x7CFB;&#x7EDF;&#x662F;&#x4EC0;&#x4E48;&#xFF0C;&#x53EF;&#x4EE5;&#x67E5;&#x9605;&#x76F8;&#x5173;&#x8D44;&#x6599;&#xFF0C;&#x8FD9;&#x91CC;&#x5C31;&#x4E0D;&#x591A;&#x505A;&#x8D58;&#x8FF0;&#x4E86;&#xFF0C;&#x4E0D;&#x7136;&#x6CA1;&#x5B8C;&#x6CA1;&#x4E86;)&#x3002;&#x60A8;&#x53EF;&#x80FD;&#x4F1A;&#x89C9;&#x5F97;&#x7591;&#x60D1;&#xFF0C;&#x8FD9;&#x4E00;&#x8282;&#x8981;&#x8BF4;&#x7684;&#x662F;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#xFF0C;&#x6211;&#x8BF4;&#x4E2A;&#x8FD9;&#x4E48; low &#x76F4;&#x7EBF;&#x65B9;&#x7A0B;&#x5E72;&#x5565;&#xFF1F;&#x5176;&#x5B9E;&#xFF0C;&#x8BF4;&#x767D;&#x4E86;&#xFF0C;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x5C31;&#x662F;&#x5728; N &#x7EF4;&#x7A7A;&#x95F4;&#x4E2D;&#x627E;&#x4E00;&#x4E2A;&#x5F62;&#x5F0F;&#x50CF;&#x76F4;&#x7EBF;&#x65B9;&#x7A0B;&#x4E00;&#x6837;&#x7684;&#x51FD;&#x6570;&#x6765;&#x62DF;&#x5408;&#x6570;&#x636E;&#x800C;&#x5DF2;&#x3002;&#x6BD4;&#x5982;&#x8BF4;&#xFF0C;&#x6211;&#x73B0;&#x5728;&#x6709;&#x8FD9;&#x4E48;&#x4E00;&#x5F20;&#x56FE;&#xFF0C;&#x6A2A;&#x5750;&#x6807;&#x4EE3;&#x8868;&#x623F;&#x5B50;&#x7684;&#x9762;&#x79EF;&#xFF0C;&#x7EB5;&#x5750;&#x6807;&#x4EE3;&#x8868;&#x623F;&#x4EF7;&#x3002;</p>
<p><img src="img/10.jpg" alt=""></p>
<p>&#x7136;&#x540E;&#x5462;&#xFF0C;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x5C31;&#x662F;&#x8981;&#x627E;&#x4E00;&#x6761;&#x76F4;&#x7EBF;&#xFF0C;&#x5E76;&#x4E14;&#x8BA9;&#x8FD9;&#x6761;&#x76F4;&#x7EBF;&#x5C3D;&#x53EF;&#x80FD;&#x5730;&#x62DF;&#x5408;&#x56FE;&#x4E2D;&#x7684;&#x6570;&#x636E;&#x70B9;&#x3002; </p>
<p>&#x90A3;&#x5982;&#x679C;&#x8BA9; 1000 &#x4F4D;&#x670B;&#x53CB;&#x6765;&#x627E;&#x8FD9;&#x6761;&#x76F4;&#x7EBF;&#x5C31;&#x53EF;&#x80FD;&#x627E;&#x51FA; 1000 &#x79CD;&#x76F4;&#x7EBF;&#x6765;&#xFF0C;&#x6BD4;&#x5982;&#x8FD9;&#x6837;</p>
<p><img src="img/11.jpg" alt=""></p>
<p>&#x8FD9;&#x6837;</p>
<p><img src="img/12.jpg" alt=""></p>
<p>&#x6216;&#x8005;&#x8FD9;&#x6837;</p>
<p><img src="img/13.jpg" alt=""></p>
<p>&#x558F;&#xFF0C;&#x5176;&#x5B9E;&#x627E;&#x76F4;&#x7EBF;&#x7684;&#x8FC7;&#x7A0B;&#x5C31;&#x662F;&#x5728;&#x505A;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#xFF0C;&#x53EA;&#x4E0D;&#x8FC7;&#x8FD9;&#x4E2A;&#x53EB;&#x6CD5;&#x66F4;&#x6709;&#x9AD8;&#x5927;&#x4E0A;&#x800C;&#x5DF2;&#x3002;</p>
<h2 id="&#x635F;&#x5931;&#x51FD;&#x6570;">&#x635F;&#x5931;&#x51FD;&#x6570;</h2>
<p>&#x90A3;&#x65E2;&#x7136;&#x662F;&#x627E;&#x76F4;&#x7EBF;&#xFF0C;&#x90A3;&#x80AF;&#x5B9A;&#x662F;&#x8981;&#x6709;&#x4E00;&#x4E2A;&#x8BC4;&#x5224;&#x7684;&#x6807;&#x51C6;&#xFF0C;&#x6765;&#x8BC4;&#x5224;&#x54EA;&#x6761;&#x76F4;&#x7EBF;&#x624D;&#x662F;&#x6700;&#x597D;&#x7684;&#x3002;OK&#xFF0C;&#x9053;&#x7406;&#x6211;&#x4EEC;&#x90FD;&#x61C2;&#xFF0C;&#x90A3;&#x548B;&#x8BC4;&#x5224;&#x5462;&#xFF1F;&#x5176;&#x5B9E;&#x53EA;&#x8981;&#x7B97;&#x4E00;&#x4E0B;&#x5B9E;&#x9645;&#x623F;&#x4EF7;&#x548C;&#x6211;&#x627E;&#x51FA;&#x7684;&#x76F4;&#x7EBF;&#x6839;&#x636E;&#x623F;&#x5B50;&#x5927;&#x5C0F;&#x9884;&#x6D4B;&#x51FA;&#x6765;&#x7684;&#x623F;&#x4EF7;&#x4E4B;&#x95F4;&#x7684;&#x5DEE;&#x8DDD;&#x5C31;&#x884C;&#x4E86;&#x3002;&#x8BF4;&#x767D;&#x4E86;&#x5C31;&#x662F;&#x7B97;&#x4E24;&#x70B9;&#x7684;&#x8DDD;&#x79BB;&#x3002;&#x5F53;&#x6211;&#x4EEC;&#x628A;&#x6240;&#x6709;&#x5B9E;&#x9645;&#x623F;&#x4EF7;&#x548C;&#x9884;&#x6D4B;&#x51FA;&#x6765;&#x7684;&#x623F;&#x4EF7;&#x7684;&#x5DEE;&#x8DDD;&#xFF08;&#x8DDD;&#x79BB;&#xFF09;&#x7B97;&#x51FA;&#x6765;&#x7136;&#x540E;&#x505A;&#x4E2A;&#x52A0;&#x548C;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x80FD;&#x91CF;&#x5316;&#x51FA;&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x9884;&#x6D4B;&#x7684;&#x623F;&#x4EF7;&#x548C;&#x5B9E;&#x9645;&#x623F;&#x4EF7;&#x4E4B;&#x95F4;&#x7684;&#x8BEF;&#x5DEE;&#x3002;&#x4F8B;&#x5982;&#x4E0B;&#x56FE;&#x4E2D;&#x6211;&#x753B;&#x4E86;&#x5F88;&#x591A;&#x6761;&#x5C0F;&#x6570;&#x7EBF;&#xFF0C;&#x6BCF;&#x4E00;&#x6761;&#x5C0F;&#x6570;&#x7EBF;&#x5C31;&#x662F;&#x5B9E;&#x9645;&#x623F;&#x4EF7;&#x548C;&#x9884;&#x6D4B;&#x623F;&#x4EF7;&#x7684;&#x5DEE;&#x8DDD;&#xFF08;&#x8DDD;&#x79BB;&#xFF09;&#x3002;</p>
<p><img src="img/14.jpg" alt=""></p>
<p>&#x7136;&#x540E;&#x628A;&#x6BCF;&#x6761;&#x5C0F;&#x7AD6;&#x7EBF;&#x7684;&#x957F;&#x5EA6;&#x52A0;&#x8D77;&#x6765;&#x5C31;&#x7B49;&#x4E8E;&#x6211;&#x4EEC;&#x73B0;&#x5728;&#x901A;&#x8FC7;&#x8FD9;&#x6761;&#x76F4;&#x7EBF;&#x9884;&#x6D4B;&#x51FA;&#x7684;&#x623F;&#x4EF7;&#x4E0E;&#x5B9E;&#x9645;&#x623F;&#x4EF7;&#x4E4B;&#x95F4;&#x7684;&#x5DEE;&#x8DDD;&#x3002;&#x90A3;&#x6BCF;&#x6761;&#x5C0F;&#x7AD6;&#x7EBF;&#x7684;&#x957F;&#x5EA6;&#x7684;&#x52A0;&#x548C;&#x600E;&#x4E48;&#x7B97;&#xFF1F;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x6B27;&#x5F0F;&#x8DDD;&#x79BB;&#x52A0;&#x548C;&#xFF0C;&#x516C;&#x5F0F;&#x4E3A;&#xFF1A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msubsup><mo>&#x2211;</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>m</mi></msubsup><mo>(</mo><msup><mi>y</mi><mrow><mo>(</mo><mi>i</mi><mo>)</mo></mrow></msup><mo>&#x2212;</mo><mi>y</mi><mover accent="true"><mrow><msup><mrow></mrow><mrow><mo>(</mo><mi>i</mi><mo>)</mo></mrow></msup></mrow><mo>^</mo></mover><msup><mo>)</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">\sum_{i=1}^m(y^{(i)}-y\hat{^{(i)}})^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:1.07744em;"></span><span class="strut bottom" style="height:1.37745em;vertical-align:-0.30001em;"></span><span class="base textstyle uncramped"><span class="mop"><span class="mop op-symbol small-op" style="top:-0.0000050000000000050004em;">&#x2211;</span><span class="msupsub"><span class="vlist"><span style="top:0.30001em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">i</span><span class="mrel mtight">=</span><span class="mord mathrm mtight">1</span></span></span></span><span style="top:-0.364em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathit mtight">m</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mord mathit" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist"><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord scriptstyle uncramped mtight"><span class="mopen mtight">(</span><span class="mord mathit mtight">i</span><span class="mclose mtight">)</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mbin">&#x2212;</span><span class="mord mathit" style="margin-right:0.03588em;">y</span><span class="mord accent"><span class="vlist"><span style="top:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="mord textstyle cramped"><span class="mord"><span></span><span class="msupsub"><span class="vlist"><span style="top:-0.289em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mopen mtight">(</span><span class="mord mathit mtight">i</span><span class="mclose mtight">)</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span><span style="top:-0.38299999999999995em;margin-left:0em;"><span class="fontsize-ensurer reset-size5
<p>&#x8FD9;&#x4E2A;&#x6B27;&#x6C0F;&#x8DDD;&#x79BB;&#x52A0;&#x548C;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x7528;&#x6765;&#x91CF;&#x5316;&#x9884;&#x6D4B;&#x7ED3;&#x679C;&#x548C;&#x771F;&#x5B9E;&#x7ED3;&#x679C;&#x7684;&#x8BEF;&#x5DEE;&#x7684;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x3002;&#x5728;&#x673A;&#x5668;&#x5B66;&#x4E60;&#x4E2D;&#x79F0;&#x5B83;&#x4E3A;<strong>&#x635F;&#x5931;&#x51FD;&#x6570;</strong>&#xFF08;&#x8BF4;&#x767D;&#x4E86;&#x5C31;&#x662F;&#x8BA1;&#x7B97;&#x8BEF;&#x5DEE;&#x7684;&#x51FD;&#x6570;&#xFF09;&#x3002;&#x90A3;&#x6709;&#x4E86;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x76F8;&#x5F53;&#x4E8E;&#x6709;&#x4E86;&#x4E00;&#x4E2A;&#x8BC4;&#x5224;&#x6807;&#x51C6;&#xFF0C;&#x5F53;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x503C;&#x8D8A;&#x5C0F;&#xFF0C;&#x5C31;&#x8D8A;&#x8BF4;&#x660E;&#x6211;&#x4EEC;&#x627E;&#x5230;&#x7684;&#x8FD9;&#x6761;&#x76F4;&#x7EBF;&#x8D8A;&#x80FD;&#x62DF;&#x5408;&#x6211;&#x4EEC;&#x7684;&#x623F;&#x4EF7;&#x6570;&#x636E;&#x3002;&#x6240;&#x4EE5;&#x8BF4;&#x554A;&#xFF0C;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x5C31;&#x662F;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x635F;&#x5931;&#x51FD;&#x6570;&#x505A;&#x4E3A;&#x8BC4;&#x5224;&#x6807;&#x51C6;&#x6765;&#x627E;&#x51FA;&#x4E00;&#x6761;&#x76F4;&#x7EBF;&#x3002;</p>
<p>&#x5982;&#x679C;&#x5047;&#x8BBE;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>h</mi><mrow><mo>(</mo><mi>&#x3B8;</mi><mo>)</mo></mrow></msub><mo>(</mo><mi>x</mi><mo>)</mo></mrow><annotation encoding="application/x-tex">h_{(\theta)}(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1.1052em;vertical-align:-0.3551999999999999em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">h</span><span class="msupsub"><span class="vlist"><span style="top:0.18019999999999992em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mopen mtight">(</span><span class="mord mathit mtight" style="margin-right:0.02778em;">&#x3B8;</span><span class="mclose mtight">)</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mopen">(</span><span class="mord mathit">x</span><span class="mclose">)</span></span></span></span>&#x8868;&#x793A;&#x5F53;&#x6743;&#x91CD;&#x4E3A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>&#x3B8;</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.69444em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.02778em;">&#x3B8;</span></span></span></span>&#xFF0C;&#x8F93;&#x5165;&#x4E3A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.43056em;"></span><span class="strut bottom" style="height:0.43056em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">x</span></span></span></span>&#x65F6;&#x8BA1;&#x7B97;&#x51FA;&#x6765;&#x7684;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>y</mi><mover accent="true"><mo>(</mo><mo>^</mo></mover><mi>i</mi><mo>)</mo></mrow><annotation encoding="application/x-tex">y \hat (i)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:1.01344em;"></span><span class="strut bottom" style="height:1.26344em;vertical-align:-0.25em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.03588em;">y</span><span class="mord accent"><span class="vlist"><span style="top:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="mopen">(</span></span><span style="top:-0.319em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="accent-body"><span>^</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span><span class="mord mathit">i</span><span class="mclose">)</span></span></span></span>&#xFF0C;&#x90A3;&#x4E48;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;&#x635F;&#x5931;&#x51FD;&#x6570;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>J</mi><mo>(</mo><mi>&#x3B8;</mi><mo>)</mo></mrow><annotation encoding="application/x-tex">J(\theta)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1em;vertical-align:-0.25em;"></span><span class="base textstyle unc
<p><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>J</mi><mo>(</mo><mi>&#x3B8;</mi><mo>)</mo><mo>=</mo><mfrac><mrow><mn>1</mn></mrow><mrow><mn>2</mn></mrow></mfrac><msubsup><mo>&#x2211;</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>m</mi></msubsup><mo>(</mo><msub><mi>h</mi><mi>&#x3B8;</mi></msub><mo>(</mo><msup><mi>x</mi><mi>i</mi></msup><mo>)</mo><mo>&#x2212;</mo><msup><mi>y</mi><mi>i</mi></msup><msup><mo>)</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">
J(\theta)=\frac{1}{2}\sum^m_{i=1}(h_\theta(x^i)-y^i)^2
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.845108em;"></span><span class="strut bottom" style="height:1.190108em;vertical-align:-0.345em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.09618em;">J</span><span class="mopen">(</span><span class="mord mathit" style="margin-right:0.02778em;">&#x3B8;</span><span class="mclose">)</span><span class="mrel">=</span><span class="mord reset-textstyle textstyle uncramped"><span class="mopen sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span><span class="mfrac"><span class="vlist"><span style="top:0.345em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">2</span></span></span></span><span style="top:-0.22999999999999998em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle textstyle uncramped frac-line"></span></span><span style="top:-0.394em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord scriptstyle uncramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span><span class="mclose sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span></span><span class="mop"><span class="mop op-symbol small-op" style="top:-0.0000050000000000050004em;">&#x2211;</span><span class="msupsub"><span class="vlist"><span style="top:0.30001em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">i</span><span class="mrel mtight">=</span><span class="mord mathrm mtight">1</span></span></span></span><span style="top:-0.364em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathit mtight">m</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mord mathit">h</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.02778em;">&#x3B8;</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathit mtight">i</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mclose">)</span><span class="mbin">&#x2212;</span><span class="mord"><span class="mord mathit" style="margin-right:0.03588em;">y</span><span class="msupsub"><span class="vlist"><span style="top:-0.363em
<h2 id="&#x600E;&#x6837;&#x8BA1;&#x7B97;&#x51FA;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;&#x89E3;&#xFF1F;">&#x600E;&#x6837;&#x8BA1;&#x7B97;&#x51FA;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;&#x89E3;&#xFF1F;</h2>
<p>&#x73B0;&#x5728;&#x60A8;&#x5E94;&#x8BE5;&#x5DF2;&#x7ECF;&#x5F04;&#x660E;&#x767D;&#x4E86;&#x4E00;&#x4E2A;&#x4E8B;&#x5B9E;&#xFF0C;&#x90A3;&#x5C31;&#x662F;&#x6211;&#x53EA;&#x8981;&#x627E;&#x5230;&#x4E00;&#x7EC4;&#x53C2;&#x6570;&#xFF08;&#x4E5F;&#x5C31;&#x662F;&#x7EBF;&#x6027;&#x65B9;&#x7A0B;&#x6BCF;&#x4E00;&#x9879;&#x4E0A;&#x7684;&#x7CFB;&#x6570;&#xFF09;&#x80FD;&#x8BA9;&#x6211;&#x7684;&#x635F;&#x5931;&#x51FD;&#x6570;&#x7684;&#x503C;&#x6700;&#x5C0F;&#xFF0C;&#x90A3;&#x6211;&#x8FD9;&#x4E00;&#x7EC4;&#x53C2;&#x6570;&#x5C31;&#x80FD;&#x6700;&#x597D;&#x7684;&#x62DF;&#x5408;&#x6211;&#x73B0;&#x5728;&#x7684;&#x8BAD;&#x7EC3;&#x6570;&#x636E;&#x3002;OK&#xFF0C;&#x90A3;&#x600E;&#x4E48;&#x6765;&#x627E;&#x5230;&#x8FD9;&#x4E00;&#x7EC4;&#x53C2;&#x6570;&#x5462;&#xFF1F;&#x5176;&#x5B9E;&#x6709;&#x4E24;&#x79CD;&#x5957;&#x8DEF;&#xFF0C;&#x4E00;&#x79CD;&#x5C31;&#x662F;&#x7528;&#x5927;&#x540D;&#x9F0E;&#x9F0E;&#x7684;<strong>&#x68AF;&#x5EA6;&#x4E0B;&#x964D;</strong>&#xFF0C;&#x5176;&#x5927;&#x6982;&#x601D;&#x60F3;&#x5C31;&#x662F;&#x6839;&#x636E;&#x6BCF;&#x4E2A;&#x53C2;&#x6570;&#x5BF9;&#x635F;&#x5931;&#x51FD;&#x6570;&#x7684;&#x504F;&#x5BFC;&#x6765;&#x66F4;&#x65B0;&#x53C2;&#x6570;&#x3002;&#x53E6;&#x4E00;&#x79CD;&#x662F;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;<strong>&#x6B63;&#x89C4;&#x65B9;&#x7A0B;&#x89E3;</strong>&#xFF0C;&#x8FD9;&#x540D;&#x5B57;&#x542C;&#x8D77;&#x6765;&#x9AD8;&#x5927;&#x4E0A;&#xFF0C;&#x5176;&#x5B9E;&#x672C;&#x8D28;&#x5C31;&#x662F;&#x6839;&#x636E;&#x4E00;&#x4E2A;&#x56FA;&#x5B9A;&#x7684;&#x5F0F;&#x5B50;&#x8BA1;&#x7B97;&#x51FA;&#x53C2;&#x6570;&#x3002;&#x7531;&#x4E8E;<strong>&#x6B63;&#x89C4;&#x65B9;&#x7A0B;&#x89E3;</strong>&#x5728;&#x6570;&#x636E;&#x91CF;&#x6BD4;&#x8F83;&#x5927;&#x7684;&#x65F6;&#x5019;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x6BD4;&#x8F83;&#x9AD8;&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x8FD9;&#x4E00;&#x90E8;&#x5206;&#x4E2D;&#xFF0C;&#x4E3B;&#x8981;&#x804A;&#x804A;&#x600E;&#x6837;&#x4F7F;&#x7528;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x7684;&#x65B9;&#x6CD5;&#x6765;&#x66F4;&#x65B0;&#x53C2;&#x6570;&#x3002;</p>
<h3 id="&#x4EC0;&#x4E48;&#x662F;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;">&#x4EC0;&#x4E48;&#x662F;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;</h3>
<p>&#x5176;&#x5B9E;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x673A;&#x5668;&#x5B66;&#x4E60;&#x7B97;&#x6CD5;&#xFF0C;&#x800C;&#x662F;&#x4E00;&#x79CD;&#x57FA;&#x4E8E;&#x641C;&#x7D22;&#x7684;&#x6700;&#x4F18;&#x5316;&#x65B9;&#x6CD5;&#x3002;&#x56E0;&#x4E3A;&#x5F88;&#x591A;&#x7B97;&#x6CD5;&#x90FD;&#x6CA1;&#x6709;&#x6B63;&#x89C4;&#x89E3;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x901A;&#x8FC7;&#x4E00;&#x6B21;&#x4E00;&#x6B21;&#x7684;&#x8FED;&#x4EE3;&#x6765;&#x627E;&#x5230;&#x627E;&#x5230;&#x4E00;&#x7EC4;&#x53C2;&#x6570;&#x80FD;&#x8BA9;&#x6211;&#x4EEC;&#x7684;&#x635F;&#x5931;&#x51FD;&#x6570;&#x6700;&#x5C0F;&#x3002;&#x635F;&#x5931;&#x51FD;&#x6570;&#x7684;&#x5927;&#x6982;&#x5957;&#x8DEF;&#x53EF;&#x4EE5;&#x53C2;&#x770B;&#x8FD9;&#x4E2A;&#x56FE;&#xFF1A;</p>
<p><img src="img/16.jpg" alt=""></p>
<p>&#x6240;&#x4EE5;&#x8BF4;&#xFF0C;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x4E0D;&#x65AD;&#x7684;&#x5BFB;&#x627E;&#x9760;&#x8C31;&#x7684;&#x6743;&#x91CD;&#x662F;&#x591A;&#x5C11;&#x3002;</p>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x77E5;&#x9053;&#x4E86;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x5C31;&#x662F;&#x7528;&#x6765;&#x627E;&#x6743;&#x91CD;&#x7684;&#xFF0C;&#x90A3;&#x600E;&#x4E48;&#x627E;&#x6743;&#x91CD;&#x5462;&#xFF1F;&#x778E;&#x731C;&#xFF1F;&#x4E0D;&#x53EF;&#x80FD;&#x7684;&#x3002;&#x3002;&#x8FD9;&#x8F88;&#x5B50;&#x90FD;&#x4E0D;&#x53EF;&#x80FD;&#x731C;&#x7684;&#x3002;&#x60F3;&#x60F3;&#x90FD;&#x77E5;&#x9053;&#xFF0C;&#x6743;&#x91CD;&#x7684;&#x53D6;&#x503C;&#x8303;&#x56F4;&#x53EF;&#x4EE5;&#x770B;&#x6210;&#x662F;&#x4E2A;&#x5B9E;&#x6570;&#x7A7A;&#x95F4;&#xFF0C;&#x90A3; 100 &#x4E2A;&#x7279;&#x5F81;&#x5C31;&#x5BF9;&#x5E94;&#x7740; 100 &#x4E2A;&#x6743;&#x91CD;&#xFF0C;10000 &#x4E2A;&#x7279;&#x5F81;&#x5C31;&#x5BF9;&#x5E94;&#x7740; 10000 &#x4E2A;&#x6743;&#x91CD;&#x3002;&#x5982;&#x679C;&#x9760;&#x778E;&#x731C;&#x6743;&#x91CD;&#x7684;&#x8BDD;&#x3002;&#x5E94;&#x8BE5;&#x8FD9;&#x8F88;&#x5B50;&#x90FD;&#x731C;&#x4E0D;&#x4E2D;&#x4E86;&#x3002;&#x6240;&#x4EE5;&#x627E;&#x6743;&#x91CD;&#x7684;&#x627E;&#x4E2A;&#x5957;&#x8DEF;&#x6765;&#x627E;&#xFF0C;&#x8FD9;&#x4E2A;&#x5957;&#x8DEF;&#x5C31;&#x662F;<strong>&#x68AF;&#x5EA6;</strong>&#x3002;<strong>&#x68AF;&#x5EA6;</strong>&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x8BA9;&#x51FD;&#x6570;&#x503C;&#x4E3A; 0 &#x65F6;&#x5176;&#x4E2D;&#x5404;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x504F;&#x5BFC;&#x6240;&#x7EC4;&#x6210;&#x7684;&#x5411;&#x91CF;&#xFF0C;&#x800C;&#x4E14;<strong>&#x68AF;&#x5EA6;&#x65B9;&#x5411;</strong>&#x662F;&#x4F7F;&#x5F97;<strong>&#x51FD;&#x6570;&#x503C;&#x589E;&#x957F;&#x6700;&#x5FEB;&#x7684;&#x65B9;&#x5411;</strong>&#x3002;</p>
<p>&#x8FD9;&#x4E2A;&#x6027;&#x8D28;&#x600E;&#x4E48;&#x7406;&#x89E3;&#x5462;&#xFF1F;&#x4E3E;&#x4E2A;&#x6817;&#x5B50;&#x3002;&#x5047;&#x5982;&#x6211;&#x662F;&#x4E2A;&#x60F3;&#x8981;&#x6210;&#x4E3A;&#x82F1;&#x96C4;&#x8054;&#x76DF;&#x90CA;&#x533A;&#x738B;&#x8005;&#x7684;&#x6B7B;&#x80A5;&#x5B85;&#xFF0C;&#x7136;&#x540E;&#x8981;&#x6210;&#x4E3A;&#x90CA;&#x533A;&#x738B;&#x8005;&#x53EF;&#x80FD;&#x6709;&#x8FD9;&#x4E48;&#x51E0;&#x4E2A;&#x56E0;&#x7D20;&#xFF0C;&#x4E00;&#x4E2A;&#x662F;&#x82F1;&#x96C4;&#x6C60;&#x7684;&#x6DF1;&#x6D45;&#xFF0C;&#x4E00;&#x4E2A;&#x662F;&#x5927;&#x5C40;&#x89C2;&#xFF0C;&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x662F;&#x9A9A;&#x64CD;&#x4F5C;&#x3002;&#x4ED6;&#x4EEC;&#x5BF9;&#x6211;&#x6210;&#x4E3A;&#x738B;&#x8005;&#x6765;&#x8BF4;&#x90FD;&#x6709;&#x4E00;&#x5B9A;&#x7684;&#x6743;&#x91CD;&#x3002;&#x5982;&#x56FE;&#x6240;&#x793A;&#xFF0C;&#x6BCF;&#x4E00;&#x4E2A;&#x56E0;&#x7D20;&#x7684;&#x7BAD;&#x5934;&#x90FD;&#x6709;&#x65B9;&#x5411;&#xFF08;&#x4E5F;&#x5C31;&#x662F;&#x56E0;&#x7D20;&#x5BF9;&#x4E8E;&#x6211;&#x6210;&#x4E3A;&#x738B;&#x8005;&#x7684;&#x504F;&#x5BFC;&#x7684;&#x65B9;&#x5411;&#xFF09;&#x548C;&#x957F;&#x5EA6;&#xFF08;&#x504F;&#x5BFC;&#x7684;&#x503C;&#x7684;&#x5927;&#x5C0F;&#xFF09;&#x3002;&#x7136;&#x540E;&#x5728;&#x8FD9;&#x4E9B;&#x56E0;&#x7D20;&#x7684;&#x5171;&#x540C;&#x4F5C;&#x7528;&#x4E0B;&#xFF0C;&#x6211;&#x6700;&#x7EC8;&#x4F1A;&#x671D;&#x7740;&#x4E00;&#x4E2A;&#x65B9;&#x5411;&#x6765;&#x8BAD;&#x7EC3;&#xFF08;&#x597D;&#x6BD4;&#x7269;&#x7406;&#x4E2D;&#x5206;&#x529B;&#x548C;&#x5408;&#x529B;&#x7684;&#x5173;&#x7CFB;&#xFF09;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x5C31;&#x80FD;&#x4EE5;&#x6700;&#x5FEB;&#x7684;&#x901F;&#x5EA6;&#x5411;&#x90CA;&#x533A;&#x738B;&#x8005;&#x66F4;&#x8FDB;&#x4E00;&#x6B65;&#x3002;</p>
<p><img src="img/17.jpg" alt=""></p>
<p>&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6211;&#x5982;&#x679C;&#x4E00;&#x76F4;&#x671D;&#x7740;&#x6700;&#x7EC8;&#x7684;&#x90A3;&#x4E2A;&#x65B9;&#x5411;&#x52AA;&#x529B;&#x7684;&#x8BDD;&#xFF0C;&#x7406;&#x8BBA;&#x4E0A;&#x6765;&#x8BF4;&#x6211;&#x5C31;&#x80FD;&#x4EE5;&#x6700;&#x5FEB;&#x7684;&#x901F;&#x5EA6;&#x6210;&#x4E3A;&#x90CA;&#x533A;&#x738B;&#x8005;&#x3002;</p>
<p>OK&#x3002;&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x4E86;&#x68AF;&#x5EA6;&#x7684;&#x65B9;&#x5411;&#x662F;&#x51FD;&#x6570;&#x589E;&#x957F;&#x6700;&#x5FEB;&#x7684;&#x65B9;&#x5411;&#xFF0C;&#x90A3;&#x6211;&#x5728;&#x68AF;&#x5EA6;&#x524D;&#x9762;&#x53D6;&#x4E2A;&#x8D1F;&#x53F7;&#xFF08;&#x53CD;&#x65B9;&#x5411;&#xFF09;&#xFF0C;&#x90A3;&#x4E0D;&#x5C31;&#x662F;&#x51FD;&#x6570;&#x4E0B;&#x964D;&#x6700;&#x5FEB;&#x7684;&#x65B9;&#x5411;&#x4E86;&#x4E48;&#x3002;&#x6240;&#x4EE5;&#xFF0C;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x5B83;&#x7684;&#x672C;&#x8D28;&#x5C31;&#x662F;&#x66F4;&#x65B0;&#x6743;&#x91CD;&#x7684;&#x65F6;&#x5019;&#x662F;&#x6CBF;&#x7740;&#x68AF;&#x5EA6;&#x7684;&#x53CD;&#x65B9;&#x5411;&#x66F4;&#x65B0;&#x3002;&#x597D;&#x6BD4;&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x56FE;&#xFF0C;&#x5047;&#x5982;&#x6211;&#x662F;&#x4E2A;&#x778E;&#x5B50;&#xFF0C;&#x7136;&#x540E;&#x83AB;&#x540D;&#x5176;&#x5999;&#x7684;&#x6765;&#x5230;&#x4E86;&#x4E00;&#x4E2A;&#x5C71;&#x8C37;&#x91CC;&#x3002;&#x73B0;&#x5728;&#x6211;&#x8981;&#x505A;&#x7684;&#x4E8B;&#x60C5;&#x5C31;&#x662F;&#x8D70;&#x5230;&#x5C71;&#x8C37;&#x7684;&#x8C37;&#x5E95;&#x3002;&#x56E0;&#x4E3A;&#x6211;&#x662F;&#x778E;&#x5B50;&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x53EA;&#x80FD;&#x4E00;&#x70B9;&#x4E00;&#x70B9;&#x7684;&#x632A;&#x3002;&#x8981;&#x632A;&#x7684;&#x8BDD;&#xFF0C;&#x90A3;&#x6211;&#x80AF;&#x5B9A;&#x662F;&#x90A3;&#x6211;&#x7684;&#x811A;&#x5728;&#x6211;&#x56DB;&#x5468;&#x626B;&#x4E00;&#x904D;&#xFF0C;&#x89C9;&#x5F97;&#x54EA;&#x91CC;&#x611F;&#x89C9;&#x8D77;&#x6765;&#x66F4;&#x50CF;&#x662F;&#x5728;&#x4E0B;&#x5C71;&#x90A3;&#x6211;&#x5C31;&#x5F80;&#x54EA;&#x91CC;&#x8D70;&#x3002;&#x7136;&#x540E;&#x8FD9;&#x6837;&#x5FAA;&#x73AF;&#x53CD;&#x590D;&#x4E00;&#x53D1;&#x6211;&#x6700;&#x7EC8;&#x5C31;&#x80FD;&#x8D70;&#x5230;&#x5C71;&#x8C37;&#x7684;&#x8C37;&#x5E95;&#x3002;</p>
<p><img src="img/18.jpg" alt=""></p>
<p>&#x6240;&#x4EE5;&#xFF0C;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x7684;&#x4F2A;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="img/19.jpg" alt=""></p>
<p>&#x5FAA;&#x73AF;&#x5E72;&#x7684;&#x4E8B;&#x60C5;&#x5C31;&#x76F8;&#x5F53;&#x4E8E;&#x6211;&#x4E0B;&#x5C71;&#x7684;&#x65F6;&#x5019;&#x5728;&#x8FC8;&#x6B65;&#x5B50;&#xFF0C;&#x4EE3;&#x7801;&#x91CC;&#x7684; <span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>&#x3B1;</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.43056em;"></span><span class="strut bottom" style="height:0.43056em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.0037em;">&#x3B1;</span></span></span></span> &#x9AD8;&#x7AEF;&#x70B9;&#x53EB;&#x5B66;&#x4E60;&#x7387;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x5C31;&#x662F;&#x4EE3;&#x8868;&#x6211;&#x4E0B;&#x5C71;&#x7684;&#x65F6;&#x5019;&#x6B65;&#x5B50;&#x8FC8;&#x591A;&#x5927;&#x3002;&#x503C;&#x8D8A;&#x5C0F;&#x5C31;&#x4EE3;&#x8868;&#x6211;&#x6B65;&#x5B50;&#x8FC8;&#x5F97;&#x5C0F;&#xFF0C;&#x5BB3;&#x6015;&#x4E00;&#x811A;&#x4E0B;&#x53BB;&#x6389;&#x5751;&#x91CC;&#x3002;&#x503C;&#x8D8A;&#x5927;&#x5C31;&#x4EE3;&#x8868;&#x6211;&#x80C6;&#x5B50;&#x8D8A;&#x5927;&#xFF0C;&#x6B65;&#x5B50;&#x8FC8;&#x5F97;&#x8D8A;&#x5927;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x53EF;&#x80FD;&#x4F1A;&#x8D8A;&#x8FC7;&#x5C71;&#x8C37;&#x7684;&#x8C37;&#x5E95;&#x3002;</p>
<h3 id="&#x4F7F;&#x7528;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x6C42;&#x89E3;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;&#x89E3;">&#x4F7F;&#x7528;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x6C42;&#x89E3;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;&#x89E3;</h3>
<p>&#x6211;&#x4EEC;&#x77E5;&#x9053;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;&#x635F;&#x5931;&#x51FD;&#x6570; <span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>J</mi></mrow><annotation encoding="application/x-tex">J</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.09618em;">J</span></span></span></span> &#x4E3A;&#xFF1A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>J</mi><mo>(</mo><mi>&#x3B8;</mi><mo>)</mo><mo>=</mo><mfrac><mrow><mn>1</mn></mrow><mrow><mn>2</mn></mrow></mfrac><msubsup><mo>&#x2211;</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>m</mi></msubsup><mo>(</mo><msub><mi>h</mi><mi>&#x3B8;</mi></msub><mo>(</mo><msup><mi>x</mi><mi>i</mi></msup><mo>)</mo><mo>&#x2212;</mo><msup><mi>y</mi><mi>i</mi></msup><msup><mo>)</mo><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">J(\theta)=\frac{1}{2}\sum^m_{i=1}(h_\theta(x^i)-y^i)^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.845108em;"></span><span class="strut bottom" style="height:1.190108em;vertical-align:-0.345em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.09618em;">J</span><span class="mopen">(</span><span class="mord mathit" style="margin-right:0.02778em;">&#x3B8;</span><span class="mclose">)</span><span class="mrel">=</span><span class="mord reset-textstyle textstyle uncramped"><span class="mopen sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span><span class="mfrac"><span class="vlist"><span style="top:0.345em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">2</span></span></span></span><span style="top:-0.22999999999999998em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle textstyle uncramped frac-line"></span></span><span style="top:-0.394em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord scriptstyle uncramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span><span class="mclose sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span></span><span class="mop"><span class="mop op-symbol small-op" style="top:-0.0000050000000000050004em;">&#x2211;</span><span class="msupsub"><span class="vlist"><span style="top:0.30001em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">i</span><span class="mrel mtight">=</span><span class="mord mathrm mtight">1</span></span></span></span><span style="top:-0.364em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathit mtight">m</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mopen">(</span><span class="mord"><span class="mord mathit">h</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fonts
<p><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mfrac><mrow><mi mathvariant="normal">&#x2202;</mi><mi>J</mi><mo>(</mo><msub><mi>&#x3B8;</mi><mi>j</mi></msub><mo>)</mo></mrow><mrow><msub><mi>&#x3B8;</mi><mi>J</mi></msub></mrow></mfrac><mo>=</mo><mo>(</mo><msub><mi>h</mi><mi>&#x3B8;</mi></msub><mo>(</mo><mi>x</mi><mo>)</mo><mo>&#x2212;</mo><mi>y</mi><mo>)</mo><msub><mi>x</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">
\frac{\partial J(\theta_j)}{\theta_J} = (h_\theta(x)-y)x_j
</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:1.03232em;"></span><span class="strut bottom" style="height:1.4776249999999997em;vertical-align:-0.44530499999999995em;"></span><span class="base textstyle uncramped"><span class="mord reset-textstyle textstyle uncramped"><span class="mopen sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span><span class="mfrac"><span class="vlist"><span style="top:0.345em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mtight"><span class="mord mathit mtight" style="margin-right:0.02778em;">&#x3B8;</span><span class="msupsub"><span class="vlist"><span style="top:0.14329285714285717em;margin-right:0.07142857142857144em;margin-left:-0.02778em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-scriptstyle scriptscriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.09618em;">J</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span><span style="top:-0.22999999999999998em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle textstyle uncramped frac-line"></span></span><span style="top:-0.50732em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord scriptstyle uncramped mtight"><span class="mord mathrm mtight" style="margin-right:0.05556em;">&#x2202;</span><span class="mord mathit mtight" style="margin-right:0.09618em;">J</span><span class="mopen mtight">(</span><span class="mord mtight"><span class="mord mathit mtight" style="margin-right:0.02778em;">&#x3B8;</span><span class="msupsub"><span class="vlist"><span style="top:0.14300000000000002em;margin-right:0.07142857142857144em;margin-left:-0.02778em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-scriptstyle scriptscriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mclose mtight">)</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span><span class="mclose sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span></span><span class="mrel">=</span><span class="mopen">(</span><span class="mord"><span class="mord mathit">h</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.02778em;">&#x3B8;</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mopen">(</span><span class="mord mathit">x</span><span class="mclose">)</span><span class="mbin">&#x2212;</span><span class="mord mathit" style="margin-right:0.03588em;">y</span><span class="mclose">)</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em
<p>&#x6240;&#x4EE5;&#x5F88;&#x81EA;&#x7136;&#x7684;&#x53EF;&#x4EE5;&#x60F3;&#x5230;&#xFF0C;&#x4F7F;&#x7528;&#x68AF;&#x5EA6;&#x4E0B;&#x964D;&#x6C42;&#x89E3;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x7684;&#x89E3;&#x7684;&#x6D41;&#x7A0B;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">&#x5FAA;&#x73AF;&#x82E5;&#x5E72;&#x6B21;
&#x8BA1;&#x7B97;&#x5F53;&#x524D;&#x53C2;&#x6570;theta&#x5BF9;&#x635F;&#x5931;&#x51FD;&#x6570;&#x7684;&#x68AF;&#x5EA6; gradient
theta = theta - alpha * gradient
</code></pre>
<p>&#x5F53;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>&#x3B8;</mi></mrow><annotation encoding="application/x-tex">\theta</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:0.69444em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.02778em;">&#x3B8;</span></span></span></span>&#x66F4;&#x65B0;&#x597D;&#x4E86;&#x4E4B;&#x540E;&#xFF0C;&#x5C31;&#x76F8;&#x5F53;&#x4E8E;&#x5F97;&#x5230;&#x4E86;&#x4E00;&#x4E2A;&#x7EBF;&#x6027;&#x56DE;&#x5F52;&#x6A21;&#x578B;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x53EA;&#x8981;&#x5C06;&#x6570;&#x636E;&#x653E;&#x5230;&#x6A21;&#x578B;&#x4E2D;&#x8FDB;&#x884C;&#x8BA1;&#x7B97;&#x5C31;&#x80FD;&#x5F97;&#x5230;&#x9884;&#x6D4B;&#x8F93;&#x51FA;&#x4E86;&#x3002;</p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="kNN.html" class="navigation navigation-prev " aria-label="Previous page: 近朱者赤近墨者黑-kNN">
<i class="fa fa-angle-left"></i>
</a>
<a href="logistic_regression.html" class="navigation navigation-next " aria-label="Next page: 使用回归的思想进行分类-逻辑回归">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"最简单的回归算法-线性回归","level":"1.3.2","depth":2,"next":{"title":"使用回归的思想进行分类-逻辑回归","level":"1.3.3","depth":2,"path":"logistic_regression.md","ref":"logistic_regression.md","articles":[]},"previous":{"title":"近朱者赤近墨者黑-kNN","level":"1.3.1","depth":2,"path":"kNN.md","ref":"kNN.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["katex"],"pluginsConfig":{"katex":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"linear_regression.md","mtime":"2019-07-04T08:14:32.052Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-06T07:31:21.537Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="gitbook/gitbook-plugin-search/search.js"></script>
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>