{"id":83,"date":"2019-12-19T13:04:01","date_gmt":"2019-12-19T05:04:01","guid":{"rendered":"https:\/\/kishere.gq\/?p=83"},"modified":"2020-01-04T16:00:35","modified_gmt":"2020-01-04T08:00:35","slug":"machine_learning2","status":"publish","type":"post","link":"https:\/\/blog.kishere.cn\/?p=83","title":{"rendered":"\u673a\u5668\u5b66\u4e602"},"content":{"rendered":"<h2>\u5f53\u53d8\u91cf\u589e\u52a0\u65f6<\/h2>\n<p><span class=\"katex math inline\">n<\/span> \u7279\u5f81(\u53d8\u91cf)\u7684\u6570\u91cf<br \/>\n<span class=\"katex math inline\">{x^{(i)}}<\/span> \u7b2ci\u4e2a\u8bad\u7ec3\u6837\u672c\u7684\u8f93\u5165\u7279\u5f81\u503c, \u662f\u4e00\u4e2an\u7ef4\u5411\u91cf<\/p>\n<div class=\"katex math multi-line no-emojify\">\\rm{x^{(i)}_j}\n<\/div>\n<p>\u65b0\u7684\u5047\u8bbe\u5f62\u5f0f<\/p>\n<div class=\"katex math multi-line no-emojify\">h_\\theta(x)=\\theta_0+\\theta_1x_1+\\theta_2x_2+\\theta_3x_3+\\theta_4x_4\n<\/div>\n<p>\u4e3a\u4e86\u65b9\u4fbf, \u5b9a\u4e49<span class=\"katex math inline\">x_0=1<\/span><br \/>\n\u5373<\/p>\n<div class=\"katex math multi-line no-emojify\">\\rm{x^{(i)}_0}=0\n<\/div>\n<p>\u5219<\/p>\n<div class=\"katex math multi-line no-emojify\">x=<br \/>\n\\begin{bmatrix}<br \/>\nx_0\\\\<br \/>\nx_1\\\\<br \/>\nx_2\\\\<br \/>\n\\vdots\\\\<br \/>\nx_n<br \/>\n\\end{bmatrix}<br \/>\n\\text{  }\\theta=<br \/>\n\\begin{bmatrix}<br \/>\nx_0\\\\<br \/>\nx_1\\\\<br \/>\nx_2\\\\<br \/>\n\\vdots\\\\<br \/>\nx_n<br \/>\n\\end{bmatrix}\n<\/div>\n<p>\u7528\u03b8\u7684\u8f6c\u7f6e\u4e58x<br \/>\n\u5f97:<\/p>\n<div class=\"katex math multi-line no-emojify\">\\theta^Tx=<br \/>\n\\begin{bmatrix}<br \/>\n\\theta_0 &amp; \\theta_1 &amp; \\dots &amp; \\theta_n<br \/>\n\\end{bmatrix}<br \/>\n\\begin{bmatrix}<br \/>\nx_0\\\\<br \/>\nx_1\\\\<br \/>\n\\vdots\\\\<br \/>\nx_n<br \/>\n\\end{bmatrix}\n<\/div>\n<div class=\"katex math multi-line no-emojify\">h_\\theta(x)=\\theta_0+\\theta_1x_1+\\theta_2x_2+\\dots\\theta_nx_n\n<\/div>\n<h2>\u591a\u5143\u7ebf\u6027\u56de\u5f52\u7684\u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5<\/h2>\n<p>\u4ee3\u4ef7\u51fd\u6570\u53d8\u4e3a:<\/p>\n<p><span class=\"katex math multi-line\">J(\\theta)= {1\\over2m}\\sum_{i=1}^{m}(h_\\theta(x^i)-y^i)^2\\\\<br \/>\n\\text{\u5176\u4e2d\u03b8\u662f\u4e00\u4e2an\u7ef4\u5411\u91cf}<\/span><\/p>\n<p>\u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5:<\/p>\n<p><span class=\"katex math multi-line\">\\theta_j:=\\theta_j-\\alpha{\\partial\\over\\partial\\theta_j}J(\\theta_0,\\dots,\\theta_n) \\text{ (j=0,&#8230;n)}<\/span><\/p>\n<p>\u5f97:<\/p>\n<p><span class=\"katex math multi-line\">\\theta_j:=\\theta_j-\\alpha {1\\over m}\\sum_{i=1}^m(h_\\theta(x^i)-y^i)x_j^i<\/span><\/p>\n<h2>\u7279\u5f81\u7f29\u653e<\/h2>\n<h3>\u5c06\u7279\u5f81\u503c\u9664\u4ee5\u533a\u95f4\u5bbd\u5ea6<\/h3>\n<p>\u5982\u679c\u7279\u5f81\u503c\u7684\u53d6\u503c\u8303\u56f4\u5dee\u8ddd\u5f88\u5927\u6bd4\u5982\u4e00\u4e2a\u662f0-2000\u4e00\u4e2a\u662f1-5, \u8fd9\u6837\u7b49\u503c\u56fe\u5c31\u4f1a\u5f62\u6210\u4e00\u4e2a\u4fee\u957f\u7684\u692d\u5706\u5f62:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/kishere.cn\/wp-content\/uploads\/2019\/12\/image-20191222173347895-300x212.png\" alt=\"\" \/> <img decoding=\"async\" src=\"https:\/\/kishere.cn\/wp-content\/uploads\/2019\/12\/image-20191222175033176.png\" alt=\"\" \/><\/p>\n<p>\u5982\u679c\u5728\u8fd9\u4e2a\u56fe\u4e0a\u8fd0\u884c\u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5, \u53ef\u80fd\u4f1a\u4f7f\u8def\u5f84\u53cd\u590d\u9707\u8361, \u624d\u4f1a\u6700\u7ec8\u5230\u8fbe\u5168\u5c40\u6700\u5c0f\u503c\u70b9.<\/p>\n<p>\u8fd9\u65f6\u5019\u53ef\u4ee5\u7528\u5230\u7279\u5f81\u7f29\u653e(scale the features):<\/p>\n<p>\u4ee4: <span class=\"katex math inline\">x_1 = {size \\over 2000}   ,   x_2={number_of_bedroom \\over 5}<\/span><\/p>\n<p>\u7b49\u503c\u56fe\u4f1a\u53d8\u5f97\u6bd4\u8f83\u5706\u4e00\u4e9b:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/kishere.cn\/wp-content\/uploads\/2019\/12\/image-20191222175033176.png\" alt=\"\" \/><\/p>\n<p>\u8fd9\u6837\u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5\u4f1a\u66f4\u5feb\u7684\u627e\u5230\u5c40\u90e8\u6700\u4f4e\u70b9.<\/p>\n<p>\u6267\u884c\u7279\u5f81\u7f29\u653e\u65f6, \u901a\u5e38\u4f1a\u4f7f\u6bcf\u4e2a\u7279\u5f81\u503c\u90fd\u5728<span class=\"katex math inline\">-1\\leq x_i \\leq 1<\/span>\u8fd9\u4e2a\u8303\u56f4\u5185. \u5f53\u7136\u4e0d\u9700\u8981\u5f3a\u6c42, \u5728\u8303\u56f4\u9644\u8fd1, \u533a\u95f4\u5bbd\u5ea6\u76f8\u4f3c\u4e5f\u53ef\u4ee5.<\/p>\n<h3>\u5747\u503c\u5f52\u4e00\u5316<\/h3>\n<p>\u7528<span class=\"katex math inline\">x_i-\\mu_i<\/span>\u6765\u4ee3\u66ff<span class=\"katex math inline\">x_i<\/span>. \u8ba9\u7279\u5f81\u503c\u5177\u6709\u4e3a0\u7684\u5e73\u5747\u503c(\u4e0d\u9700\u8981\u5e94\u7528\u5230<span class=\"katex math inline\">x_0<\/span>\u4e2d, <span class=\"katex math inline\">x_0 = 1<\/span>)<\/p>\n<p>\u5982:<br \/>\n<span class=\"katex math multi-line\">x_1 = {size-1000 \\over2000}<\/span><br \/>\n<span class=\"katex math multi-line\">x_2 = {bedroom &#8211; 2 \\over 5}<\/span><br \/>\n\u5f62\u5f0f\u53ef\u4ee5\u5f52\u7eb3\u4e3a:<br \/>\n<span class=\"katex math multi-line\">x_i = {x_i &#8211; \\mu_i \\over s_i}&#92;<\/span><br \/>\n<span class=\"katex math inline\">\\mu_1<\/span>\u662f\u8bad\u7ec3\u96c6\u4e2d\u7279\u5f81} <span class=\"katex math inline\">x_1<\/span>\u7684\u5e73\u5747\u503c<br \/>\ns_i\u662f\u7279\u5f81\u503c\u7684\u6700\u5927\u503c\u51cf\u53bb\u6700\u5c0f\u503c}, \u901a\u5e38\u4e5f\u7528\u6807\u51c6\u5dee\u6765\u4f5c\u4e3a<span class=\"katex math inline\">s_i<\/span><br \/>\n\u7279\u5f81\u7f29\u653e\u4e0d\u9700\u8981\u7279\u522b\u7cbe\u786e, \u53ea\u662f\u5c06\u68af\u5ea6\u4e0b\u964d\u8fd0\u884c\u5f97\u66f4\u5feb\u800c\u5df2.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u53d8\u91cf\u589e\u52a0\u65f6 n \u7279\u5f81(\u53d8\u91cf)\u7684\u6570\u91cf {x^{(i)}} \u7b2ci\u4e2a\u8bad\u7ec3\u6837\u672c\u7684\u8f93\u5165\u7279\u5f81\u503c, \u662f\u4e00\u4e2an\u7ef4\u5411\u91cf \\rm{x^{(i)}_j} \u65b0\u7684\u5047\u8bbe\u5f62\u5f0f h_\\theta(x)=\\theta_0+\\theta_1x_1+\\theta_2x_2+\\theta_3x_3+\\theta_4x_4 \u4e3a\u4e86\u65b9\u4fbf, \u5b9a\u4e49x_0=1 \u5373 \\rm{x^{(i)}_0}=0 \u5219 x= \\begin{bmatrix} x_0\\\\ x_1\\\\ x_2\\\\ \\vdots\\\\ x_n \\end{bmatrix} \\text{ }\\theta= \\begin{bmatrix} x_0\\\\ x_1\\\\ x_2\\\\ \\vdots\\\\ x_n \\end{bmatrix} \u7528\u03b8\u7684\u8f6c\u7f6e\u4e58x \u5f97: \\theta^Tx= \\begin{bmatrix} \\theta_0 &amp; \\theta_1 &amp; \\dots &amp; \\theta_n \\end{bmatrix} \\begin{bmatrix} x_0\\\\ x_1\\\\ \\vdots\\\\ x_n \\end{bmatrix} h_\\theta(x)=\\theta_0+\\theta_1x_1+\\theta_2x_2+\\dots\\theta_nx_n \u591a\u5143\u7ebf\u6027\u56de\u5f52\u7684\u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5 \u4ee3\u4ef7\u51fd\u6570\u53d8\u4e3a: J(\\theta)= {1\\over2m}\\sum_{i=1}^{m}(h_\\theta(x^i)-y^i)^2\\\\ \\text{\u5176\u4e2d\u03b8\u662f\u4e00\u4e2an\u7ef4\u5411\u91cf} \u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5: \\theta_j:=\\theta_j-\\alpha{\\partial\\over\\partial\\theta_j}J(\\theta_0,\\dots,\\theta_n) \\text{ (j=0,&#8230;n)} \u5f97: \\theta_j:=\\theta_j-\\alpha {1\\over m}\\sum_{i=1}^m(h_\\theta(x^i)-y^i)x_j^i \u7279\u5f81\u7f29\u653e \u5c06\u7279\u5f81\u503c\u9664\u4ee5\u533a\u95f4\u5bbd\u5ea6 \u5982\u679c\u7279\u5f81\u503c\u7684\u53d6\u503c\u8303\u56f4\u5dee\u8ddd\u5f88\u5927\u6bd4\u5982\u4e00\u4e2a\u662f0-2000\u4e00\u4e2a\u662f1-5, \u8fd9\u6837\u7b49\u503c\u56fe\u5c31\u4f1a\u5f62\u6210\u4e00\u4e2a\u4fee\u957f\u7684\u692d\u5706\u5f62: \u5982\u679c\u5728\u8fd9\u4e2a\u56fe\u4e0a\u8fd0\u884c\u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5, \u53ef\u80fd\u4f1a\u4f7f\u8def\u5f84\u53cd\u590d\u9707\u8361, \u624d\u4f1a\u6700\u7ec8\u5230\u8fbe\u5168\u5c40\u6700\u5c0f\u503c\u70b9. \u8fd9\u65f6\u5019\u53ef\u4ee5\u7528\u5230\u7279\u5f81\u7f29\u653e(scale the features): \u4ee4: x_1 = {size \\over 2000} , x_2={number_of_bedroom \\over 5} \u7b49\u503c\u56fe\u4f1a\u53d8\u5f97\u6bd4\u8f83\u5706\u4e00\u4e9b: \u8fd9\u6837\u68af\u5ea6\u4e0b\u964d\u7b97\u6cd5\u4f1a\u66f4\u5feb\u7684\u627e\u5230\u5c40\u90e8\u6700\u4f4e\u70b9. \u6267\u884c\u7279\u5f81\u7f29\u653e\u65f6, \u901a\u5e38\u4f1a\u4f7f\u6bcf\u4e2a\u7279\u5f81\u503c\u90fd\u5728-1\\leq x_i \\leq 1\u8fd9\u4e2a\u8303\u56f4\u5185. \u5f53\u7136\u4e0d\u9700\u8981\u5f3a\u6c42, \u5728\u8303\u56f4\u9644\u8fd1, \u533a\u95f4\u5bbd\u5ea6\u76f8\u4f3c\u4e5f\u53ef\u4ee5. \u5747\u503c\u5f52\u4e00\u5316 \u7528x_i-\\mu_i\u6765\u4ee3\u66ffx_i. \u8ba9\u7279\u5f81\u503c\u5177\u6709\u4e3a0\u7684\u5e73\u5747\u503c(\u4e0d\u9700\u8981\u5e94\u7528\u5230x_0\u4e2d, x_0 = 1) \u5982: x_1 = {size-1000 \\over2000} x_2 = {bedroom &#8211; 2 \\over 5} \u5f62\u5f0f\u53ef\u4ee5\u5f52\u7eb3\u4e3a: x_i = {x_i &#8211; \\mu_i \\over s_i}&#92; \\mu_1\u662f\u8bad\u7ec3\u96c6\u4e2d\u7279\u5f81} x_1\u7684\u5e73\u5747\u503c s_i\u662f\u7279\u5f81\u503c\u7684\u6700\u5927\u503c\u51cf\u53bb\u6700\u5c0f\u503c}, \u901a\u5e38\u4e5f\u7528\u6807\u51c6\u5dee\u6765\u4f5c\u4e3as_i \u7279\u5f81\u7f29\u653e\u4e0d\u9700\u8981\u7279\u522b\u7cbe\u786e, \u53ea\u662f\u5c06\u68af\u5ea6\u4e0b\u964d\u8fd0\u884c\u5f97\u66f4\u5feb\u800c\u5df2.<\/p>\n","protected":false},"author":1,"featured_media":94,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=\/wp\/v2\/posts\/83"}],"collection":[{"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=83"}],"version-history":[{"count":9,"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":118,"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions\/118"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=\/wp\/v2\/media\/94"}],"wp:attachment":[{"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kishere.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}